alchemy 2.0.0-beta.4 → 2.0.0-beta.test-export-fix-4

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.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "alchemy",
3
- "version": "2.0.0-beta.4",
3
+ "version": "2.0.0-beta.test-export-fix-4",
4
4
  "homepage": "https://alchemy.run",
5
5
  "license": "Apache-2.0",
6
6
  "author": "Sam Goodwin <sam@alchemy.run>",
@@ -201,16 +201,15 @@
201
201
  "access": "public"
202
202
  },
203
203
  "dependencies": {
204
- "@clack/prompts": "^0.11.0",
205
204
  "@ai-sdk/anthropic": "^3.0.31",
206
205
  "@ai-sdk/openai": "^3.0.23",
207
206
  "@ai-sdk/provider": "^3.0.8",
208
207
  "@aws-sdk/credential-providers": "^3.0.0",
209
- "@distilled.cloud/aws": "^0.10.2",
210
- "@distilled.cloud/cloudflare": "^0.10.2",
208
+ "@distilled.cloud/aws": "^0.10.0",
209
+ "@distilled.cloud/cloudflare": "^0.10.0",
211
210
  "@distilled.cloud/cloudflare-rolldown-plugin": "0.3.0",
212
211
  "@distilled.cloud/cloudflare-vite-plugin": "0.2.0",
213
- "@distilled.cloud/core": "^0.10.2",
212
+ "@distilled.cloud/core": "^0.10.0",
214
213
  "@effect/vitest": "4.0.0-beta.48",
215
214
  "@libsql/client": "^0.17.0",
216
215
  "@octokit/rest": "^22.0.1",
@@ -9,10 +9,10 @@ import type { ScopedPlanStatusSession } from "../../Cli/Cli.ts";
9
9
  import { isResolved } from "../../Diff.ts";
10
10
  import * as Provider from "../../Provider.ts";
11
11
  import { Resource } from "../../Resource.ts";
12
+ import type { Providers } from "../Providers.ts";
12
13
  import { createInternalTags, createTagsList, diffTags } from "../../Tags.ts";
13
14
  import type { AccountID } from "../Account.ts";
14
15
  import { Account } from "../Account.ts";
15
- import type { Providers } from "../Providers.ts";
16
16
  import type { RegionID } from "../Region.ts";
17
17
  import type { RouteTableId } from "./RouteTable.ts";
18
18
  import type { SecurityGroupId } from "./SecurityGroup.ts";
@@ -595,11 +595,11 @@ const waitForVpcEndpointAvailable = (
595
595
  return yield* new VpcEndpointNotFound({ vpcEndpointId });
596
596
  }
597
597
 
598
- if (ep.State === "available") {
598
+ if (ep.State === "Available") {
599
599
  return ep;
600
600
  }
601
601
 
602
- if (ep.State === "failed" || ep.State === "rejected") {
602
+ if (ep.State === "Failed" || ep.State === "Rejected") {
603
603
  return yield* new VpcEndpointFailed({
604
604
  vpcEndpointId,
605
605
  errorCode: ep.LastError?.Code,
@@ -641,7 +641,7 @@ const waitForVpcEndpointDeleted = (
641
641
 
642
642
  const ep = result.VpcEndpoints?.[0];
643
643
 
644
- if (!ep || ep.State === "deleted") {
644
+ if (!ep || ep.State === "Deleted") {
645
645
  return; // Successfully deleted
646
646
  }
647
647
 
@@ -83,41 +83,28 @@ export type StaticSite = ReturnType<typeof StaticSite>;
83
83
  * });
84
84
  * ```
85
85
  */
86
- export const StaticSite = <
87
- const Bindings extends WorkerBindingProps = {},
88
- Req = never,
89
- >(
86
+ export const StaticSite = <const Bindings extends WorkerBindingProps = {}>(
90
87
  id: string,
91
- propsEff:
92
- | InputProps<StaticSiteProps<Bindings>>
93
- | Effect.Effect<InputProps<StaticSiteProps<Bindings>>, never, Req>,
88
+ props: InputProps<StaticSiteProps<Bindings>>,
94
89
  ) =>
95
90
  Effect.gen(function* () {
96
- const props = Effect.isEffect(propsEff)
97
- ? propsEff
98
- : Effect.succeed(propsEff);
99
-
100
91
  // TODO(sam): local dev/hmr support?
101
- const build = yield* Command(
102
- "Build",
103
- Effect.map(props, (props) => ({
104
- command: props.command,
105
- cwd: props.cwd,
106
- memo: props.memo,
107
- outdir: props.outdir,
108
- env: props.env,
109
- })),
110
- );
92
+ const build = yield* Command("Build", {
93
+ command: props.command,
94
+ cwd: props.cwd,
95
+ memo: props.memo,
96
+ outdir: props.outdir,
97
+ env: props.env,
98
+ });
99
+
100
+ const worker = yield* Worker<Bindings, WorkerAssetsConfig>("Worker", {
101
+ ...props,
102
+ assets: {
103
+ path: build.outdir,
104
+ hash: build.hash,
105
+ config: props.assetsConfig,
106
+ },
107
+ });
111
108
 
112
- return yield* Worker<Bindings, WorkerAssetsConfig, Req>(
113
- "Worker",
114
- Effect.map(props, (props) => ({
115
- ...props,
116
- assets: {
117
- path: build.outdir,
118
- hash: build.hash,
119
- config: props.assetsConfig,
120
- },
121
- })),
122
- );
109
+ return worker;
123
110
  }).pipe(Namespace.push(id));
@@ -1,4 +1,3 @@
1
- import * as Effect from "effect/Effect";
2
1
  import type { MemoOptions } from "../../Build/Memo.ts";
3
2
  import type { InputProps } from "../../Input.ts";
4
3
  import {
@@ -107,26 +106,15 @@ export interface ViteProps<
107
106
  * });
108
107
  * ```
109
108
  */
110
- export const Vite = <
111
- const Bindings extends WorkerBindingProps = {},
112
- Req = never,
113
- >(
109
+ export const Vite = <const Bindings extends WorkerBindingProps = {}>(
114
110
  id: string,
115
- propsEff?:
116
- | InputProps<ViteProps<Bindings>>
117
- | Effect.Effect<InputProps<ViteProps<Bindings>>, never, Req>,
111
+ props: InputProps<ViteProps<Bindings>> = {},
118
112
  ) =>
119
- Worker<Bindings, WorkerAssetsConfig, Req>(
120
- id,
121
- Effect.map(
122
- Effect.isEffect(propsEff) ? propsEff : Effect.succeed(propsEff),
123
- (props) => ({
124
- ...props,
125
- main: undefined!,
126
- vite: {
127
- rootDir: props?.rootDir,
128
- memo: props?.memo,
129
- },
130
- }),
131
- ),
132
- );
113
+ Worker<Bindings, WorkerAssetsConfig>(id, {
114
+ ...props,
115
+ main: undefined!,
116
+ vite: {
117
+ rootDir: props.rootDir,
118
+ memo: props.memo,
119
+ },
120
+ });
@@ -2,7 +2,6 @@ import type * as cf from "@cloudflare/workers-types";
2
2
  import cloudflareRolldown from "@distilled.cloud/cloudflare-rolldown-plugin";
3
3
  import cloudflareVite from "@distilled.cloud/cloudflare-vite-plugin";
4
4
  import * as workers from "@distilled.cloud/cloudflare/workers";
5
- import * as zones from "@distilled.cloud/cloudflare/zones";
6
5
  import type * as Cause from "effect/Cause";
7
6
  import * as Context from "effect/Context";
8
7
  import * as Data from "effect/Data";
@@ -248,12 +247,6 @@ export interface WorkerProps<
248
247
  env?: Record<string, string | Redacted.Redacted<string>>;
249
248
  exports?: string[];
250
249
  bindings?: Bindings;
251
- /**
252
- * One or more custom hostnames (e.g. `"app.example.com"`) to bind to this
253
- * Worker. The Cloudflare Zone is inferred from the hostname — the zone must
254
- * already exist in the account.
255
- */
256
- domain?: string | string[];
257
250
  build?: {
258
251
  /**
259
252
  * Whether to generate a metafile for the worker bundle.
@@ -274,7 +267,6 @@ export type Worker<Bindings extends WorkerBindings = any> = Resource<
274
267
  tags: string[] | undefined;
275
268
  durableObjectNamespaces: Record<string, string>;
276
269
  accountId: string;
277
- domains: { hostname: string; id: string; zoneId: string }[];
278
270
  hash?: {
279
271
  assets: string | undefined;
280
272
  bundle: string | undefined;
@@ -622,21 +614,16 @@ export const Worker: Platform<
622
614
  <
623
615
  const Bindings extends WorkerBindingProps,
624
616
  const Assets extends WorkerAssetsConfig | undefined = undefined,
625
- Req = never,
626
617
  >(
627
618
  id: string,
628
- props:
629
- | InputProps<WorkerProps<Bindings, Assets>>
630
- | Effect.Effect<InputProps<WorkerProps<Bindings, Assets>>, never, Req>,
619
+ props: InputProps<WorkerProps<Bindings, Assets>>,
631
620
  ): Effect.Effect<
632
621
  Worker<{
633
622
  [binding in keyof NormalizedBindings<
634
623
  Bindings,
635
624
  Assets
636
625
  >]: NormalizedBindings<Bindings, Assets>[binding];
637
- }>,
638
- never,
639
- Req | Providers
626
+ }>
640
627
  >;
641
628
  } = Platform(WorkerTypeId, {
642
629
  onCreate: Effect.fnUntraced(function* (
@@ -925,10 +912,6 @@ export const WorkerProvider = () =>
925
912
  const getSubdomain = yield* workers.getSubdomain;
926
913
  const listScripts = yield* workers.listScripts;
927
914
  const putScript = yield* workers.putScript;
928
- const putDomain = yield* workers.putDomain;
929
- const listDomains = yield* workers.listDomains;
930
- const deleteDomain = yield* workers.deleteDomain;
931
- const listZones = yield* zones.listZones;
932
915
  const telemetry = yield* CloudflareLogs;
933
916
  const defaultCompatibilityDate = yield* Effect.promise(() =>
934
917
  // @ts-expect-error no types for workerd
@@ -955,95 +938,6 @@ export const WorkerProvider = () =>
955
938
  maxLength: 54,
956
939
  }).pipe(Effect.map((name) => name.toLowerCase()));
957
940
 
958
- const normalizeDomains = (
959
- domain: string | string[] | undefined,
960
- ): string[] =>
961
- domain === undefined
962
- ? []
963
- : Array.isArray(domain)
964
- ? Array.from(new Set(domain))
965
- : [domain];
966
-
967
- /**
968
- * Infer the Cloudflare Zone ID for a given hostname by listing the
969
- * account's zones and matching the hostname against each zone's name —
970
- * walking up the DNS label hierarchy until a match is found.
971
- */
972
- const inferZoneIdForHostname = (
973
- hostname: string,
974
- zoneCache: Map<string, string>,
975
- ) =>
976
- Effect.gen(function* () {
977
- const cached = zoneCache.get(hostname);
978
- if (cached) return cached;
979
-
980
- const zoneList = yield* listZones({}).pipe(
981
- Effect.map((response) => response.result ?? []),
982
- );
983
- for (const zone of zoneList) {
984
- zoneCache.set(zone.name, zone.id);
985
- }
986
-
987
- const parts = hostname.split(".");
988
- for (let i = 0; i < parts.length - 1; i++) {
989
- const candidate = parts.slice(i).join(".");
990
- const match = zoneList.find((z) => z.name === candidate);
991
- if (match) {
992
- zoneCache.set(hostname, match.id);
993
- return match.id;
994
- }
995
- }
996
- return yield* Effect.die(
997
- `Could not infer Cloudflare Zone for hostname "${hostname}". ` +
998
- "Ensure the parent zone exists in this account.",
999
- );
1000
- });
1001
-
1002
- const reconcileDomains = (
1003
- scriptName: string,
1004
- desired: string[],
1005
- previous: Worker["Attributes"]["domains"],
1006
- ) =>
1007
- Effect.gen(function* () {
1008
- const desiredSet = new Set(desired);
1009
- const toRemove = previous.filter((p) => !desiredSet.has(p.hostname));
1010
- yield* Effect.all(
1011
- toRemove.map((d) =>
1012
- deleteDomain({ accountId, domainId: d.id }).pipe(
1013
- Effect.catchTag("DomainNotFound", () => Effect.void),
1014
- ),
1015
- ),
1016
- { concurrency: "unbounded" },
1017
- );
1018
-
1019
- if (desired.length === 0) return [];
1020
-
1021
- const zoneCache = new Map<string, string>();
1022
- const applied = yield* Effect.all(
1023
- desired.map((hostname) =>
1024
- Effect.gen(function* () {
1025
- const zoneId = yield* inferZoneIdForHostname(
1026
- hostname,
1027
- zoneCache,
1028
- );
1029
- const res = yield* putDomain({
1030
- accountId,
1031
- hostname,
1032
- service: scriptName,
1033
- zoneId,
1034
- });
1035
- return {
1036
- hostname,
1037
- id: res.id ?? "",
1038
- zoneId: res.zoneId ?? zoneId,
1039
- };
1040
- }),
1041
- ),
1042
- { concurrency: "unbounded" },
1043
- );
1044
- return applied;
1045
- });
1046
-
1047
941
  const createAlchemyWorkerTags = (id: string) => [
1048
942
  `alchemy:stack:${stack.name}`,
1049
943
  `alchemy:stage:${stack.stage}`,
@@ -1744,18 +1638,6 @@ ${[
1744
1638
  );
1745
1639
  yield* setWorkerSubdomain(name, enable);
1746
1640
  }
1747
- const desiredDomains = normalizeDomains(news.domain);
1748
- const previousDomains = output?.domains ?? [];
1749
- if (desiredDomains.length > 0 || previousDomains.length > 0) {
1750
- yield* session.note(
1751
- `Reconciling custom domains (${desiredDomains.length}) ...`,
1752
- );
1753
- }
1754
- const domains = yield* reconcileDomains(
1755
- name,
1756
- desiredDomains,
1757
- previousDomains,
1758
- );
1759
1641
  return {
1760
1642
  workerId: worker.id ?? name,
1761
1643
  workerName: name,
@@ -1767,7 +1649,6 @@ ${[
1767
1649
  tags: settings.tags ?? metadata.tags,
1768
1650
  durableObjectNamespaces,
1769
1651
  accountId,
1770
- domains,
1771
1652
  hash,
1772
1653
  } satisfies Worker["Attributes"];
1773
1654
  });
@@ -1813,14 +1694,7 @@ ${[
1813
1694
  if (!output) {
1814
1695
  return;
1815
1696
  }
1816
- const newDomains = normalizeDomains(news.domain).sort();
1817
- const oldDomains = (output?.domains ?? [])
1818
- .map((d) => d.hostname)
1819
- .sort();
1820
- const domainsChanged =
1821
- newDomains.length !== oldDomains.length ||
1822
- newDomains.some((d, i) => d !== oldDomains[i]);
1823
- if (domainsChanged || (yield* hasChanged(id, news, output))) {
1697
+ if (yield* hasChanged(id, news, output)) {
1824
1698
  return {
1825
1699
  action: "update",
1826
1700
  stables:
@@ -1949,7 +1823,6 @@ ${[
1949
1823
  tags: existingSettings?.tags ?? tags,
1950
1824
  durableObjectNamespaces,
1951
1825
  accountId,
1952
- domains: [],
1953
1826
  } satisfies Worker["Attributes"];
1954
1827
  }),
1955
1828
  read: Effect.fnUntraced(
@@ -1959,28 +1832,23 @@ ${[
1959
1832
  yield* Effect.logInfo(
1960
1833
  `Cloudflare Worker read: checking ${workerName}`,
1961
1834
  );
1962
- const [worker, subdomain, settings, domainsList] =
1963
- yield* Effect.all([
1964
- listScripts({
1965
- accountId,
1966
- }).pipe(
1967
- Effect.map((workers) =>
1968
- workers.result.find((worker) => worker.id === workerName),
1969
- ),
1835
+ const [worker, subdomain, settings] = yield* Effect.all([
1836
+ listScripts({
1837
+ accountId,
1838
+ }).pipe(
1839
+ Effect.map((workers) =>
1840
+ workers.result.find((worker) => worker.id === workerName),
1970
1841
  ),
1971
- getScriptSubdomain({
1972
- accountId,
1973
- scriptName: workerName,
1974
- }),
1975
- getScriptSettings({
1976
- accountId,
1977
- scriptName: workerName,
1978
- }),
1979
- listDomains({
1980
- accountId,
1981
- service: workerName,
1982
- }).pipe(Effect.map((r) => r.result ?? [])),
1983
- ]);
1842
+ ),
1843
+ getScriptSubdomain({
1844
+ accountId,
1845
+ scriptName: workerName,
1846
+ }),
1847
+ getScriptSettings({
1848
+ accountId,
1849
+ scriptName: workerName,
1850
+ }),
1851
+ ]);
1984
1852
  if (!worker) {
1985
1853
  yield* Effect.logInfo(
1986
1854
  `Cloudflare Worker read: ${workerName} not found in script list`,
@@ -2002,11 +1870,6 @@ ${[
2002
1870
  durableObjectNamespaces: getDurableObjectNamespaces(
2003
1871
  settings.bindings,
2004
1872
  ),
2005
- domains: domainsList.flatMap((d) =>
2006
- d.id && d.hostname && d.zoneId
2007
- ? [{ id: d.id, hostname: d.hostname, zoneId: d.zoneId }]
2008
- : [],
2009
- ),
2010
1873
  } satisfies Worker["Attributes"];
2011
1874
  },
2012
1875
  (effect) =>
@@ -2108,17 +1971,6 @@ ${[
2108
1971
  yield* Effect.logInfo(
2109
1972
  `Cloudflare Worker delete: deleting ${output.workerName}`,
2110
1973
  );
2111
- if (output.domains?.length) {
2112
- yield* Effect.all(
2113
- output.domains.map((d) =>
2114
- deleteDomain({
2115
- accountId: output.accountId,
2116
- domainId: d.id,
2117
- }).pipe(Effect.catchTag("DomainNotFound", () => Effect.void)),
2118
- ),
2119
- { concurrency: "unbounded" },
2120
- );
2121
- }
2122
1974
  yield* deleteScript({
2123
1975
  accountId: output.accountId,
2124
1976
  scriptName: output.workerName,
package/src/Platform.ts CHANGED
@@ -220,15 +220,10 @@ export const Platform = <
220
220
  // return new Response("Hello, world!");
221
221
  // }
222
222
  // }
223
- resource(
224
- id,
225
- Effect.isEffect(props)
226
- ? Effect.map(props, (p: any) => ({ ...p, isExternal: true }))
227
- : {
228
- ...props,
229
- isExternal: true,
230
- },
231
- )
223
+ resource(id, {
224
+ ...props,
225
+ isExternal: true,
226
+ })
232
227
  : Effect.flatMap(
233
228
  // this is a tagged resource
234
229
  Effect.serviceOption(cls.Self),
package/src/Resource.ts CHANGED
@@ -31,10 +31,10 @@ export type ResourceConstructor<R extends ResourceLike, Req = never> = {
31
31
  },
32
32
  ]
33
33
  ): Effect.Effect<R, never, Req>;
34
- <PropsReq = never>(
35
- id: string,
36
- props: Effect.Effect<Input<R["Props"]>, never, PropsReq>,
37
- ): Effect.Effect<R, never, PropsReq | Req>;
34
+ // <PropsReq = never>(
35
+ // id: string,
36
+ // props: Effect.Effect<Input<R["Props"]>, never, PropsReq>,
37
+ // ): Effect.Effect<R, never, PropsReq | Req>;
38
38
  };
39
39
 
40
40
  export type ResourceClassWithMethods<