alchemy 0.22.4 → 0.23.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 (160) hide show
  1. package/lib/aws/bucket.d.ts.map +1 -1
  2. package/lib/aws/bucket.js +13 -12
  3. package/lib/aws/bucket.js.map +1 -1
  4. package/lib/aws/control/client.d.ts.map +1 -1
  5. package/lib/aws/control/client.js +5 -3
  6. package/lib/aws/control/client.js.map +1 -1
  7. package/lib/aws/control/resource.d.ts.map +1 -1
  8. package/lib/aws/control/resource.js +13 -4
  9. package/lib/aws/control/resource.js.map +1 -1
  10. package/lib/aws/control/types.d.ts +85129 -0
  11. package/lib/aws/function.d.ts.map +1 -1
  12. package/lib/aws/function.js +51 -42
  13. package/lib/aws/function.js.map +1 -1
  14. package/lib/aws/index.d.ts +1 -0
  15. package/lib/aws/index.d.ts.map +1 -1
  16. package/lib/aws/index.js +1 -0
  17. package/lib/aws/index.js.map +1 -1
  18. package/lib/aws/policy-attachment.d.ts.map +1 -1
  19. package/lib/aws/policy-attachment.js +5 -4
  20. package/lib/aws/policy-attachment.js.map +1 -1
  21. package/lib/aws/policy.d.ts.map +1 -1
  22. package/lib/aws/policy.js +21 -20
  23. package/lib/aws/policy.js.map +1 -1
  24. package/lib/aws/queue.d.ts.map +1 -1
  25. package/lib/aws/queue.js +19 -15
  26. package/lib/aws/queue.js.map +1 -1
  27. package/lib/aws/retry.d.ts +5 -0
  28. package/lib/aws/retry.d.ts.map +1 -0
  29. package/lib/aws/retry.js +27 -0
  30. package/lib/aws/retry.js.map +1 -0
  31. package/lib/aws/role.d.ts.map +1 -1
  32. package/lib/aws/role.js +31 -30
  33. package/lib/aws/role.js.map +1 -1
  34. package/lib/aws/ses.d.ts.map +1 -1
  35. package/lib/aws/ses.js +27 -26
  36. package/lib/aws/ses.js.map +1 -1
  37. package/lib/aws/ssm-parameter.d.ts +150 -0
  38. package/lib/aws/ssm-parameter.d.ts.map +1 -0
  39. package/lib/aws/ssm-parameter.js +184 -0
  40. package/lib/aws/ssm-parameter.js.map +1 -0
  41. package/lib/aws/table.d.ts.map +1 -1
  42. package/lib/aws/table.js +9 -27
  43. package/lib/aws/table.js.map +1 -1
  44. package/lib/cloudflare/account-id.d.ts +1 -0
  45. package/lib/cloudflare/account-id.d.ts.map +1 -1
  46. package/lib/cloudflare/account-id.js.map +1 -1
  47. package/lib/cloudflare/api.d.ts.map +1 -1
  48. package/lib/cloudflare/api.js +22 -2
  49. package/lib/cloudflare/api.js.map +1 -1
  50. package/lib/cloudflare/index.d.ts +2 -1
  51. package/lib/cloudflare/index.d.ts.map +1 -1
  52. package/lib/cloudflare/index.js +2 -1
  53. package/lib/cloudflare/index.js.map +1 -1
  54. package/lib/cloudflare/queue.d.ts.map +1 -1
  55. package/lib/cloudflare/queue.js +1 -0
  56. package/lib/cloudflare/queue.js.map +1 -1
  57. package/lib/cloudflare/route.d.ts +7 -0
  58. package/lib/cloudflare/route.d.ts.map +1 -1
  59. package/lib/cloudflare/route.js +44 -2
  60. package/lib/cloudflare/route.js.map +1 -1
  61. package/lib/cloudflare/worker-metadata.d.ts.map +1 -1
  62. package/lib/cloudflare/worker-metadata.js +1 -2
  63. package/lib/cloudflare/worker-metadata.js.map +1 -1
  64. package/lib/cloudflare/worker.d.ts +2 -1
  65. package/lib/cloudflare/worker.d.ts.map +1 -1
  66. package/lib/cloudflare/worker.js +17 -8
  67. package/lib/cloudflare/worker.js.map +1 -1
  68. package/lib/cloudflare/workflow.d.ts +7 -0
  69. package/lib/cloudflare/workflow.d.ts.map +1 -1
  70. package/lib/cloudflare/workflow.js +2 -0
  71. package/lib/cloudflare/workflow.js.map +1 -1
  72. package/lib/cloudflare/wrangler.json.d.ts +1 -0
  73. package/lib/cloudflare/wrangler.json.d.ts.map +1 -1
  74. package/lib/cloudflare/wrangler.json.js +1 -0
  75. package/lib/cloudflare/wrangler.json.js.map +1 -1
  76. package/lib/destroy.js +1 -1
  77. package/lib/destroy.js.map +1 -1
  78. package/lib/dns/godaddy.d.ts.map +1 -1
  79. package/lib/dns/godaddy.js +2 -1
  80. package/lib/dns/godaddy.js.map +1 -1
  81. package/lib/fs/file-system-state-store.d.ts.map +1 -1
  82. package/lib/fs/file-system-state-store.js +14 -2
  83. package/lib/fs/file-system-state-store.js.map +1 -1
  84. package/lib/github/secret.d.ts.map +1 -1
  85. package/lib/github/secret.js +1 -0
  86. package/lib/github/secret.js.map +1 -1
  87. package/lib/neon/api.d.ts.map +1 -1
  88. package/lib/neon/api.js +2 -1
  89. package/lib/neon/api.js.map +1 -1
  90. package/lib/runtime/shims.d.ts +6 -0
  91. package/lib/runtime/shims.d.ts.map +1 -0
  92. package/lib/runtime/shims.js +27 -0
  93. package/lib/runtime/shims.js.map +1 -0
  94. package/lib/sentry/api.d.ts.map +1 -1
  95. package/lib/sentry/api.js +2 -1
  96. package/lib/sentry/api.js.map +1 -1
  97. package/lib/test/bun.d.ts.map +1 -1
  98. package/lib/test/bun.js +1 -7
  99. package/lib/test/bun.js.map +1 -1
  100. package/lib/test/prune.d.ts +2 -1
  101. package/lib/test/prune.d.ts.map +1 -1
  102. package/lib/test/prune.js +29 -5
  103. package/lib/test/prune.js.map +1 -1
  104. package/lib/test/vitest.d.ts +92 -0
  105. package/lib/test/vitest.d.ts.map +1 -0
  106. package/lib/test/vitest.js +94 -0
  107. package/lib/test/vitest.js.map +1 -0
  108. package/lib/upstash/api.d.ts.map +1 -1
  109. package/lib/upstash/api.js +2 -1
  110. package/lib/upstash/api.js.map +1 -1
  111. package/lib/util/retry.js +2 -2
  112. package/lib/util/retry.js.map +1 -1
  113. package/lib/util/safe-fetch.d.ts +2 -0
  114. package/lib/util/safe-fetch.d.ts.map +1 -0
  115. package/lib/util/safe-fetch.js +48 -0
  116. package/lib/util/safe-fetch.js.map +1 -0
  117. package/lib/vercel/api.d.ts.map +1 -1
  118. package/lib/vercel/api.js +2 -1
  119. package/lib/vercel/api.js.map +1 -1
  120. package/lib/web/vitepress/process-front-matter-files.d.ts.map +1 -1
  121. package/lib/web/vitepress/process-front-matter-files.js +11 -7
  122. package/lib/web/vitepress/process-front-matter-files.js.map +1 -1
  123. package/package.json +10 -6
  124. package/src/alchemy.ts +2 -2
  125. package/src/aws/bucket.ts +55 -36
  126. package/src/aws/control/client.ts +13 -13
  127. package/src/aws/control/resource.ts +19 -3
  128. package/src/aws/function.ts +233 -178
  129. package/src/aws/index.ts +1 -0
  130. package/src/aws/policy-attachment.ts +15 -10
  131. package/src/aws/policy.ts +75 -54
  132. package/src/aws/queue.ts +53 -36
  133. package/src/aws/retry.ts +38 -0
  134. package/src/aws/role.ts +121 -90
  135. package/src/aws/ses.ts +101 -73
  136. package/src/aws/ssm-parameter.ts +315 -0
  137. package/src/aws/table.ts +61 -90
  138. package/src/cloudflare/account-id.ts +2 -0
  139. package/src/cloudflare/api.ts +26 -3
  140. package/src/cloudflare/index.ts +2 -1
  141. package/src/cloudflare/queue.ts +2 -0
  142. package/src/cloudflare/route.ts +86 -2
  143. package/src/cloudflare/worker-metadata.ts +1 -2
  144. package/src/cloudflare/worker.ts +21 -9
  145. package/src/cloudflare/workflow.ts +8 -0
  146. package/src/cloudflare/wrangler.json.ts +8 -1
  147. package/src/destroy.ts +1 -1
  148. package/src/dns/godaddy.ts +3 -1
  149. package/src/fs/file-system-state-store.ts +16 -2
  150. package/src/github/secret.ts +2 -0
  151. package/src/neon/api.ts +2 -1
  152. package/src/sentry/api.ts +2 -1
  153. package/src/test/bun.ts +1 -7
  154. package/src/test/prune.ts +31 -4
  155. package/src/test/vitest.ts +209 -0
  156. package/src/upstash/api.ts +2 -1
  157. package/src/util/retry.ts +3 -3
  158. package/src/util/safe-fetch.ts +61 -0
  159. package/src/vercel/api.ts +2 -1
  160. package/src/web/vitepress/process-front-matter-files.ts +15 -7
@@ -0,0 +1,61 @@
1
+ import type { Agent } from "undici";
2
+
3
+ export async function safeFetch(
4
+ url: string | URL | Request,
5
+ options: RequestInit = {},
6
+ retries = 3,
7
+ ) {
8
+ let latestErr: any;
9
+ for (let attempt = 1; attempt <= retries; attempt++) {
10
+ try {
11
+ return await fetch(url, {
12
+ ...options,
13
+ // Type assertion to work around Cloudflare Workers type definitions
14
+ dispatcher: await dispatcher(),
15
+ } as RequestInit);
16
+ } catch (err: any) {
17
+ latestErr = err;
18
+ const shouldRetry =
19
+ err?.code === "UND_ERR_SOCKET" ||
20
+ err?.code === "ECONNRESET" ||
21
+ err?.name === "FetchError";
22
+
23
+ if (!shouldRetry || attempt === retries) {
24
+ throw err;
25
+ }
26
+
27
+ console.warn(`Retry ${attempt}/${retries} for ${url}: ${err.code}`);
28
+ await new Promise((r) => setTimeout(r, 250 * attempt)); // exponential backoff
29
+ }
30
+ }
31
+ throw latestErr;
32
+ }
33
+
34
+ let agent:
35
+ | {
36
+ value: Agent | undefined;
37
+ }
38
+ | undefined;
39
+
40
+ async function dispatcher() {
41
+ if (agent) {
42
+ return agent.value;
43
+ }
44
+ try {
45
+ // undici not available in all runtimes
46
+ const { Agent } = await import("undici");
47
+
48
+ if (!agent) {
49
+ // Configure agent with connection limits to avoid socket errors
50
+ agent = {
51
+ value: new Agent({
52
+ pipelining: 0, // Disable pipelining to avoid connection issues
53
+ // connections: 5, // Limit concurrent connections per host
54
+ }),
55
+ };
56
+ }
57
+ } catch {
58
+ agent = { value: undefined };
59
+ }
60
+ return agent.value;
61
+ }
package/src/vercel/api.ts CHANGED
@@ -1,5 +1,6 @@
1
1
  import { alchemy } from "../alchemy.ts";
2
2
  import type { Secret } from "../secret.ts";
3
+ import { safeFetch } from "../util/safe-fetch.ts";
3
4
 
4
5
  /**
5
6
  * Options for Vercel API requests
@@ -85,7 +86,7 @@ export class VercelApi {
85
86
  delete headers["Content-Type"];
86
87
  }
87
88
 
88
- const response = await fetch(`${this.baseUrl}${path}`, {
89
+ const response = await safeFetch(`${this.baseUrl}${path}`, {
89
90
  ...init,
90
91
  headers,
91
92
  });
@@ -1,5 +1,6 @@
1
1
  import fs from "node:fs/promises";
2
2
  import path from "node:path";
3
+ import { parse as parseYaml } from "yaml";
3
4
 
4
5
  /**
5
6
  * Process markdown files with frontmatter to generate navigation items
@@ -56,14 +57,21 @@ export async function processFrontmatterFiles(
56
57
  let title;
57
58
 
58
59
  if (frontmatterMatch) {
59
- const frontmatter = frontmatterMatch[1];
60
- const orderMatch = frontmatter.match(/order:\s*(\d+)/);
61
- if (orderMatch) {
62
- order = Number.parseFloat(orderMatch[1]);
60
+ const frontmatter = parseYaml(frontmatterMatch[1]);
61
+
62
+ // Parse order as a number (supports both integers and floats)
63
+ if (frontmatter.order !== undefined) {
64
+ if (typeof frontmatter.order !== "number") {
65
+ throw new Error(
66
+ `Invalid order field in ${fullPath}: expected number, got ${typeof frontmatter.order}`,
67
+ );
68
+ }
69
+ order = frontmatter.order;
63
70
  }
64
- const titleMatch = frontmatter.match(/title:\s*(.+)/);
65
- if (titleMatch) {
66
- title = titleMatch[1].trim();
71
+
72
+ // Get title from frontmatter
73
+ if (frontmatter.title) {
74
+ title = String(frontmatter.title).trim();
67
75
  }
68
76
  }
69
77