alchemy 0.68.0 → 0.69.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 (92) hide show
  1. package/bin/alchemy.js +19 -1
  2. package/lib/aws/control/properties.d.ts +64 -0
  3. package/lib/aws/control/properties.d.ts.map +1 -1
  4. package/lib/aws/control/properties.js +554 -39
  5. package/lib/aws/control/properties.js.map +1 -1
  6. package/lib/aws/control/resource.d.ts.map +1 -1
  7. package/lib/aws/control/resource.js +33 -0
  8. package/lib/aws/control/resource.js.map +1 -1
  9. package/lib/aws/control/types.d.ts +5451 -1587
  10. package/lib/aws/control/types.d.ts.map +1 -1
  11. package/lib/aws/control/types.js.map +1 -1
  12. package/lib/aws/control/update-types.d.ts +12913 -0
  13. package/lib/aws/control/update-types.d.ts.map +1 -0
  14. package/lib/aws/control/update-types.js +12916 -0
  15. package/lib/aws/control/update-types.js.map +1 -0
  16. package/lib/cloudflare/api.d.ts +1 -1
  17. package/lib/cloudflare/api.d.ts.map +1 -1
  18. package/lib/cloudflare/api.js +9 -10
  19. package/lib/cloudflare/api.js.map +1 -1
  20. package/lib/cloudflare/astro/astro.d.ts.map +1 -1
  21. package/lib/cloudflare/astro/astro.js +3 -3
  22. package/lib/cloudflare/astro/astro.js.map +1 -1
  23. package/lib/cloudflare/bucket-object.d.ts +81 -0
  24. package/lib/cloudflare/bucket-object.d.ts.map +1 -0
  25. package/lib/cloudflare/bucket-object.js +67 -0
  26. package/lib/cloudflare/bucket-object.js.map +1 -0
  27. package/lib/cloudflare/bucket.d.ts +30 -3
  28. package/lib/cloudflare/bucket.d.ts.map +1 -1
  29. package/lib/cloudflare/bucket.js +97 -13
  30. package/lib/cloudflare/bucket.js.map +1 -1
  31. package/lib/cloudflare/compatibility-date.gen.d.ts +1 -1
  32. package/lib/cloudflare/compatibility-date.gen.js +1 -1
  33. package/lib/cloudflare/container.d.ts.map +1 -1
  34. package/lib/cloudflare/container.js +1 -1
  35. package/lib/cloudflare/container.js.map +1 -1
  36. package/lib/cloudflare/index.d.ts +1 -0
  37. package/lib/cloudflare/index.d.ts.map +1 -1
  38. package/lib/cloudflare/index.js +1 -0
  39. package/lib/cloudflare/index.js.map +1 -1
  40. package/lib/cloudflare/next.js.map +1 -1
  41. package/lib/cloudflare/nuxt/nuxt.d.ts.map +1 -1
  42. package/lib/cloudflare/nuxt/nuxt.js +3 -3
  43. package/lib/cloudflare/nuxt/nuxt.js.map +1 -1
  44. package/lib/cloudflare/vite/vite.d.ts.map +1 -1
  45. package/lib/cloudflare/vite/vite.js +3 -3
  46. package/lib/cloudflare/vite/vite.js.map +1 -1
  47. package/lib/cloudflare/website.d.ts +7 -1
  48. package/lib/cloudflare/website.d.ts.map +1 -1
  49. package/lib/cloudflare/website.js +19 -1
  50. package/lib/cloudflare/website.js.map +1 -1
  51. package/lib/cloudflare/wrangler.json.d.ts +27 -8
  52. package/lib/cloudflare/wrangler.json.d.ts.map +1 -1
  53. package/lib/cloudflare/wrangler.json.js +3 -1
  54. package/lib/cloudflare/wrangler.json.js.map +1 -1
  55. package/lib/llms.cloudflare.txt +2 -2
  56. package/lib/neon/branch.d.ts +19 -3
  57. package/lib/neon/branch.d.ts.map +1 -1
  58. package/lib/neon/branch.js +4 -4
  59. package/lib/neon/branch.js.map +1 -1
  60. package/lib/neon/project.d.ts +17 -1
  61. package/lib/neon/project.d.ts.map +1 -1
  62. package/lib/neon/project.js +4 -4
  63. package/lib/neon/project.js.map +1 -1
  64. package/lib/serde.d.ts +3 -0
  65. package/lib/serde.d.ts.map +1 -1
  66. package/lib/serde.js +40 -0
  67. package/lib/serde.js.map +1 -1
  68. package/lib/test/bun.js.map +1 -1
  69. package/package.json +1 -1
  70. package/src/aws/control/properties.ts +554 -39
  71. package/src/aws/control/resource.ts +58 -0
  72. package/src/aws/control/types.ts +85281 -84914
  73. package/src/aws/control/update-types.ts +12917 -0
  74. package/src/cloudflare/api.ts +9 -10
  75. package/src/cloudflare/astro/astro.ts +8 -3
  76. package/src/cloudflare/bucket-object.ts +117 -0
  77. package/src/cloudflare/bucket.ts +148 -14
  78. package/src/cloudflare/compatibility-date.gen.ts +1 -1
  79. package/src/cloudflare/container.ts +2 -3
  80. package/src/cloudflare/index.ts +1 -0
  81. package/src/cloudflare/next.ts +2 -2
  82. package/src/cloudflare/nuxt/nuxt.ts +8 -3
  83. package/src/cloudflare/vite/vite.ts +8 -3
  84. package/src/cloudflare/website.ts +28 -2
  85. package/src/cloudflare/wrangler.json.ts +32 -17
  86. package/src/llms.cloudflare.txt +2 -2
  87. package/src/neon/branch.ts +6 -5
  88. package/src/neon/project.ts +4 -4
  89. package/src/serde.ts +50 -0
  90. package/src/test/bun.ts +1 -1
  91. package/templates/rwsdk/.cursor/rules/alchemy_cloudflare.mdc +2 -2
  92. package/workers/tunnel-proxy.js +1 -1
@@ -350,14 +350,7 @@ export interface WranglerJsonSpec {
350
350
  */
351
351
  queues?: {
352
352
  producers?: { queue: string; binding: string }[];
353
- consumers?: {
354
- queue: string;
355
- max_batch_size?: number;
356
- max_concurrency?: number;
357
- max_retries?: number;
358
- max_wait_time_ms?: number;
359
- retry_delay?: number;
360
- }[];
353
+ consumers?: QueueConsumerWranglerJson[];
361
354
  };
362
355
 
363
356
  /**
@@ -500,6 +493,33 @@ export interface WranglerJsonSpec {
500
493
  };
501
494
  }
502
495
 
496
+ /**
497
+ * Queue consumer bindings for wrangler.json
498
+ */
499
+ interface QueueConsumerWranglerJson {
500
+ queue: string;
501
+ /**
502
+ * The maximum number of messages allowed in each batch.
503
+ */
504
+ max_batch_size?: number;
505
+ /**
506
+ * The maximum number of concurrent consumers allowed to run at once. Leaving this unset will mean that the number of invocations will scale to the currently supported maximum.
507
+ */
508
+ max_concurrency?: number;
509
+ /**
510
+ * The maximum number of retries for a message, if it fails or `retryAll()` is invoked.
511
+ */
512
+ max_retries?: number;
513
+ /**
514
+ * The maximum number of seconds to wait for messages to fill a batch before the batch is sent to the consumer Worker.
515
+ */
516
+ max_batch_timeout?: number;
517
+ /**
518
+ * The number of seconds to delay retried messages for by default, before they are re-delivered to the consumer. This can be overridden on a per-message or per-batch basis when retrying messages.
519
+ */
520
+ retry_delay?: number;
521
+ }
522
+
503
523
  /**
504
524
  * Process worker bindings into wrangler.json format
505
525
  */
@@ -554,14 +574,7 @@ function processBindings(
554
574
  }[] = [];
555
575
  const queues: {
556
576
  producers: { queue: string; binding: string }[];
557
- consumers: {
558
- queue: string;
559
- max_batch_size?: number;
560
- max_concurrency?: number;
561
- max_retries?: number;
562
- max_wait_time_ms?: number;
563
- retry_delay?: number;
564
- }[];
577
+ consumers: QueueConsumerWranglerJson[];
565
578
  } = {
566
579
  producers: [],
567
580
  consumers: [],
@@ -604,7 +617,9 @@ function processBindings(
604
617
  max_batch_size: eventSource.settings?.batchSize,
605
618
  max_concurrency: eventSource.settings?.maxConcurrency,
606
619
  max_retries: eventSource.settings?.maxRetries,
607
- max_wait_time_ms: eventSource.settings?.maxWaitTimeMs,
620
+ max_batch_timeout: eventSource.settings?.maxWaitTimeMs
621
+ ? eventSource.settings?.maxWaitTimeMs / 1000
622
+ : undefined,
608
623
  retry_delay: eventSource.settings?.retryDelay,
609
624
  });
610
625
  } else if (isQueue(eventSource)) {
@@ -301,7 +301,7 @@ const app = await alchemy("my-app", {
301
301
  ### Framework Integration (Vite/React/etc.)
302
302
  ```typescript
303
303
  const website = await Vite("website", {
304
- main: "./src/worker.ts",
304
+ entrypoint: "./src/worker.ts",
305
305
  command: "bun run build", // Build command
306
306
  bindings: {
307
307
  API: await Worker("api", { entrypoint: "./api/worker.ts" }),
@@ -319,7 +319,7 @@ await alchemy.run("backend", async () => {
319
319
  });
320
320
 
321
321
  await alchemy.run("frontend", async () => {
322
- await Vite("website", { main: "./src/worker.ts" });
322
+ await Vite("website", { entrypoint: "./src/worker.ts" });
323
323
  });
324
324
  ```
325
325
 
@@ -76,7 +76,7 @@ export interface NeonBranchProps extends NeonApiOptions {
76
76
  endpoints: neon.BranchCreateRequestEndpointOptions[];
77
77
  }
78
78
 
79
- export interface NeonBranch extends Resource<"neon::Branch"> {
79
+ export interface NeonBranch {
80
80
  /**
81
81
  * The branch ID. This value is generated when a branch is created. A branch_id value has a br- prefix. For example: br-small-term-683261.
82
82
  */
@@ -215,7 +215,7 @@ export const NeonBranch = Resource(
215
215
  ),
216
216
  );
217
217
 
218
- return this({
218
+ return {
219
219
  id: data.branch.id,
220
220
  name: data.branch.name,
221
221
  projectId: data.branch.project_id,
@@ -237,7 +237,7 @@ export const NeonBranch = Resource(
237
237
  databases: data.databases,
238
238
  roles: data.roles.map(formatRole),
239
239
  connectionUris: data.connection_uris?.map(formatConnectionUri) ?? [],
240
- });
240
+ };
241
241
  }
242
242
  case "update": {
243
243
  if (
@@ -263,7 +263,8 @@ export const NeonBranch = Resource(
263
263
  },
264
264
  },
265
265
  });
266
- return this({
266
+
267
+ return {
267
268
  ...this.output,
268
269
  name,
269
270
  protected: data.branch.protected,
@@ -271,7 +272,7 @@ export const NeonBranch = Resource(
271
272
  expiresAt: data.branch.expires_at
272
273
  ? new Date(data.branch.expires_at)
273
274
  : undefined,
274
- });
275
+ };
275
276
  }
276
277
  }
277
278
  },
@@ -229,7 +229,7 @@ export const NeonProject = Resource(
229
229
  .then((res) => res.data.endpoints),
230
230
  ]);
231
231
 
232
- return this({
232
+ return {
233
233
  id: data.project.id,
234
234
  name: data.project.name,
235
235
  created_at: data.project.created_at,
@@ -248,7 +248,7 @@ export const NeonProject = Resource(
248
248
  databases: data.databases as [neon.Database, ...neon.Database[]],
249
249
  branch,
250
250
  endpoints: endpoints as [neon.Endpoint, ...neon.Endpoint[]],
251
- });
251
+ };
252
252
  }
253
253
  case "update": {
254
254
  const { data } = await api.updateProject({
@@ -264,7 +264,7 @@ export const NeonProject = Resource(
264
264
  },
265
265
  },
266
266
  });
267
- return this({
267
+ return {
268
268
  ...this.output,
269
269
  name: data.project.name,
270
270
  updated_at: data.project.updated_at,
@@ -274,7 +274,7 @@ export const NeonProject = Resource(
274
274
  settings: data.project.settings,
275
275
  default_endpoint_settings: data.project.default_endpoint_settings,
276
276
  history_retention_seconds: data.project.history_retention_seconds,
277
- });
277
+ };
278
278
  }
279
279
  case "delete": {
280
280
  if (this.output?.id) {
package/src/serde.ts CHANGED
@@ -119,6 +119,10 @@ export async function serialize(
119
119
  .filter((prop) => prop === "env")
120
120
  .map((prop) => [prop, (value as any)[prop]]),
121
121
  );
122
+ } else if (isBinary(value)) {
123
+ return {
124
+ "@buffer": await serializeBinary(value),
125
+ };
122
126
  } else if (value && typeof value === "object") {
123
127
  for (const symbol of Object.getOwnPropertySymbols(value)) {
124
128
  assertNotUniqueSymbol(symbol);
@@ -195,6 +199,8 @@ export async function deserialize(
195
199
  return parseSymbol(value["@symbol"]);
196
200
  } else if ("@scope" in value) {
197
201
  return scope;
202
+ } else if ("@buffer" in value) {
203
+ return Buffer.from(value["@buffer"], "base64");
198
204
  }
199
205
 
200
206
  return Object.fromEntries(
@@ -227,3 +233,47 @@ function assertNotUniqueSymbol(symbol: Symbol) {
227
233
  throw new Error(`Cannot serialize unique symbol: ${symbol.description}`);
228
234
  }
229
235
  }
236
+
237
+ export const isBinary = (
238
+ value: any,
239
+ ): value is Buffer | Uint8Array | ArrayBuffer | Blob | ReadableStream => {
240
+ return (
241
+ value instanceof Buffer ||
242
+ value instanceof Uint8Array ||
243
+ value instanceof ArrayBuffer ||
244
+ value instanceof Blob ||
245
+ value instanceof ReadableStream ||
246
+ ArrayBuffer.isView(value)
247
+ );
248
+ };
249
+
250
+ export const serializeBinary = async (
251
+ value: Buffer | Uint8Array | ArrayBuffer | Blob | ReadableStream,
252
+ ): Promise<string> => {
253
+ return value instanceof Buffer
254
+ ? value.toString("base64")
255
+ : value instanceof Uint8Array
256
+ ? value.toString("base64")
257
+ : value instanceof ArrayBuffer
258
+ ? serializeBinary(Buffer.from(value))
259
+ : value instanceof Blob
260
+ ? serializeBinary(await value.arrayBuffer())
261
+ : value instanceof ReadableStream
262
+ ? serializeBinary(await streamToBuffer(value))
263
+ : value;
264
+ };
265
+
266
+ export async function streamToBuffer(
267
+ stream: ReadableStream<Uint8Array>,
268
+ ): Promise<Buffer> {
269
+ const reader = stream.getReader();
270
+ const chunks: Uint8Array[] = [];
271
+
272
+ while (true) {
273
+ const { done, value } = await reader.read();
274
+ if (done) break;
275
+ chunks.push(value);
276
+ }
277
+
278
+ return Buffer.concat(chunks);
279
+ }
package/src/test/bun.ts CHANGED
@@ -115,7 +115,7 @@ export function test(meta: ImportMeta, defaultOptions?: TestOptions): test {
115
115
  return afterAll(() => scope.run(() => fn(scope)));
116
116
  };
117
117
 
118
- return test as test;
118
+ return test as any;
119
119
 
120
120
  function test(
121
121
  ...args:
@@ -306,7 +306,7 @@ const app = await alchemy("my-app", {
306
306
  ### Framework Integration (Vite/React/etc.)
307
307
  ```typescript
308
308
  const website = await Vite("website", {
309
- main: "./src/worker.ts",
309
+ entrypoint: "./src/worker.ts",
310
310
  command: "bun run build", // Build command
311
311
  bindings: {
312
312
  API: await Worker("api", { entrypoint: "./api/worker.ts" }),
@@ -324,7 +324,7 @@ await alchemy.run("backend", async () => {
324
324
  });
325
325
 
326
326
  await alchemy.run("frontend", async () => {
327
- await Vite("website", { main: "./src/worker.ts" });
327
+ await Vite("website", { entrypoint: "./src/worker.ts" });
328
328
  });
329
329
  ```
330
330
 
@@ -34,7 +34,7 @@ var h={async fetch(e,r){let n=new URL(e.url);n.host=r.TUNNEL_HOST;let l=new Head
34
34
  Alchemy</a>.</p>
35
35
  </div>
36
36
  <div class="bg-slate-200 px-5 py-3 flex flex-col w-full max-w-lg">
37
- <p class="text-sm text-slate-500">Alchemy 0.68.0</p>
37
+ <p class="text-sm text-slate-500">Alchemy 0.69.0</p>
38
38
  </div>
39
39
  </div>
40
40
  </body>