alchemy 0.48.0 → 0.48.2

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 (75) hide show
  1. package/bin/alchemy.mjs +63 -56
  2. package/lib/apply.js +1 -0
  3. package/lib/apply.js.map +1 -1
  4. package/lib/cloudflare/compatibility-date.gen.d.ts +5 -0
  5. package/lib/cloudflare/compatibility-date.gen.d.ts.map +1 -0
  6. package/lib/cloudflare/compatibility-date.gen.js +7 -0
  7. package/lib/cloudflare/compatibility-date.gen.js.map +1 -0
  8. package/lib/cloudflare/d1-migrations.d.ts.map +1 -1
  9. package/lib/cloudflare/d1-migrations.js +6 -11
  10. package/lib/cloudflare/d1-migrations.js.map +1 -1
  11. package/lib/cloudflare/index.d.ts +1 -0
  12. package/lib/cloudflare/index.d.ts.map +1 -1
  13. package/lib/cloudflare/index.js +1 -0
  14. package/lib/cloudflare/index.js.map +1 -1
  15. package/lib/cloudflare/miniflare/miniflare-worker-options.d.ts +2 -2
  16. package/lib/cloudflare/miniflare/miniflare-worker-options.d.ts.map +1 -1
  17. package/lib/cloudflare/miniflare/miniflare-worker-options.js +11 -2
  18. package/lib/cloudflare/miniflare/miniflare-worker-options.js.map +1 -1
  19. package/lib/cloudflare/miniflare/miniflare-worker-proxy.d.ts +20 -0
  20. package/lib/cloudflare/miniflare/miniflare-worker-proxy.d.ts.map +1 -0
  21. package/lib/cloudflare/miniflare/miniflare-worker-proxy.js +80 -0
  22. package/lib/cloudflare/miniflare/miniflare-worker-proxy.js.map +1 -0
  23. package/lib/cloudflare/miniflare/miniflare.d.ts +6 -6
  24. package/lib/cloudflare/miniflare/miniflare.d.ts.map +1 -1
  25. package/lib/cloudflare/miniflare/miniflare.js +25 -16
  26. package/lib/cloudflare/miniflare/miniflare.js.map +1 -1
  27. package/lib/cloudflare/miniflare/remote-binding-proxy.d.ts +10 -10
  28. package/lib/cloudflare/miniflare/remote-binding-proxy.d.ts.map +1 -1
  29. package/lib/cloudflare/miniflare/remote-binding-proxy.js +34 -44
  30. package/lib/cloudflare/miniflare/remote-binding-proxy.js.map +1 -1
  31. package/lib/cloudflare/oauth.js +3 -3
  32. package/lib/cloudflare/oauth.js.map +1 -1
  33. package/lib/cloudflare/website.d.ts.map +1 -1
  34. package/lib/cloudflare/website.js +2 -1
  35. package/lib/cloudflare/website.js.map +1 -1
  36. package/lib/cloudflare/worker.d.ts +1 -2
  37. package/lib/cloudflare/worker.d.ts.map +1 -1
  38. package/lib/cloudflare/worker.js +3 -10
  39. package/lib/cloudflare/worker.js.map +1 -1
  40. package/lib/scope.d.ts +6 -0
  41. package/lib/scope.d.ts.map +1 -1
  42. package/lib/scope.js +15 -1
  43. package/lib/scope.js.map +1 -1
  44. package/lib/state/cloudflare-state-store.d.ts.map +1 -1
  45. package/lib/state/cloudflare-state-store.js +2 -2
  46. package/lib/state/cloudflare-state-store.js.map +1 -1
  47. package/lib/util/http.d.ts +13 -0
  48. package/lib/util/http.d.ts.map +1 -0
  49. package/lib/util/http.js +78 -0
  50. package/lib/util/http.js.map +1 -0
  51. package/package.json +3 -3
  52. package/src/apply.ts +1 -0
  53. package/src/cloudflare/compatibility-date.gen.ts +7 -0
  54. package/src/cloudflare/d1-migrations.ts +8 -21
  55. package/src/cloudflare/index.ts +1 -0
  56. package/src/cloudflare/miniflare/miniflare-worker-options.ts +13 -1
  57. package/src/cloudflare/miniflare/miniflare-worker-proxy.ts +97 -0
  58. package/src/cloudflare/miniflare/miniflare.ts +30 -21
  59. package/src/cloudflare/miniflare/remote-binding-proxy.ts +40 -52
  60. package/src/cloudflare/oauth.ts +3 -3
  61. package/src/cloudflare/website.ts +2 -6
  62. package/src/cloudflare/worker.ts +5 -12
  63. package/src/scope.ts +17 -1
  64. package/src/state/cloudflare-state-store.ts +2 -2
  65. package/src/util/http.ts +94 -0
  66. package/lib/build-date.d.ts +0 -6
  67. package/lib/build-date.d.ts.map +0 -1
  68. package/lib/build-date.js +0 -8
  69. package/lib/build-date.js.map +0 -1
  70. package/lib/util/http-server.d.ts +0 -14
  71. package/lib/util/http-server.d.ts.map +0 -1
  72. package/lib/util/http-server.js +0 -71
  73. package/lib/util/http-server.js.map +0 -1
  74. package/src/build-date.ts +0 -8
  75. package/src/util/http-server.ts +0 -84
@@ -1,71 +0,0 @@
1
- import http from "node:http";
2
- import { Readable } from "node:stream";
3
- import { promiseWithResolvers } from "./promise-with-resolvers.js";
4
- export class HTTPServer {
5
- server;
6
- ready;
7
- constructor(options) {
8
- const { promise, resolve } = promiseWithResolvers();
9
- this.ready = promise;
10
- this.server = http
11
- .createServer(async (req, res) => {
12
- const response = await options.fetch(toWebRequest(req));
13
- await writeNodeResponse(res, response);
14
- })
15
- .listen(options.port, resolve);
16
- }
17
- get port() {
18
- return this.server.address().port;
19
- }
20
- get hostname() {
21
- const address = this.server.address()?.address;
22
- if (address === "::") {
23
- return "localhost";
24
- }
25
- return address;
26
- }
27
- get url() {
28
- return `http://${this.hostname}:${this.port}`;
29
- }
30
- stop() {
31
- return new Promise((resolve, reject) => {
32
- this.server.close((err) => {
33
- if (err) {
34
- reject(err);
35
- }
36
- else {
37
- resolve(undefined);
38
- }
39
- });
40
- });
41
- }
42
- }
43
- function toWebRequest(request) {
44
- const method = request.method ?? "GET";
45
- return new Request(`http://${request.headers.host}${request.url ?? "/"}`, {
46
- method,
47
- headers: request.headers,
48
- body: ["GET", "HEAD", "OPTIONS"].includes(method) || !request.readable
49
- ? undefined
50
- : Readable.toWeb(request),
51
- // TODO: why is Cloudflare's request type showing up here?
52
- // @ts-expect-error - `duplex` not present on Cloudflare Workers request type, but valid for Node
53
- duplex: "half",
54
- });
55
- }
56
- async function writeNodeResponse(res, response) {
57
- res.statusCode = response.status;
58
- response.headers.forEach((value, key) => {
59
- res.setHeader(key, value);
60
- });
61
- await response.body?.pipeTo(new WritableStream({
62
- write(chunk) {
63
- res.write(chunk);
64
- },
65
- close() {
66
- res.end();
67
- },
68
- }));
69
- res.end();
70
- }
71
- //# source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AC;QACnB,CAAC;QACD,KAAK;YACH,GAAG,CAAC,GAAG,EAAE,CAAC;QACZ,CAAC;KACF,CAAC,CACH,CAAC;IACF,GAAG,CAAC,GAAG,EAAE,CAAC;AACZ,CAAC"}
package/src/build-date.ts DELETED
@@ -1,8 +0,0 @@
1
- // This file is auto-generated during build
2
- // Do not edit manually
3
-
4
- /**
5
- * The build date used as the default worker compatibility date.
6
- * This is set to the date when the package was built.
7
- */
8
- export const BUILD_DATE = "2025-07-16";
@@ -1,84 +0,0 @@
1
- import http from "node:http";
2
- import type { AddressInfo } from "node:net";
3
- import { Readable } from "node:stream";
4
- import { promiseWithResolvers } from "./promise-with-resolvers.ts";
5
-
6
- export class HTTPServer {
7
- server: http.Server;
8
- ready: Promise<void>;
9
-
10
- constructor(options: {
11
- port?: number;
12
- fetch: (request: Request) => Promise<Response>;
13
- }) {
14
- const { promise, resolve } = promiseWithResolvers<void>();
15
- this.ready = promise;
16
- this.server = http
17
- .createServer(async (req, res) => {
18
- const response = await options.fetch(toWebRequest(req));
19
- await writeNodeResponse(res, response);
20
- })
21
- .listen(options.port, resolve);
22
- }
23
-
24
- get port() {
25
- return (this.server.address() as AddressInfo).port;
26
- }
27
-
28
- get hostname() {
29
- const address = (this.server.address() as AddressInfo)?.address;
30
- if (address === "::") {
31
- return "localhost";
32
- }
33
- return address;
34
- }
35
-
36
- get url() {
37
- return `http://${this.hostname}:${this.port}`;
38
- }
39
-
40
- stop() {
41
- return new Promise((resolve, reject) => {
42
- this.server.close((err) => {
43
- if (err) {
44
- reject(err);
45
- } else {
46
- resolve(undefined);
47
- }
48
- });
49
- });
50
- }
51
- }
52
-
53
- function toWebRequest(request: http.IncomingMessage): Request {
54
- const method = request.method ?? "GET";
55
- return new Request(`http://${request.headers.host}${request.url ?? "/"}`, {
56
- method,
57
- headers: request.headers as Record<string, string>,
58
- body:
59
- ["GET", "HEAD", "OPTIONS"].includes(method) || !request.readable
60
- ? undefined
61
- : (Readable.toWeb(request) as unknown as BodyInit),
62
- // TODO: why is Cloudflare's request type showing up here?
63
- // @ts-expect-error - `duplex` not present on Cloudflare Workers request type, but valid for Node
64
- duplex: "half",
65
- });
66
- }
67
-
68
- async function writeNodeResponse(res: http.ServerResponse, response: Response) {
69
- res.statusCode = response.status;
70
- response.headers.forEach((value, key) => {
71
- res.setHeader(key, value);
72
- });
73
- await response.body?.pipeTo(
74
- new WritableStream({
75
- write(chunk) {
76
- res.write(chunk);
77
- },
78
- close() {
79
- res.end();
80
- },
81
- }),
82
- );
83
- res.end();
84
- }