alchemy 0.1.11 → 0.1.13

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 (312) hide show
  1. package/README.md +324 -0
  2. package/lib/$.d.ts +8 -3
  3. package/lib/$.d.ts.map +1 -1
  4. package/lib/$.js +38 -27
  5. package/lib/$.js.map +1 -1
  6. package/lib/alchemize.d.ts.map +1 -1
  7. package/lib/alchemize.js +7 -0
  8. package/lib/alchemize.js.map +1 -1
  9. package/lib/apply.d.ts +2 -2
  10. package/lib/apply.d.ts.map +1 -1
  11. package/lib/apply.js +3 -3
  12. package/lib/apply.js.map +1 -1
  13. package/lib/aws/index.d.ts +1 -0
  14. package/lib/aws/index.d.ts.map +1 -1
  15. package/lib/aws/index.js +1 -0
  16. package/lib/aws/index.js.map +1 -1
  17. package/lib/aws/ses.d.ts +75 -0
  18. package/lib/aws/ses.d.ts.map +1 -0
  19. package/lib/aws/ses.js +197 -0
  20. package/lib/aws/ses.js.map +1 -0
  21. package/lib/cloudflare/api.d.ts +88 -0
  22. package/lib/cloudflare/api.d.ts.map +1 -0
  23. package/lib/cloudflare/api.js +184 -0
  24. package/lib/cloudflare/api.js.map +1 -0
  25. package/lib/cloudflare/asset-manifest.d.ts +15 -0
  26. package/lib/cloudflare/asset-manifest.d.ts.map +1 -0
  27. package/lib/cloudflare/asset-manifest.js +2 -0
  28. package/lib/cloudflare/asset-manifest.js.map +1 -0
  29. package/lib/cloudflare/auth.d.ts +52 -0
  30. package/lib/cloudflare/auth.d.ts.map +1 -0
  31. package/lib/cloudflare/auth.js +114 -0
  32. package/lib/cloudflare/auth.js.map +1 -0
  33. package/lib/cloudflare/bindings.d.ts +254 -0
  34. package/lib/cloudflare/bindings.d.ts.map +1 -0
  35. package/lib/cloudflare/bindings.js +2 -0
  36. package/lib/cloudflare/bindings.js.map +1 -0
  37. package/lib/cloudflare/durable-object-namespace.d.ts +23 -0
  38. package/lib/cloudflare/durable-object-namespace.d.ts.map +1 -0
  39. package/lib/cloudflare/durable-object-namespace.js +26 -0
  40. package/lib/cloudflare/durable-object-namespace.js.map +1 -0
  41. package/lib/cloudflare/generate-asset-manifest.d.ts +3 -0
  42. package/lib/cloudflare/generate-asset-manifest.d.ts.map +1 -0
  43. package/lib/cloudflare/generate-asset-manifest.js +69 -0
  44. package/lib/cloudflare/generate-asset-manifest.js.map +1 -0
  45. package/lib/cloudflare/index.d.ts +7 -0
  46. package/lib/cloudflare/index.d.ts.map +1 -0
  47. package/lib/cloudflare/index.js +7 -0
  48. package/lib/cloudflare/index.js.map +1 -0
  49. package/lib/cloudflare/kv-namespace.d.ts +61 -0
  50. package/lib/cloudflare/kv-namespace.d.ts.map +1 -0
  51. package/lib/cloudflare/kv-namespace.js +93 -0
  52. package/lib/cloudflare/kv-namespace.js.map +1 -0
  53. package/lib/cloudflare/state.d.ts +83 -0
  54. package/lib/cloudflare/state.d.ts.map +1 -0
  55. package/lib/cloudflare/state.js +109 -0
  56. package/lib/cloudflare/state.js.map +1 -0
  57. package/lib/cloudflare/static-site-router.d.ts +19 -0
  58. package/lib/cloudflare/static-site-router.d.ts.map +1 -0
  59. package/lib/cloudflare/static-site-router.js +110 -0
  60. package/lib/cloudflare/static-site-router.js.map +1 -0
  61. package/lib/cloudflare/static-site.d.ts +166 -0
  62. package/lib/cloudflare/static-site.d.ts.map +1 -0
  63. package/lib/cloudflare/static-site.js +168 -0
  64. package/lib/cloudflare/static-site.js.map +1 -0
  65. package/lib/cloudflare/types.d.ts +52 -0
  66. package/lib/cloudflare/types.d.ts.map +1 -0
  67. package/lib/cloudflare/types.js +21 -0
  68. package/lib/cloudflare/types.js.map +1 -0
  69. package/lib/cloudflare/upload-asset-manifest.d.ts +12 -0
  70. package/lib/cloudflare/upload-asset-manifest.d.ts.map +1 -0
  71. package/lib/cloudflare/upload-asset-manifest.js +55 -0
  72. package/lib/cloudflare/upload-asset-manifest.js.map +1 -0
  73. package/lib/cloudflare/worker-metadata.d.ts +130 -0
  74. package/lib/cloudflare/worker-metadata.d.ts.map +1 -0
  75. package/lib/cloudflare/worker-metadata.js +2 -0
  76. package/lib/cloudflare/worker-metadata.js.map +1 -0
  77. package/lib/cloudflare/worker-migration.d.ts +110 -0
  78. package/lib/cloudflare/worker-migration.d.ts.map +1 -0
  79. package/lib/cloudflare/worker-migration.js +11 -0
  80. package/lib/cloudflare/worker-migration.js.map +1 -0
  81. package/lib/cloudflare/worker.d.ts +105 -0
  82. package/lib/cloudflare/worker.d.ts.map +1 -0
  83. package/lib/cloudflare/worker.js +358 -0
  84. package/lib/cloudflare/worker.js.map +1 -0
  85. package/lib/destroy.d.ts +1 -1
  86. package/lib/destroy.d.ts.map +1 -1
  87. package/lib/destroy.js +2 -1
  88. package/lib/destroy.js.map +1 -1
  89. package/lib/esbuild.d.ts +83 -1
  90. package/lib/esbuild.d.ts.map +1 -1
  91. package/lib/esbuild.js +27 -18
  92. package/lib/esbuild.js.map +1 -1
  93. package/lib/fs.d.ts +1 -1
  94. package/lib/global.d.ts +0 -2
  95. package/lib/global.d.ts.map +1 -1
  96. package/lib/global.js +3 -3
  97. package/lib/global.js.map +1 -1
  98. package/lib/index.d.ts +1 -0
  99. package/lib/index.d.ts.map +1 -1
  100. package/lib/index.js +1 -0
  101. package/lib/index.js.map +1 -1
  102. package/lib/main.js +1 -1
  103. package/lib/main.js.map +1 -1
  104. package/lib/output.d.ts +18 -13
  105. package/lib/output.d.ts.map +1 -1
  106. package/lib/output.js +12 -5
  107. package/lib/output.js.map +1 -1
  108. package/lib/print.d.ts +7 -0
  109. package/lib/print.d.ts.map +1 -0
  110. package/lib/print.js +10 -0
  111. package/lib/print.js.map +1 -0
  112. package/lib/resource.d.ts +9 -4
  113. package/lib/resource.d.ts.map +1 -1
  114. package/lib/resource.js +127 -93
  115. package/lib/resource.js.map +1 -1
  116. package/lib/scope.d.ts +3 -0
  117. package/lib/scope.d.ts.map +1 -1
  118. package/lib/scope.js +4 -12
  119. package/lib/scope.js.map +1 -1
  120. package/lib/utils/content-type.d.ts +8 -0
  121. package/lib/utils/content-type.d.ts.map +1 -0
  122. package/lib/utils/content-type.js +41 -0
  123. package/lib/utils/content-type.js.map +1 -0
  124. package/package.json +27 -8
  125. package/src/$.ts +63 -30
  126. package/src/alchemize.ts +12 -0
  127. package/src/apply.ts +6 -6
  128. package/src/aws/index.ts +1 -0
  129. package/src/aws/ses.ts +346 -0
  130. package/src/cloudflare/api.ts +282 -0
  131. package/src/cloudflare/asset-manifest.ts +16 -0
  132. package/src/cloudflare/auth.ts +187 -0
  133. package/src/cloudflare/bindings.ts +297 -0
  134. package/src/cloudflare/durable-object-namespace.ts +43 -0
  135. package/src/cloudflare/generate-asset-manifest.ts +93 -0
  136. package/src/cloudflare/index.ts +6 -0
  137. package/src/cloudflare/kv-namespace.ts +195 -0
  138. package/src/cloudflare/state.ts +138 -0
  139. package/src/cloudflare/static-site-router.ts +150 -0
  140. package/src/cloudflare/static-site.ts +395 -0
  141. package/src/cloudflare/types.ts +71 -0
  142. package/src/cloudflare/upload-asset-manifest.ts +83 -0
  143. package/src/cloudflare/worker-metadata.ts +154 -0
  144. package/src/cloudflare/worker-migration.ts +145 -0
  145. package/src/cloudflare/worker.ts +666 -0
  146. package/src/destroy.ts +2 -2
  147. package/src/esbuild.ts +34 -22
  148. package/src/global.ts +1 -3
  149. package/src/index.ts +1 -1
  150. package/src/main.ts +1 -1
  151. package/src/output.ts +53 -37
  152. package/src/print.ts +18 -0
  153. package/src/resource.ts +163 -116
  154. package/src/scope.ts +7 -12
  155. package/src/utils/content-type.ts +42 -0
  156. package/lib/agent/ai.d.ts +0 -40
  157. package/lib/agent/ai.d.ts.map +0 -1
  158. package/lib/agent/ai.js +0 -132
  159. package/lib/agent/ai.js.map +0 -1
  160. package/lib/agent/anthropic.d.ts +0 -9
  161. package/lib/agent/anthropic.d.ts.map +0 -1
  162. package/lib/agent/anthropic.js +0 -25
  163. package/lib/agent/anthropic.js.map +0 -1
  164. package/lib/agent/dependencies.d.ts +0 -4
  165. package/lib/agent/dependencies.d.ts.map +0 -1
  166. package/lib/agent/dependencies.js +0 -48
  167. package/lib/agent/dependencies.js.map +0 -1
  168. package/lib/agent/file-context.d.ts +0 -13
  169. package/lib/agent/file-context.d.ts.map +0 -1
  170. package/lib/agent/file-context.js +0 -6
  171. package/lib/agent/file-context.js.map +0 -1
  172. package/lib/agent/index.d.ts +0 -10
  173. package/lib/agent/index.d.ts.map +0 -1
  174. package/lib/agent/index.js +0 -10
  175. package/lib/agent/index.js.map +0 -1
  176. package/lib/agent/model.d.ts +0 -8
  177. package/lib/agent/model.d.ts.map +0 -1
  178. package/lib/agent/model.js +0 -29
  179. package/lib/agent/model.js.map +0 -1
  180. package/lib/agent/module.d.ts +0 -81
  181. package/lib/agent/module.d.ts.map +0 -1
  182. package/lib/agent/module.js +0 -309
  183. package/lib/agent/module.js.map +0 -1
  184. package/lib/agent/openai.d.ts +0 -6
  185. package/lib/agent/openai.d.ts.map +0 -1
  186. package/lib/agent/openai.js +0 -41
  187. package/lib/agent/openai.js.map +0 -1
  188. package/lib/agent/program.d.ts +0 -12
  189. package/lib/agent/program.d.ts.map +0 -1
  190. package/lib/agent/program.js +0 -21
  191. package/lib/agent/program.js.map +0 -1
  192. package/lib/agent/prompts.d.ts +0 -4
  193. package/lib/agent/prompts.d.ts.map +0 -1
  194. package/lib/agent/prompts.js +0 -11
  195. package/lib/agent/prompts.js.map +0 -1
  196. package/lib/agent/scrape.d.ts +0 -71
  197. package/lib/agent/scrape.d.ts.map +0 -1
  198. package/lib/agent/scrape.js +0 -45
  199. package/lib/agent/scrape.js.map +0 -1
  200. package/lib/aws/auto/docs.d.ts +0 -11
  201. package/lib/aws/auto/docs.d.ts.map +0 -1
  202. package/lib/aws/auto/docs.js +0 -56
  203. package/lib/aws/auto/docs.js.map +0 -1
  204. package/lib/aws/auto/index.d.ts +0 -5
  205. package/lib/aws/auto/index.d.ts.map +0 -1
  206. package/lib/aws/auto/index.js +0 -5
  207. package/lib/aws/auto/index.js.map +0 -1
  208. package/lib/aws/auto/resource.d.ts +0 -24
  209. package/lib/aws/auto/resource.d.ts.map +0 -1
  210. package/lib/aws/auto/resource.js +0 -194
  211. package/lib/aws/auto/resource.js.map +0 -1
  212. package/lib/aws/auto/service.d.ts +0 -10
  213. package/lib/aws/auto/service.d.ts.map +0 -1
  214. package/lib/aws/auto/service.js +0 -34
  215. package/lib/aws/auto/service.js.map +0 -1
  216. package/lib/aws/auto/spec.d.ts +0 -83
  217. package/lib/aws/auto/spec.d.ts.map +0 -1
  218. package/lib/aws/auto/spec.js +0 -58
  219. package/lib/aws/auto/spec.js.map +0 -1
  220. package/lib/markdown/design.d.ts +0 -17
  221. package/lib/markdown/design.d.ts.map +0 -1
  222. package/lib/markdown/design.js +0 -92
  223. package/lib/markdown/design.js.map +0 -1
  224. package/lib/markdown/extract.d.ts +0 -7
  225. package/lib/markdown/extract.d.ts.map +0 -1
  226. package/lib/markdown/extract.js +0 -10
  227. package/lib/markdown/extract.js.map +0 -1
  228. package/lib/markdown/index.d.ts +0 -4
  229. package/lib/markdown/index.d.ts.map +0 -1
  230. package/lib/markdown/index.js +0 -4
  231. package/lib/markdown/index.js.map +0 -1
  232. package/lib/markdown/requirements.d.ts +0 -79
  233. package/lib/markdown/requirements.d.ts.map +0 -1
  234. package/lib/markdown/requirements.js +0 -105
  235. package/lib/markdown/requirements.js.map +0 -1
  236. package/lib/typescript/check-omission.d.ts +0 -2
  237. package/lib/typescript/check-omission.d.ts.map +0 -1
  238. package/lib/typescript/check-omission.js +0 -43
  239. package/lib/typescript/check-omission.js.map +0 -1
  240. package/lib/typescript/debug-type-errors.d.ts +0 -3
  241. package/lib/typescript/debug-type-errors.d.ts.map +0 -1
  242. package/lib/typescript/debug-type-errors.js +0 -35
  243. package/lib/typescript/debug-type-errors.js.map +0 -1
  244. package/lib/typescript/extract.d.ts +0 -7
  245. package/lib/typescript/extract.d.ts.map +0 -1
  246. package/lib/typescript/extract.js +0 -10
  247. package/lib/typescript/extract.js.map +0 -1
  248. package/lib/typescript/index.d.ts +0 -7
  249. package/lib/typescript/index.d.ts.map +0 -1
  250. package/lib/typescript/index.js +0 -7
  251. package/lib/typescript/index.js.map +0 -1
  252. package/lib/typescript/install-dependencies.d.ts +0 -29
  253. package/lib/typescript/install-dependencies.d.ts.map +0 -1
  254. package/lib/typescript/install-dependencies.js +0 -52
  255. package/lib/typescript/install-dependencies.js.map +0 -1
  256. package/lib/typescript/package.d.ts +0 -157
  257. package/lib/typescript/package.d.ts.map +0 -1
  258. package/lib/typescript/package.js +0 -115
  259. package/lib/typescript/package.js.map +0 -1
  260. package/lib/typescript/repair-omissions.d.ts +0 -3
  261. package/lib/typescript/repair-omissions.d.ts.map +0 -1
  262. package/lib/typescript/repair-omissions.js +0 -23
  263. package/lib/typescript/repair-omissions.js.map +0 -1
  264. package/lib/typescript/repair.d.ts +0 -3
  265. package/lib/typescript/repair.d.ts.map +0 -1
  266. package/lib/typescript/repair.js +0 -34
  267. package/lib/typescript/repair.js.map +0 -1
  268. package/lib/typescript/tsconfig.d.ts +0 -469
  269. package/lib/typescript/tsconfig.d.ts.map +0 -1
  270. package/lib/typescript/tsconfig.js +0 -143
  271. package/lib/typescript/tsconfig.js.map +0 -1
  272. package/lib/typescript/typescript.d.ts +0 -107
  273. package/lib/typescript/typescript.d.ts.map +0 -1
  274. package/lib/typescript/typescript.js +0 -180
  275. package/lib/typescript/typescript.js.map +0 -1
  276. package/lib/typescript/validate.d.ts +0 -10
  277. package/lib/typescript/validate.d.ts.map +0 -1
  278. package/lib/typescript/validate.js +0 -49
  279. package/lib/typescript/validate.js.map +0 -1
  280. package/src/agent/ai.ts +0 -215
  281. package/src/agent/anthropic.ts +0 -31
  282. package/src/agent/dependencies.ts +0 -62
  283. package/src/agent/file-context.ts +0 -8
  284. package/src/agent/index.ts +0 -9
  285. package/src/agent/model.ts +0 -39
  286. package/src/agent/module.ts +0 -418
  287. package/src/agent/openai.ts +0 -50
  288. package/src/agent/program.md +0 -38
  289. package/src/agent/program.ts +0 -37
  290. package/src/agent/prompts.ts +0 -20
  291. package/src/agent/scrape.ts +0 -47
  292. package/src/aws/auto/cfn.json +0 -225310
  293. package/src/aws/auto/docs.ts +0 -73
  294. package/src/aws/auto/index.ts +0 -4
  295. package/src/aws/auto/resource.ts +0 -269
  296. package/src/aws/auto/service.ts +0 -51
  297. package/src/aws/auto/spec.ts +0 -160
  298. package/src/markdown/design.ts +0 -125
  299. package/src/markdown/extract.ts +0 -9
  300. package/src/markdown/index.ts +0 -3
  301. package/src/markdown/requirements.ts +0 -135
  302. package/src/typescript/check-omission.ts +0 -47
  303. package/src/typescript/debug-type-errors.ts +0 -42
  304. package/src/typescript/extract.ts +0 -9
  305. package/src/typescript/index.ts +0 -6
  306. package/src/typescript/install-dependencies.ts +0 -61
  307. package/src/typescript/package.ts +0 -143
  308. package/src/typescript/repair-omissions.ts +0 -31
  309. package/src/typescript/repair.ts +0 -45
  310. package/src/typescript/tsconfig.ts +0 -170
  311. package/src/typescript/typescript.ts +0 -217
  312. package/src/typescript/validate.ts +0 -73
package/lib/aws/ses.js ADDED
@@ -0,0 +1,197 @@
1
+ import { AlreadyExistsException, CreateConfigurationSetCommand, CreateEmailIdentityCommand, DeleteConfigurationSetCommand, DeleteEmailIdentityCommand, GetConfigurationSetCommand, GetEmailIdentityCommand, NotFoundException, PutEmailIdentityDkimAttributesCommand, SESv2Client, } from "@aws-sdk/client-sesv2";
2
+ import { ignore } from "../error";
3
+ import { Resource } from "../resource";
4
+ /**
5
+ * AWS SES resource for creating and configuring Simple Email Service
6
+ */
7
+ export class SES extends Resource("aws::SES", async (ctx, props) => {
8
+ // Create SES client
9
+ const client = new SESv2Client({});
10
+ // Resource ID is either based on the configuration set name or email identity
11
+ const id = props.configurationSetName || props.emailIdentity || ctx.resourceID;
12
+ // Handle deletion
13
+ if (ctx.event === "delete") {
14
+ const output = ctx.output;
15
+ // Delete configuration set if it exists
16
+ if (output?.configurationSetName) {
17
+ await ignore(NotFoundException.name, () => client.send(new DeleteConfigurationSetCommand({
18
+ ConfigurationSetName: output.configurationSetName,
19
+ })));
20
+ }
21
+ // Delete email identity if it exists
22
+ if (output?.emailIdentity) {
23
+ await ignore(NotFoundException.name, () => client.send(new DeleteEmailIdentityCommand({
24
+ EmailIdentity: output.emailIdentity,
25
+ })));
26
+ }
27
+ // Return empty output for delete
28
+ return {
29
+ ...props,
30
+ id,
31
+ };
32
+ }
33
+ // Created resources
34
+ let configurationSetArn;
35
+ let emailIdentityArn;
36
+ let emailIdentityVerificationStatus;
37
+ let dkimVerificationStatus;
38
+ // Create or update configuration set if specified
39
+ if (props.configurationSetName) {
40
+ try {
41
+ // Check if configuration set exists
42
+ let getConfigResult;
43
+ try {
44
+ getConfigResult = await client.send(new GetConfigurationSetCommand({
45
+ ConfigurationSetName: props.configurationSetName,
46
+ }));
47
+ }
48
+ catch (error) {
49
+ if (error instanceof NotFoundException) {
50
+ getConfigResult = null;
51
+ }
52
+ else {
53
+ throw error;
54
+ }
55
+ }
56
+ if (getConfigResult) {
57
+ // For updating configuration set, we need to use individual commands
58
+ // since there's no unified UpdateConfigurationSetCommand
59
+ if (props.sendingOptions) {
60
+ await client.send(new CreateConfigurationSetCommand({
61
+ ConfigurationSetName: props.configurationSetName,
62
+ SendingOptions: props.sendingOptions,
63
+ }));
64
+ }
65
+ if (props.reputationOptions) {
66
+ await client.send(new CreateConfigurationSetCommand({
67
+ ConfigurationSetName: props.configurationSetName,
68
+ ReputationOptions: props.reputationOptions,
69
+ }));
70
+ }
71
+ if (props.trackingOptions) {
72
+ await client.send(new CreateConfigurationSetCommand({
73
+ ConfigurationSetName: props.configurationSetName,
74
+ TrackingOptions: props.trackingOptions,
75
+ }));
76
+ }
77
+ if (props.suppressionOptions) {
78
+ await client.send(new CreateConfigurationSetCommand({
79
+ ConfigurationSetName: props.configurationSetName,
80
+ SuppressionOptions: props.suppressionOptions,
81
+ }));
82
+ }
83
+ if (props.deliveryOptions) {
84
+ await client.send(new CreateConfigurationSetCommand({
85
+ ConfigurationSetName: props.configurationSetName,
86
+ DeliveryOptions: props.deliveryOptions,
87
+ }));
88
+ }
89
+ // In SESv2, the ARN isn't directly returned in the response
90
+ configurationSetArn = `arn:aws:ses:${process.env.AWS_REGION}:${process.env.AWS_ACCOUNT_ID}:configuration-set/${props.configurationSetName}`;
91
+ }
92
+ else {
93
+ // Create new configuration set
94
+ await client.send(new CreateConfigurationSetCommand({
95
+ ConfigurationSetName: props.configurationSetName,
96
+ SendingOptions: props.sendingOptions,
97
+ ReputationOptions: props.reputationOptions,
98
+ TrackingOptions: props.trackingOptions,
99
+ SuppressionOptions: props.suppressionOptions,
100
+ DeliveryOptions: props.deliveryOptions,
101
+ Tags: Object.entries(props.tags || {}).map(([Key, Value]) => ({
102
+ Key,
103
+ Value,
104
+ })),
105
+ }));
106
+ // In SESv2, the ARN isn't directly returned in the response
107
+ configurationSetArn = `arn:aws:ses:${process.env.AWS_REGION}:${process.env.AWS_ACCOUNT_ID}:configuration-set/${props.configurationSetName}`;
108
+ }
109
+ }
110
+ catch (error) {
111
+ if (error instanceof AlreadyExistsException) {
112
+ // If it already exists but we couldn't get it (permissions issue), continue
113
+ console.warn(`Configuration set ${props.configurationSetName} already exists but cannot be retrieved`);
114
+ }
115
+ else {
116
+ throw error;
117
+ }
118
+ }
119
+ }
120
+ // Create or verify email identity if specified
121
+ if (props.emailIdentity) {
122
+ try {
123
+ // Check if identity exists
124
+ let getIdentityResult;
125
+ try {
126
+ getIdentityResult = await client.send(new GetEmailIdentityCommand({
127
+ EmailIdentity: props.emailIdentity,
128
+ }));
129
+ }
130
+ catch (error) {
131
+ if (error instanceof NotFoundException) {
132
+ getIdentityResult = null;
133
+ }
134
+ else {
135
+ throw error;
136
+ }
137
+ }
138
+ if (!getIdentityResult) {
139
+ // Create new email identity
140
+ const createIdentityResult = await client.send(new CreateEmailIdentityCommand({
141
+ EmailIdentity: props.emailIdentity,
142
+ Tags: Object.entries(props.tags || {}).map(([Key, Value]) => ({
143
+ Key,
144
+ Value,
145
+ })),
146
+ }));
147
+ // If it's an email address, we don't need to explicitly verify in v2
148
+ // The verification email is automatically sent by SES in v2
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
+ createIdentityResult.VerifiedForSendingStatus
153
+ ? "VERIFIED"
154
+ : "PENDING";
155
+ }
156
+ else {
157
+ // Store the identity information
158
+ emailIdentityArn = `arn:aws:ses:${process.env.AWS_REGION}:${process.env.AWS_ACCOUNT_ID}:identity/${props.emailIdentity}`;
159
+ emailIdentityVerificationStatus =
160
+ getIdentityResult.VerifiedForSendingStatus ? "VERIFIED" : "PENDING";
161
+ // Update DKIM settings if requested
162
+ if (props.enableDkim !== undefined) {
163
+ if (props.enableDkim) {
164
+ await client.send(new PutEmailIdentityDkimAttributesCommand({
165
+ EmailIdentity: props.emailIdentity,
166
+ SigningEnabled: true,
167
+ }));
168
+ // We can check the current status of DKIM
169
+ dkimVerificationStatus = "PENDING"; // Default to pending
170
+ // Get the updated identity to check DKIM status
171
+ const updatedIdentity = await client.send(new GetEmailIdentityCommand({
172
+ EmailIdentity: props.emailIdentity,
173
+ }));
174
+ if (updatedIdentity.DkimAttributes?.Status) {
175
+ dkimVerificationStatus = updatedIdentity.DkimAttributes.Status;
176
+ }
177
+ }
178
+ }
179
+ }
180
+ }
181
+ catch (error) {
182
+ console.error(`Error configuring email identity ${props.emailIdentity}:`, error);
183
+ throw error;
184
+ }
185
+ }
186
+ // Return the resource output
187
+ return {
188
+ ...props,
189
+ id,
190
+ configurationSetArn,
191
+ emailIdentityArn,
192
+ emailIdentityVerificationStatus,
193
+ dkimVerificationStatus,
194
+ };
195
+ }) {
196
+ }
197
+ //# sourceMappingURL=ses.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"ses.js","sourceRoot":"","sources":["../../src/aws/ses.ts"],"names":[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,CAAC,cAAc,CAAC,MAAM,CAAC;wBACjE,CAAC;oBACH,CAAC;gBACH,CAAC;YACH,CAAC;QACH,CAAC;QAAC,OAAO,KAAK,EAAE,CAAC;YACf,OAAO,CAAC,KAAK,CACX,oCAAoC,KAAK,CAAC,aAAa,GAAG,EAC1D,KAAK,CACN,CAAC;YACF,MAAM,KAAK,CAAC;QACd,CAAC;IACH,CAAC;IAED,6BAA6B;IAC7B,OAAO;QACL,GAAG,KAAK;QACR,EAAE;QACF,mBAAmB;QACnB,gBAAgB;QAChB,+BAA+B;QAC/B,sBAAsB;KACvB,CAAC;AACJ,CAAC,CACF;CAAG"}
@@ -0,0 +1,88 @@
1
+ /**
2
+ * Options for Cloudflare API requests
3
+ */
4
+ export interface CloudflareApiOptions {
5
+ /**
6
+ * API Key to use (overrides CLOUDFLARE_API_KEY env var)
7
+ */
8
+ apiKey?: string;
9
+ /**
10
+ * Account ID to use (overrides CLOUDFLARE_ACCOUNT_ID env var)
11
+ * If not provided, will be automatically retrieved from the Cloudflare API
12
+ */
13
+ accountId?: string;
14
+ /**
15
+ * Zone ID to use (overrides CLOUDFLARE_ZONE_ID env var)
16
+ */
17
+ zoneId?: string;
18
+ /**
19
+ * Email to use with API Key authentication
20
+ * If not provided, will attempt to discover from Cloudflare API
21
+ */
22
+ email?: string;
23
+ }
24
+ /**
25
+ * Creates a CloudflareApi instance with automatic account ID discovery if not provided
26
+ *
27
+ * @param options API options
28
+ * @returns Promise resolving to a CloudflareApi instance
29
+ */
30
+ export declare function createCloudflareApi(options?: CloudflareApiOptions): Promise<CloudflareApi>;
31
+ /**
32
+ * Cloudflare API client using raw fetch
33
+ */
34
+ export declare class CloudflareApi {
35
+ /** Base URL for Cloudflare API */
36
+ readonly baseUrl: string;
37
+ /** Cloudflare API Key */
38
+ readonly apiKey: string;
39
+ /** Cloudflare account ID */
40
+ readonly accountId: string;
41
+ /** Cloudflare zone ID (if provided) */
42
+ readonly zoneId: string | null;
43
+ /** User email (when using API Key auth) */
44
+ readonly email?: string;
45
+ /** Auth options for making requests */
46
+ private readonly authOptions;
47
+ /**
48
+ * Create a new Cloudflare API client
49
+ * Use createCloudflareApi factory function instead of direct constructor
50
+ * for automatic account ID discovery.
51
+ *
52
+ * @param options API options
53
+ */
54
+ constructor(options?: CloudflareApiOptions);
55
+ /**
56
+ * Make a fetch request to the Cloudflare API
57
+ *
58
+ * @param path API path (without base URL)
59
+ * @param init Fetch init options
60
+ * @returns Raw Response object from fetch
61
+ */
62
+ fetch(path: string, init?: RequestInit): Promise<Response>;
63
+ /**
64
+ * Helper for GET requests
65
+ */
66
+ get(path: string, init?: RequestInit): Promise<Response>;
67
+ /**
68
+ * Helper for HEAD requests
69
+ */
70
+ head(path: string, init?: RequestInit): Promise<Response>;
71
+ /**
72
+ * Helper for POST requests
73
+ */
74
+ post(path: string, body: any, init?: RequestInit): Promise<Response>;
75
+ /**
76
+ * Helper for PUT requests
77
+ */
78
+ put(path: string, body: any, init?: RequestInit): Promise<Response>;
79
+ /**
80
+ * Helper for PATCH requests
81
+ */
82
+ patch(path: string, body: any, init?: RequestInit): Promise<Response>;
83
+ /**
84
+ * Helper for DELETE requests
85
+ */
86
+ delete(path: string, init?: RequestInit): Promise<Response>;
87
+ }
88
+ //# sourceMappingURL=api.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"api.d.ts","sourceRoot":"","sources":["../../src/cloudflare/api.ts"],"names":[],"mappings":"AAEA;;GAEG;AACH,MAAM,WAAW,oBAAoB;IACnC;;OAEG;IACH,MAAM,CAAC,EAAE,MAAM,CAAC;IAEhB;;;OAGG;IACH,SAAS,CAAC,EAAE,MAAM,CAAC;IAEnB;;OAEG;IACH,MAAM,CAAC,EAAE,MAAM,CAAC;IAEhB;;;OAGG;IACH,KAAK,CAAC,EAAE,MAAM,CAAC;CAChB;AAUD;;;;;GAKG;AACH,wBAAsB,mBAAmB,CACvC,OAAO,GAAE,oBAAyB,GACjC,OAAO,CAAC,aAAa,CAAC,CAexB;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AG,OAAO,CAAC,QAAQ,CAAC;CAGtE"}
@@ -0,0 +1,184 @@
1
+ import { getCloudflareHeaders } from "./auth";
2
+ /**
3
+ * Creates a CloudflareApi instance with automatic account ID discovery if not provided
4
+ *
5
+ * @param options API options
6
+ * @returns Promise resolving to a CloudflareApi instance
7
+ */
8
+ export async function createCloudflareApi(options = {}) {
9
+ try {
10
+ return new CloudflareApi({
11
+ ...options,
12
+ accountId: options.accountId ||
13
+ process.env.CLOUDFLARE_ACCOUNT_ID ||
14
+ (await fetchAccountId()),
15
+ });
16
+ }
17
+ catch (error) {
18
+ console.error("Error during Cloudflare account ID discovery:", error);
19
+ throw new Error("Failed to automatically discover Cloudflare account ID. Please provide an account ID explicitly or ensure your API token/key has sufficient permissions.");
20
+ }
21
+ }
22
+ /**
23
+ * Cloudflare API client using raw fetch
24
+ */
25
+ export class CloudflareApi {
26
+ /** Base URL for Cloudflare API */
27
+ baseUrl;
28
+ /** Cloudflare API Key */
29
+ apiKey;
30
+ /** Cloudflare account ID */
31
+ accountId;
32
+ /** Cloudflare zone ID (if provided) */
33
+ zoneId;
34
+ /** User email (when using API Key auth) */
35
+ email;
36
+ /** Auth options for making requests */
37
+ authOptions;
38
+ /**
39
+ * Create a new Cloudflare API client
40
+ * Use createCloudflareApi factory function instead of direct constructor
41
+ * for automatic account ID discovery.
42
+ *
43
+ * @param options API options
44
+ */
45
+ constructor(options = {}) {
46
+ this.baseUrl = "https://api.cloudflare.com/client/v4";
47
+ const apiKey = options.apiKey || process.env.CLOUDFLARE_API_KEY || undefined;
48
+ if (!apiKey) {
49
+ throw new Error("No API key provided. Use createCloudflareApi() instead for automatic account discovery.");
50
+ }
51
+ this.apiKey = apiKey;
52
+ this.email = options.email || process.env.CLOUDFLARE_EMAIL;
53
+ if (!this.email) {
54
+ throw new Error("No email provided. Use createCloudflareApi() instead for automatic account discovery.");
55
+ }
56
+ // Get account ID from options or environment
57
+ this.accountId =
58
+ options.accountId || process.env.CLOUDFLARE_ACCOUNT_ID || "";
59
+ if (!this.accountId) {
60
+ throw new Error("No account ID provided. Use createCloudflareApi() instead for automatic account discovery.");
61
+ }
62
+ // Zone ID is optional for some operations
63
+ this.zoneId = options.zoneId || process.env.CLOUDFLARE_ZONE_ID || null;
64
+ // Store auth options for later use
65
+ this.authOptions = {
66
+ email: this.email,
67
+ };
68
+ }
69
+ /**
70
+ * Make a fetch request to the Cloudflare API
71
+ *
72
+ * @param path API path (without base URL)
73
+ * @param init Fetch init options
74
+ * @returns Raw Response object from fetch
75
+ */
76
+ async fetch(path, init = {}) {
77
+ // Get content type from init headers or default to application/json
78
+ let contentType = "application/json";
79
+ if (init.headers) {
80
+ const initHeaders = init.headers;
81
+ if (initHeaders["Content-Type"]) {
82
+ contentType = initHeaders["Content-Type"];
83
+ }
84
+ }
85
+ // Get auth headers (async now)
86
+ const authHeaders = await getCloudflareHeaders(contentType, this.authOptions);
87
+ // Combine all headers
88
+ const combinedHeaders = {
89
+ ...authHeaders,
90
+ };
91
+ // Add headers from init if provided
92
+ if (init.headers) {
93
+ const initHeadersObj = init.headers;
94
+ Object.keys(initHeadersObj).forEach((key) => {
95
+ combinedHeaders[key] = initHeadersObj[key];
96
+ });
97
+ }
98
+ // If using FormData, remove Content-Type to let browser set it with boundary
99
+ if (init.body instanceof FormData) {
100
+ delete combinedHeaders["Content-Type"];
101
+ }
102
+ const url = `${this.baseUrl}${path}`;
103
+ // Make the request
104
+ return fetch(url, {
105
+ ...init,
106
+ headers: combinedHeaders,
107
+ });
108
+ }
109
+ /**
110
+ * Helper for GET requests
111
+ */
112
+ async get(path, init = {}) {
113
+ return this.fetch(path, { ...init, method: "GET" });
114
+ }
115
+ /**
116
+ * Helper for HEAD requests
117
+ */
118
+ async head(path, init = {}) {
119
+ return this.fetch(path, { ...init, method: "HEAD" });
120
+ }
121
+ /**
122
+ * Helper for POST requests
123
+ */
124
+ async post(path, body, init = {}) {
125
+ const requestBody = body instanceof FormData
126
+ ? body
127
+ : typeof body === "string"
128
+ ? body
129
+ : JSON.stringify(body);
130
+ return this.fetch(path, { ...init, method: "POST", body: requestBody });
131
+ }
132
+ /**
133
+ * Helper for PUT requests
134
+ */
135
+ async put(path, body, init = {}) {
136
+ const requestBody = body instanceof FormData ? body : JSON.stringify(body);
137
+ return this.fetch(path, { ...init, method: "PUT", body: requestBody });
138
+ }
139
+ /**
140
+ * Helper for PATCH requests
141
+ */
142
+ async patch(path, body, init = {}) {
143
+ return this.fetch(path, {
144
+ ...init,
145
+ method: "PATCH",
146
+ body: JSON.stringify(body),
147
+ });
148
+ }
149
+ /**
150
+ * Helper for DELETE requests
151
+ */
152
+ async delete(path, init = {}) {
153
+ return this.fetch(path, { ...init, method: "DELETE" });
154
+ }
155
+ }
156
+ /**
157
+ * Create a temporary API client for bootstrapping
158
+ * This client can only be used to fetch the account ID
159
+ */
160
+ async function fetchAccountId() {
161
+ // Create a minimal API client for bootstrapping
162
+ const baseUrl = "https://api.cloudflare.com/client/v4";
163
+ // Get content type and auth headers
164
+ const authHeaders = await getCloudflareHeaders("application/json");
165
+ // Make the request to get accounts
166
+ const response = await fetch(`${baseUrl}/accounts`, {
167
+ method: "GET",
168
+ headers: authHeaders,
169
+ });
170
+ if (!response.ok) {
171
+ const errorData = await response.json().catch(() => ({
172
+ errors: [{ message: response.statusText }],
173
+ }));
174
+ throw new Error(`Error fetching Cloudflare accounts: ${errorData.errors?.[0]?.message || response.statusText}`);
175
+ }
176
+ const data = await response.json();
177
+ const accounts = data.result;
178
+ if (!accounts || accounts.length === 0) {
179
+ throw new Error("No Cloudflare accounts found. Check your API token/key permissions.");
180
+ }
181
+ // Return the first account ID
182
+ return accounts[0].id;
183
+ }
184
+ //# sourceMappingURL=api.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"api.js","sourceRoot":"","sources":["../../src/cloudflare/api.ts"],"names":[],"mappings":"AAAA,OAAO,EAA8B,oBAAoB,EAAE,MAAM,QAAQ,CAAC;AAqC1E;;;;;GAKG;AACH,MAAM,CAAC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AAK,CACb,uCAAuC,SAAS,CAAC,MAAM,EAAE,CAAC,CAAC,CAAC,EAAE,OAAO,IAAI,QAAQ,CAAC,UAAU,EAAE,CAC/F,CAAC;IACJ,CAAC;IAED,MAAM,IAAI,GAAQ,MAAM,QAAQ,CAAC,IAAI,EAAE,CAAC;IACxC,MAAM,QAAQ,GAAG,IAAI,CAAC,MAA6B,CAAC;IAEpD,IAAI,CAAC,QAAQ,IAAI,QAAQ,CAAC,MAAM,KAAK,CAAC,EAAE,CAAC;QACvC,MAAM,IAAI,KAAK,CACb,qEAAqE,CACtE,CAAC;IACJ,CAAC;IAED,8BAA8B;IAC9B,OAAO,QAAQ,CAAC,CAAC,CAAC,CAAC,EAAE,CAAC;AACxB,CAAC"}
@@ -0,0 +1,15 @@
1
+ export type AssetManifest = AssetManifestEntry[];
2
+ export interface AssetManifestEntry {
3
+ source: string;
4
+ key: string;
5
+ hash: string;
6
+ cacheControl: string;
7
+ contentType?: string;
8
+ }
9
+ export interface FileOption {
10
+ files: string | string[];
11
+ cacheControl: string;
12
+ contentType?: string;
13
+ ignore?: string[];
14
+ }
15
+ //# sourceMappingURL=asset-manifest.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"asset-manifest.d.ts","sourceRoot":"","sources":["../../src/cloudflare/asset-manifest.ts"],"names":[],"mappings":"AAAA,MAAM,MAAM,aAAa,GAAG,kBAAkB,EAAE,CAAC;AAEjD,MAAM,WAAW,kBAAkB;IACjC,MAAM,EAAE,MAAM,CAAC;IACf,GAAG,EAAE,MAAM,CAAC;IACZ,IAAI,EAAE,MAAM,CAAC;IACb,YAAY,EAAE,MAAM,CAAC;IACrB,WAAW,CAAC,EAAE,MAAM,CAAC;CACtB;AAED,MAAM,WAAW,UAAU;IACzB,KAAK,EAAE,MAAM,GAAG,MAAM,EAAE,CAAC;IACzB,YAAY,EAAE,MAAM,CAAC;IACrB,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,MAAM,CAAC,EAAE,MAAM,EAAE,CAAC;CACnB"}
@@ -0,0 +1,2 @@
1
+ export {};
2
+ //# sourceMappingURL=asset-manifest.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"asset-manifest.js","sourceRoot":"","sources":["../../src/cloudflare/asset-manifest.ts"],"names":[],"mappings":""}
@@ -0,0 +1,52 @@
1
+ /**
2
+ * Authentication options for Cloudflare API
3
+ */
4
+ export interface CloudflareAuthOptions {
5
+ /**
6
+ * If true, throw an error when no authentication is found
7
+ * @default true
8
+ */
9
+ required?: boolean;
10
+ /**
11
+ * Email to use with API Key
12
+ * If not provided, will attempt to discover from Cloudflare API
13
+ */
14
+ email?: string;
15
+ }
16
+ /**
17
+ * Authentication headers for Cloudflare API
18
+ */
19
+ export interface CloudflareAuthHeaders {
20
+ /**
21
+ * Authentication headers to use with fetch
22
+ */
23
+ headers: Record<string, string>;
24
+ /**
25
+ * Type of authentication being used
26
+ */
27
+ type: "token" | "key" | "none";
28
+ /**
29
+ * User email (only present when using API Key auth)
30
+ */
31
+ email?: string;
32
+ }
33
+ /**
34
+ * Get authentication headers for Cloudflare API
35
+ *
36
+ * Priority:
37
+ * 1. API Token (CLOUDFLARE_API_TOKEN) - Recommended by Cloudflare
38
+ * 2. API Key (CLOUDFLARE_API_KEY) - Will attempt to discover email automatically
39
+ *
40
+ * @param options Authentication options
41
+ * @returns Authentication headers
42
+ */
43
+ export declare function getCloudflareAuth(options?: CloudflareAuthOptions): Promise<CloudflareAuthHeaders>;
44
+ /**
45
+ * Get headers for a Cloudflare API request, including content-type
46
+ *
47
+ * @param contentType Content type for the request
48
+ * @param options Authentication options
49
+ * @returns Complete headers for the request
50
+ */
51
+ export declare function getCloudflareHeaders(contentType?: string, options?: CloudflareAuthOptions): Promise<Record<string, string>>;
52
+ //# sourceMappingURL=auth.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"auth.d.ts","sourceRoot":"","sources":["../../src/cloudflare/auth.ts"],"names":[],"mappings":"AAAA;;GAEG;AACH,MAAM,WAAW,qBAAqB;IACpC;;;OAGG;IACH,QAAQ,CAAC,EAAE,OAAO,CAAC;IAEnB;;;OAGG;IACH,KAAK,CAAC,EAAE,MAAM,CAAC;CAChB;AAED;;GAEG;AACH,MAAM,WAAW,qBAAqB;IACpC;;OAEG;IACH,OAAO,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;IAEhC;;OAEG;IACH,IAAI,EAAE,OAAO,GAAG,KAAK,GAAG,MAAM,CAAC;IAE/B;;OAEG;IACH,KAAK,CAAC,EAAE,MAAM,CAAC;CAChB;AAeD;;;;;;;;;GASG;AACH,wBAAsB,iBAAiB,CACrC,OAAO,GAAE,qBAA0B,GAClC,OAAO,CAAC,qBAAqB,CAAC,CAkEhC;AAyCD;;;;;;GAMG;AACH,wBAAsB,oBAAoB,CACxC,WAAW,SAAqB,EAChC,OAAO,GAAE,qBAA0B,GAClC,OAAO,CAAC,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC,CAOjC"}