alchemy 2.0.0-beta.39 → 2.0.0-beta.40

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 (99) hide show
  1. package/bin/exec.js +5 -26
  2. package/bin/exec.js.map +1 -1
  3. package/lib/Auth/Lock.d.ts +4 -3
  4. package/lib/Auth/Lock.d.ts.map +1 -1
  5. package/lib/Auth/Lock.js +6 -5
  6. package/lib/Auth/Lock.js.map +1 -1
  7. package/lib/Axiom/Chart.d.ts +52 -2
  8. package/lib/Axiom/Chart.d.ts.map +1 -1
  9. package/lib/Bundle/Bundle.d.ts +7 -4
  10. package/lib/Bundle/Bundle.d.ts.map +1 -1
  11. package/lib/Bundle/Bundle.js +37 -14
  12. package/lib/Bundle/Bundle.js.map +1 -1
  13. package/lib/Cloudflare/AiGateway/AiGateway.d.ts +11 -11
  14. package/lib/Cloudflare/AiGateway/AiGateway.d.ts.map +1 -1
  15. package/lib/Cloudflare/AiGateway/AiGateway.js +28 -63
  16. package/lib/Cloudflare/AiGateway/AiGateway.js.map +1 -1
  17. package/lib/Cloudflare/Bridge.d.ts +3 -0
  18. package/lib/Cloudflare/Bridge.d.ts.map +1 -0
  19. package/lib/Cloudflare/Bridge.js +3 -0
  20. package/lib/Cloudflare/Bridge.js.map +1 -0
  21. package/lib/Cloudflare/Container/StartContainer.d.ts +2 -2
  22. package/lib/Cloudflare/Container/StartContainer.d.ts.map +1 -1
  23. package/lib/Cloudflare/Container/StartContainer.js +3 -3
  24. package/lib/Cloudflare/Container/StartContainer.js.map +1 -1
  25. package/lib/Cloudflare/Local/Sidecar.d.ts +45 -21
  26. package/lib/Cloudflare/Local/Sidecar.d.ts.map +1 -1
  27. package/lib/Cloudflare/Local/Sidecar.js +30 -6
  28. package/lib/Cloudflare/Local/Sidecar.js.map +1 -1
  29. package/lib/Cloudflare/Local/SidecarHandlers.d.ts +5 -2
  30. package/lib/Cloudflare/Local/SidecarHandlers.d.ts.map +1 -1
  31. package/lib/Cloudflare/Local/SidecarHandlers.js +323 -70
  32. package/lib/Cloudflare/Local/SidecarHandlers.js.map +1 -1
  33. package/lib/Cloudflare/Local/SidecarServer.js +9 -5
  34. package/lib/Cloudflare/Local/SidecarServer.js.map +1 -1
  35. package/lib/Cloudflare/StateStore/Api.d.ts +1 -1
  36. package/lib/Cloudflare/StateStore/Api.js +1 -1
  37. package/lib/Cloudflare/StateStore/Store.d.ts +1 -1
  38. package/lib/Cloudflare/Workers/HttpServer.d.ts.map +1 -1
  39. package/lib/Cloudflare/Workers/HttpServer.js +3 -25
  40. package/lib/Cloudflare/Workers/HttpServer.js.map +1 -1
  41. package/lib/Cloudflare/Workers/LocalWorkerProvider.d.ts +1 -2
  42. package/lib/Cloudflare/Workers/LocalWorkerProvider.d.ts.map +1 -1
  43. package/lib/Cloudflare/Workers/LocalWorkerProvider.js +16 -97
  44. package/lib/Cloudflare/Workers/LocalWorkerProvider.js.map +1 -1
  45. package/lib/Cloudflare/Workers/Vite.d.ts +9 -0
  46. package/lib/Cloudflare/Workers/Vite.d.ts.map +1 -0
  47. package/lib/Cloudflare/Workers/Vite.js +95 -0
  48. package/lib/Cloudflare/Workers/Vite.js.map +1 -0
  49. package/lib/Cloudflare/Workers/Worker.d.ts.map +1 -1
  50. package/lib/Cloudflare/Workers/Worker.js +9 -95
  51. package/lib/Cloudflare/Workers/Worker.js.map +1 -1
  52. package/lib/Cloudflare/Workers/WorkerBundle.d.ts +1 -2
  53. package/lib/Cloudflare/Workers/WorkerBundle.d.ts.map +1 -1
  54. package/lib/Cloudflare/Workers/WorkerBundle.js +5 -4
  55. package/lib/Cloudflare/Workers/WorkerBundle.js.map +1 -1
  56. package/lib/Diff.d.ts +15 -1
  57. package/lib/Diff.d.ts.map +1 -1
  58. package/lib/Diff.js +13 -7
  59. package/lib/Diff.js.map +1 -1
  60. package/lib/Http.d.ts.map +1 -1
  61. package/lib/Http.js +12 -7
  62. package/lib/Http.js.map +1 -1
  63. package/lib/Sidecar/Lock.d.ts +4 -5
  64. package/lib/Sidecar/Lock.d.ts.map +1 -1
  65. package/lib/Sidecar/Lock.js +22 -85
  66. package/lib/Sidecar/Lock.js.map +1 -1
  67. package/lib/Sidecar/RpcHandler.d.ts +4 -1
  68. package/lib/Sidecar/RpcHandler.d.ts.map +1 -1
  69. package/lib/Sidecar/RpcHandler.js +21 -2
  70. package/lib/Sidecar/RpcHandler.js.map +1 -1
  71. package/lib/Util/PlatformServices.d.ts.map +1 -1
  72. package/lib/Util/PlatformServices.js +0 -2
  73. package/lib/Util/PlatformServices.js.map +1 -1
  74. package/lib/tsconfig.test.tsbuildinfo +1 -1
  75. package/package.json +17 -12
  76. package/src/AWS/EC2/hosted.ts +1 -1
  77. package/src/AWS/ECS/Task.ts +1 -1
  78. package/src/AWS/Lambda/Function.ts +1 -1
  79. package/src/Auth/Lock.ts +6 -5
  80. package/src/Axiom/Chart.ts +56 -2
  81. package/src/Bundle/Bundle.ts +41 -17
  82. package/src/Cloudflare/AiGateway/AiGateway.ts +43 -76
  83. package/src/Cloudflare/Bridge.ts +2 -0
  84. package/src/Cloudflare/Container/ContainerApplication.ts +1 -1
  85. package/src/Cloudflare/Container/StartContainer.ts +10 -3
  86. package/src/Cloudflare/Local/Sidecar.ts +50 -21
  87. package/src/Cloudflare/Local/SidecarHandlers.ts +395 -91
  88. package/src/Cloudflare/Local/SidecarServer.ts +12 -4
  89. package/src/Cloudflare/StateStore/Api.ts +1 -1
  90. package/src/Cloudflare/Workers/HttpServer.ts +5 -37
  91. package/src/Cloudflare/Workers/LocalWorkerProvider.ts +18 -111
  92. package/src/Cloudflare/Workers/Vite.ts +114 -0
  93. package/src/Cloudflare/Workers/Worker.ts +27 -109
  94. package/src/Cloudflare/Workers/WorkerBundle.ts +7 -7
  95. package/src/Diff.ts +29 -8
  96. package/src/Http.ts +14 -10
  97. package/src/Sidecar/Lock.ts +30 -154
  98. package/src/Sidecar/RpcHandler.ts +67 -40
  99. package/src/Util/PlatformServices.ts +0 -2
@@ -1,36 +1,60 @@
1
- import * as Worker from "@distilled.cloud/cloudflare-runtime/Worker";
2
1
  import * as Effect from "effect/Effect";
3
2
  import * as Schema from "effect/Schema";
4
3
  import { BundleError } from "../../Bundle/Bundle.ts";
5
- import type { WorkerBinding } from "../Workers/Worker.ts";
6
- import type { WorkerBundleOptions } from "../Workers/WorkerBundle.ts";
7
- export interface ServeOptions extends WorkerBundleOptions {
8
- name: string;
9
- bindings: WorkerBinding[];
10
- /**
11
- * Local-mode hyperdrive connection details, keyed by binding name.
12
- * Forwarded to the runtime as the worker's `hyperdrives` field.
13
- */
14
- hyperdrives?: Record<string, Worker.HyperdriveOrigin>;
15
- durableObjectNamespaces: Worker.DurableObjectNamespace[];
4
+ import type { ResourceBinding } from "../../Resource.ts";
5
+ import type { Worker, WorkerProps } from "../Workers/Worker.ts";
6
+ export interface ReconcileOptions {
7
+ id: string;
8
+ props: WorkerProps;
9
+ bindings: ResourceBinding<Worker["Binding"]>[];
10
+ stack: {
11
+ name: string;
12
+ stage: string;
13
+ };
14
+ instanceId: string;
15
+ }
16
+ declare const ValidationError_base: Schema.Class<ValidationError, Schema.TaggedStruct<"ValidationError", {
17
+ readonly message: Schema.String;
18
+ readonly hint: Schema.optional<Schema.String>;
19
+ readonly value: Schema.Unknown;
20
+ }>, import("effect/Cause").YieldableError>;
21
+ export declare class ValidationError extends ValidationError_base {
16
22
  }
17
23
  export declare const ServeResult: Schema.Struct<{
18
- readonly name: Schema.String;
19
- readonly address: Schema.String;
24
+ readonly workerId: Schema.String;
25
+ readonly workerName: Schema.String;
26
+ readonly logpush: Schema.UndefinedOr<Schema.Boolean>;
27
+ readonly url: Schema.String;
28
+ readonly tags: Schema.mutable<Schema.$Array<Schema.String>>;
29
+ readonly durableObjectNamespaces: Schema.$Record<Schema.String, Schema.String>;
30
+ readonly domains: Schema.mutable<Schema.$Array<Schema.Struct<{
31
+ readonly hostname: Schema.String;
32
+ readonly id: Schema.String;
33
+ readonly zoneId: Schema.String;
34
+ }>>>;
35
+ readonly crons: Schema.mutable<Schema.$Array<Schema.String>>;
36
+ readonly accountId: Schema.String;
20
37
  }>;
21
38
  export type ServeResult = typeof ServeResult.Type;
22
- export declare const ServeError: Schema.Union<readonly [Schema.Union<readonly [typeof import("@distilled.cloud/cloudflare-runtime/RuntimeError").ConfigError, typeof import("@distilled.cloud/cloudflare-runtime/RuntimeError").SystemError, typeof import("@distilled.cloud/cloudflare-runtime/RuntimeError").ApiError]>, typeof BundleError]>;
39
+ export declare const ServeError: Schema.Union<readonly [Schema.Union<readonly [typeof import("@distilled.cloud/cloudflare-runtime").ConfigError, typeof import("@distilled.cloud/cloudflare-runtime").SystemError, typeof import("@distilled.cloud/cloudflare-runtime").ApiError]>, typeof BundleError, typeof ValidationError]>;
23
40
  export type ServeError = typeof ServeError.Type;
41
+ export declare const DiffResult: Schema.Struct<{
42
+ readonly action: Schema.Literals<readonly ["update", "noop"]>;
43
+ }>;
44
+ export type DiffResult = typeof DiffResult.Type;
24
45
  export declare const SidecarSchema: import("../../Sidecar/RpcHandler.ts").RpcHandlerEncoders<{
25
- readonly serve: (options: ServeOptions) => Effect.Effect<ServeResult, ServeError>;
26
- readonly stop: (name: string) => Effect.Effect<void>;
46
+ readonly diff: (options: ReconcileOptions) => Effect.Effect<DiffResult>;
47
+ readonly reconcile: (options: ReconcileOptions) => Effect.Effect<ServeResult, ServeError>;
48
+ readonly delete: (id: string) => Effect.Effect<void>;
27
49
  }> & import("../../Sidecar/RpcHandler.ts").RpcHandlerDecoders<{
28
- readonly serve: (options: ServeOptions) => Effect.Effect<ServeResult, ServeError>;
29
- readonly stop: (name: string) => Effect.Effect<void>;
50
+ readonly diff: (options: ReconcileOptions) => Effect.Effect<DiffResult>;
51
+ readonly reconcile: (options: ReconcileOptions) => Effect.Effect<ServeResult, ServeError>;
52
+ readonly delete: (id: string) => Effect.Effect<void>;
30
53
  }>;
31
54
  declare const Sidecar_base: import("effect/Context").ServiceClass<Sidecar, "Sidecar", {
32
- readonly serve: (options: ServeOptions) => Effect.Effect<ServeResult, ServeError>;
33
- readonly stop: (name: string) => Effect.Effect<void>;
55
+ readonly diff: (options: ReconcileOptions) => Effect.Effect<DiffResult>;
56
+ readonly reconcile: (options: ReconcileOptions) => Effect.Effect<ServeResult, ServeError>;
57
+ readonly delete: (id: string) => Effect.Effect<void>;
34
58
  }>;
35
59
  export declare class Sidecar extends Sidecar_base {
36
60
  }
@@ -1 +1 @@
1
- {"version":3,"file":"Sidecar.d.ts","sourceRoot":"","sources":["../../../src/Cloudflare/Local/Sidecar.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,MAAM,MAAM,4CAA4C,CAAC;AACrE,OAAO,KAAK,MAAM,MAAM,eAAe,CAAC;AACxC,OAAO,KAAK,MAAM,MAAM,eAAe,CAAC;AACxC,OAAO,EAAE,WAAW,EAAE,MAAM,wBAAwB,CAAC;AAGrD,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,sBAAsB,CAAC;AAC1D,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,4BAA4B,CAAC;AAEtE,MAAM,WAAW,YAAa,SAAQ,mBAAmB;IACvD,IAAI,EAAE,MAAM,CAAC;IACb,QAAQ,EAAE,aAAa,EAAE,CAAC;IAC1B;;;OAGG;IACH,WAAW,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,gBAAgB,CAAC,CAAC;IACtD,uBAAuB,EAAE,MAAM,CAAC,sBAAsB,EAAE,CAAC;CAC1D;AAED,eAAO,MAAM,WAAW;;;EAGtB,CAAC;AACH,MAAM,MAAM,WAAW,GAAG,OAAO,WAAW,CAAC,IAAI,CAAC;AAElD,eAAO,MAAM,UAAU,gTAA4C,CAAC;AACpE,MAAM,MAAM,UAAU,GAAG,OAAO,UAAU,CAAC,IAAI,CAAC;AAEhD,eAAO,MAAM,aAAa;oBAWN,CACd,OAAO,EAAE,YAAY,KAClB,MAAM,CAAC,MAAM,CAAC,WAAW,EAAE,UAAU,CAAC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;AACH,MAAM,MAAM,WAAW,GAAG,OAAO,WAAW,CAAC,IAAI,CAAC;AAElD,eAAO,MAAM,UAAU,iSAIrB,CAAC;AACH,MAAM,MAAM,UAAU,GAAG,OAAO,UAAU,CAAC,IAAI,CAAC;AAEhD,eAAO,MAAM,UAAU;;EAErB,CAAC;AACH,MAAM,MAAM,UAAU,GAAG,OAAO,UAAU,CAAC,IAAI,CAAC;AAEhD,eAAO,MAAM,aAAa;mBAYP,CAAC,OAAO,EAAE,gBAAgB,KAAK,MAAM,CAAC,MAAM,CAAC,UAAU,CAAC;wBACnD,CAClB,OAAO,EAAE,gBAAgB,KACtB,MAAM,CAAC,MAAM,CAAC,WAAW,EAAE,UAAU,CAAC;qBAC1B,CAAC,EAAE,EAAE,MAAM,KAAK,MAAM,CAAC,MAAM,CAAC,IAAI,CAAC;;mBAJrC,CAAC,OAAO,EAAE,gBAAgB,KAAK,MAAM,CAAC,MAAM,CAAC,UAAU,CAAC;wBACnD,CAClB,OAAO,EAAE,gBAAgB,KACtB,MAAM,CAAC,MAAM,CAAC,WAAW,EAAE,UAAU,CAAC;qBAC1B,CAAC,EAAE,EAAE,MAAM,KAAK,MAAM,CAAC,MAAM,CAAC,IAAI,CAAC;EATtD,CAAC;;mBAKgB,CAAC,OAAO,EAAE,gBAAgB,KAAK,MAAM,CAAC,MAAM,CAAC,UAAU,CAAC;wBACnD,CAClB,OAAO,EAAE,gBAAgB,KACtB,MAAM,CAAC,MAAM,CAAC,WAAW,EAAE,UAAU,CAAC;qBAC1B,CAAC,EAAE,EAAE,MAAM,KAAK,MAAM,CAAC,MAAM,CAAC,IAAI,CAAC;;AAPxD,qBAAa,OAAQ,SAAQ,YASf;CAAG;AAEjB,eAAO,MAAM,WAAW,kPAGtB,CAAC"}
@@ -1,21 +1,45 @@
1
1
  import { RuntimeError } from "@distilled.cloud/cloudflare-runtime/RuntimeError";
2
- import * as Worker from "@distilled.cloud/cloudflare-runtime/Worker";
3
2
  import * as Effect from "effect/Effect";
4
3
  import * as Schema from "effect/Schema";
5
4
  import { BundleError } from "../../Bundle/Bundle.js";
6
5
  import * as RpcClient from "../../Sidecar/RpcClient.js";
7
6
  import { defineSchema } from "../../Sidecar/RpcHandler.js";
7
+ export class ValidationError extends Schema.TaggedErrorClass()("ValidationError", {
8
+ message: Schema.String,
9
+ hint: Schema.optional(Schema.String),
10
+ value: Schema.Unknown,
11
+ }) {
12
+ }
8
13
  export const ServeResult = Schema.Struct({
9
- name: Schema.String,
10
- address: Schema.String,
14
+ workerId: Schema.String,
15
+ workerName: Schema.String,
16
+ logpush: Schema.UndefinedOr(Schema.Boolean),
17
+ url: Schema.String,
18
+ tags: Schema.Array(Schema.String).pipe(Schema.mutable),
19
+ durableObjectNamespaces: Schema.Record(Schema.String, Schema.String),
20
+ domains: Schema.Array(Schema.Struct({
21
+ hostname: Schema.String,
22
+ id: Schema.String,
23
+ zoneId: Schema.String,
24
+ })).pipe(Schema.mutable),
25
+ crons: Schema.Array(Schema.String).pipe(Schema.mutable),
26
+ accountId: Schema.String,
27
+ });
28
+ export const ServeError = Schema.Union([
29
+ RuntimeError,
30
+ BundleError,
31
+ ValidationError,
32
+ ]);
33
+ export const DiffResult = Schema.Struct({
34
+ action: Schema.Literals(["update", "noop"]),
11
35
  });
12
- export const ServeError = Schema.Union([RuntimeError, BundleError]);
13
36
  export const SidecarSchema = defineSchema({
14
- serve: {
37
+ diff: { success: DiffResult, error: Schema.Never },
38
+ reconcile: {
15
39
  success: ServeResult,
16
40
  error: ServeError,
17
41
  },
18
- stop: { success: Schema.Void, error: Schema.Never },
42
+ delete: { success: Schema.Void, error: Schema.Never },
19
43
  });
20
44
  export class Sidecar extends RpcClient.RpcClientService()("Sidecar") {
21
45
  }
@@ -1 +1 @@
1
- {"version":3,"file":"Sidecar.js","sourceRoot":"","sources":["../../../src/Cloudflare/Local/Sidecar.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAE,MAAM,kDAAkD,CAAC;AAChF,OAAO,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AAM,CAAC,MAAM;CACzB,CAAC,CAAC;AAGH,MAAM,CAAC,MAAM,UAAU,GAAG,MAAM,CAAC,KAAK,CAAC;IACrC,YAAY;IACZ,WAAW;IACX,eAAe;CAChB,CAAC,CAAC;AAGH,MAAM,CAAC,MAAM,UAAU,GAAG,MAAM,CAAC,MAAM,CAAC;IACtC,MAAM,EAAE,MAAM,CAAC,QAAQ,CAAC,CAAC,QAAQ,EAAE,MAAM,CAAC,CAAC;CAC5C,CAAC,CAAC;AAGH,MAAM,CAAC,MAAM,aAAa,GAAG,YAAY,CAAqB;IAC5D,IAAI,EAAE,EAAE,OAAO,EAAE,UAAU,EAAE,KAAK,EAAE,MAAM,CAAC,KAAK,EAAE;IAClD,SAAS,EAAE;QACT,OAAO,EAAE,WAAW;QACpB,KAAK,EAAE,UAAU;KAClB;IACD,MAAM,EAAE,EAAE,OAAO,EAAE,MAAM,CAAC,IAAI,EAAE,KAAK,EAAE,MAAM,CAAC,KAAK,EAAE;CACtD,CAAC,CAAC;AAEH,MAAM,OAAO,OAAQ,SAAQ,SAAS,CAAC,gBAAgB,EASpD,CAAC,SAAS,CAAC;CAAG;AAEjB,MAAM,CAAC,MAAM,WAAW,GAAG,SAAS,CAAC,KAAK,CAAC,OAAO,EAAE;IAClD,IAAI,EAAE,MAAM,CAAC,IAAI,CAAC,OAAO,CAAC,oBAAoB,EAAE,MAAM,CAAC,IAAI,CAAC,GAAG,CAAC;IAChE,MAAM,EAAE,aAAa;CACtB,CAAC,CAAC"}
@@ -1,5 +1,8 @@
1
- import * as Server from "@distilled.cloud/cloudflare-runtime/Server";
1
+ import { type RuntimeServices } from "@distilled.cloud/cloudflare-runtime";
2
+ import * as LocalProxy from "@distilled.cloud/cloudflare-runtime/proxy/LocalProxy";
2
3
  import * as Layer from "effect/Layer";
4
+ import * as Path from "effect/Path";
5
+ import { CloudflareEnvironment } from "../CloudflareEnvironment.ts";
3
6
  import { Sidecar } from "./Sidecar.ts";
4
- export declare const SidecarHandlers: Layer.Layer<Sidecar, never, import("effect/FileSystem").FileSystem | import("effect/Path").Path | Server.Server>;
7
+ export declare const SidecarHandlers: Layer.Layer<Sidecar, never, import("effect/FileSystem").FileSystem | Path.Path | CloudflareEnvironment | LocalProxy.LocalProxy | RuntimeServices>;
5
8
  //# sourceMappingURL=SidecarHandlers.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"SidecarHandlers.d.ts","sourceRoot":"","sources":["../../../src/Cloudflare/Local/SidecarHandlers.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,MAAM,MAAM,4CAA4C,CAAC;AAQrE,OAAO,KAAK,KAAK,MAAM,cAAc,CAAC;AAMtC,OAAO,EACL,OAAO,EAIR,MAAM,cAAc,CAAC;AAEtB,eAAO,MAAM,eAAe,kHA+I3B,CAAC"}
1
+ {"version":3,"file":"SidecarHandlers.d.ts","sourceRoot":"","sources":["../../../src/Cloudflare/Local/SidecarHandlers.ts"],"names":[],"mappings":"AAAA,OAAO,EAQL,KAAK,eAAe,EACrB,MAAM,qCAAqC,CAAC;AAmB7C,OAAO,KAAK,UAAU,MAAM,sDAAsD,CAAC;AAMnF,OAAO,KAAK,KAAK,MAAM,cAAc,CAAC;AACtC,OAAO,KAAK,IAAI,MAAM,aAAa,CAAC;AASpC,OAAO,EAAE,qBAAqB,EAAE,MAAM,6BAA6B,CAAC;AAcpE,OAAO,EAGL,OAAO,EAGR,MAAM,cAAc,CAAC;AAEtB,eAAO,MAAM,eAAe,mJAwS3B,CAAC"}
@@ -1,52 +1,160 @@
1
- import * as Server from "@distilled.cloud/cloudflare-runtime/Server";
1
+ import { Runtime, } from "@distilled.cloud/cloudflare-runtime";
2
+ import { Ai, Assets, Browser, D1, Data, DurableObjectNamespace, Hyperdrive, Images, Json, KvNamespace, R2Bucket, Service, Text, VersionMetadata, WasmModule, WorkerLoader, } from "@distilled.cloud/cloudflare-runtime/bindings";
3
+ import * as LocalProxy from "@distilled.cloud/cloudflare-runtime/proxy/LocalProxy";
2
4
  import * as Cause from "effect/Cause";
3
- import * as Deferred from "effect/Deferred";
4
5
  import * as Effect from "effect/Effect";
5
6
  import * as Exit from "effect/Exit";
6
7
  import * as Fiber from "effect/Fiber";
7
8
  import * as Hash from "effect/Hash";
8
9
  import * as Layer from "effect/Layer";
10
+ import * as Path from "effect/Path";
11
+ import * as Redacted from "effect/Redacted";
9
12
  import * as Result from "effect/Result";
10
13
  import * as Scope from "effect/Scope";
11
14
  import * as Stream from "effect/Stream";
12
- import * as Bundle from "../../Bundle/Bundle.js";
13
- import { WorkerBundle } from "../Workers/WorkerBundle.js";
14
- import { Sidecar, } from "./Sidecar.js";
15
+ import { InstanceId } from "../../InstanceId.js";
16
+ import { Stack } from "../../Stack.js";
17
+ import { Stage } from "../../Stage.js";
18
+ import { CloudflareEnvironment } from "../CloudflareEnvironment.js";
19
+ import { getCompatibility } from "../Workers/Compatibility.js";
20
+ import { getCronBindings } from "../Workers/index.js";
21
+ import * as Vite from "../Workers/Vite.js";
22
+ import { WorkerBundle, } from "../Workers/WorkerBundle.js";
23
+ import { createWorkerName } from "../Workers/WorkerName.js";
24
+ import { ServeError, ServeResult, Sidecar, ValidationError, } from "./Sidecar.js";
15
25
  export const SidecarHandlers = Layer.effect(Sidecar, Effect.gen(function* () {
16
- const bundle = yield* WorkerBundle;
17
- const server = yield* Server.Server;
18
- const rootScope = yield* Effect.scope;
19
- const serverScopes = new Map();
20
- const serveScoped = Effect.fnUntraced(function* (worker, modules) {
26
+ const { accountId } = yield* CloudflareEnvironment;
27
+ const bundler = yield* WorkerBundle;
28
+ const runtime = yield* Runtime;
29
+ const path = yield* Path.Path;
30
+ const localProxy = yield* LocalProxy.LocalProxy;
31
+ const toRuntimeModules = Effect.fn(function* (bundle) {
32
+ const modules = [];
33
+ for (const file of bundle.files) {
34
+ const ext = path.extname(file.path);
35
+ const type = moduleTypeFromExtension(ext);
36
+ if (type === "SourceMap")
37
+ continue;
38
+ if (type === "Data" || type === "Wasm") {
39
+ if (!(file.content instanceof Uint8Array)) {
40
+ return yield* new ValidationError({
41
+ message: `Expected Uint8Array for ${file.path} (${type})`,
42
+ value: file.content,
43
+ });
44
+ }
45
+ modules.push({
46
+ name: file.path,
47
+ type,
48
+ content: file.content,
49
+ });
50
+ }
51
+ else {
52
+ if (typeof file.content !== "string") {
53
+ return yield* new ValidationError({
54
+ message: `Expected string for ${file.path} (${type})`,
55
+ value: file.content,
56
+ });
57
+ }
58
+ modules.push({
59
+ name: file.path,
60
+ type,
61
+ content: file.content,
62
+ });
63
+ }
64
+ }
65
+ return modules;
66
+ });
67
+ const serveScoped = Effect.fnUntraced(function* (worker, bundle) {
21
68
  const scope = yield* Effect.flatMap(Effect.scope, Scope.fork);
22
- const result = yield* server
23
- .serve({
24
- name: worker.id.toLowerCase(),
69
+ const address = yield* runtime
70
+ .start({
71
+ name: worker.name,
25
72
  compatibilityDate: worker.compatibility.date,
26
73
  compatibilityFlags: worker.compatibility.flags,
27
- bindings: worker.bindings,
74
+ bindings: worker.workerBindings,
28
75
  hyperdrives: worker.hyperdrives,
29
- durableObjectNamespaces: worker.durableObjectNamespaces,
30
- modules,
76
+ durableObjectNamespaces: toRuntimeDurableObjectNamespaces(worker.durableObjectNamespaces),
77
+ modules: yield* toRuntimeModules(bundle),
78
+ assets: toRuntimeAssets(worker.assets),
31
79
  })
32
80
  .pipe(Scope.provide(scope));
33
- const previous = serverScopes.get(worker.name);
81
+ const previous = workerdScopes.get(worker.id);
34
82
  if (previous) {
35
83
  yield* Effect.forkDetach(Scope.close(previous, Exit.void));
36
84
  }
37
- serverScopes.set(worker.name, scope);
38
- return result;
85
+ workerdScopes.set(worker.id, scope);
86
+ yield* localProxy.setLocalAddress(worker.id, address);
87
+ return address;
88
+ });
89
+ const buildConfig = Effect.fn(function* ({ id, props, bindings, stack, instanceId, }) {
90
+ const name = yield* createWorkerName(id, props.name).pipe(Effect.provideService(Stack, stack), Effect.provideService(Stage, stack.stage), Effect.provideService(InstanceId, instanceId));
91
+ const compatibility = getCompatibility(props);
92
+ const workerBindings = [];
93
+ const durableObjectNamespaces = {};
94
+ const hyperdrives = {};
95
+ for (const { data } of bindings) {
96
+ for (const binding of data.bindings ?? []) {
97
+ if (binding.type === "durable_object_namespace") {
98
+ durableObjectNamespaces[binding.name] = binding.className;
99
+ }
100
+ workerBindings.push(yield* toRuntimeBinding(binding));
101
+ }
102
+ if (data.hyperdrives) {
103
+ for (const [id, origin] of Object.entries(data.hyperdrives)) {
104
+ hyperdrives[id] = {
105
+ scheme: origin.scheme,
106
+ host: origin.host,
107
+ port: origin.port,
108
+ user: origin.user,
109
+ database: origin.database,
110
+ password: Redacted.isRedacted(origin.password)
111
+ ? Redacted.value(origin.password)
112
+ : origin.password,
113
+ sslmode: origin.sslmode,
114
+ };
115
+ }
116
+ }
117
+ }
118
+ for (const [key, value] of Object.entries(props.env ?? {})) {
119
+ if (value === undefined)
120
+ continue;
121
+ if (Redacted.isRedacted(value)) {
122
+ workerBindings.push(Text.binding(key, Redacted.value(value)));
123
+ }
124
+ else if (typeof value === "string") {
125
+ workerBindings.push(Text.binding(key, value));
126
+ }
127
+ else {
128
+ workerBindings.push(Json.binding(key, value));
129
+ }
130
+ }
131
+ return {
132
+ id,
133
+ name,
134
+ compatibility,
135
+ workerBindings,
136
+ durableObjectNamespaces,
137
+ hyperdrives,
138
+ bundleOptions: {
139
+ id,
140
+ main: props.main,
141
+ compatibility,
142
+ entry: props.isExternal
143
+ ? { kind: "external" }
144
+ : { kind: "effect", exports: (props.exports ?? {}) },
145
+ stack: { name: stack.name, stage: stack.stage },
146
+ userOptions: props.build,
147
+ },
148
+ assets: props.assets,
149
+ };
39
150
  });
40
- const watchers = new Map();
41
- const serveFiber = Effect.fnUntraced(function* (worker) {
42
- const result = yield* Deferred.make();
151
+ const runServer = Effect.fnUntraced(function* (worker) {
43
152
  let start = Date.now();
44
- yield* bundle.watch(worker).pipe(Stream.mapEffect((event) => event._tag === "Error" && !Deferred.isDoneUnsafe(result)
45
- ? Effect.fail(event.error)
46
- : Effect.succeed(event)), Stream.tap((event) => {
153
+ let status = "start";
154
+ yield* bundler.watch(worker.bundleOptions).pipe(Stream.tap((event) => {
47
155
  if (event._tag === "Start") {
48
156
  start = Date.now();
49
- if (Deferred.isDoneUnsafe(result)) {
157
+ if (status === "update") {
50
158
  return Effect.log(`[${worker.id}] Rebuilding`);
51
159
  }
52
160
  }
@@ -56,73 +164,218 @@ export const SidecarHandlers = Layer.effect(Sidecar, Effect.gen(function* () {
56
164
  return Effect.void;
57
165
  }), Stream.filterMap((event) => event._tag === "Success"
58
166
  ? Result.succeed(event.output)
59
- : Result.failVoid), Stream.map(bundleOutputToWorkerModules), Stream.mapEffect((modules) => serveScoped(worker, modules).pipe(Effect.exit, Effect.tap((exit) => {
60
- const isDone = Deferred.isDoneUnsafe(result);
167
+ : Result.failVoid), Stream.mapEffect((bundle) => serveScoped(worker, bundle).pipe(Effect.exit, Effect.tap((exit) => {
61
168
  if (exit._tag === "Success") {
62
- return Effect.log(`[${worker.id}] ${isDone ? "Updated" : "Started"} in ${Math.round(Date.now() - start)}ms`);
169
+ const message = Effect.log(`[${worker.id}] ${status === "update" ? "Updated" : "Started"} in ${Math.round(Date.now() - start)}ms`);
170
+ status = "update";
171
+ return message;
63
172
  }
64
- else if (isDone) {
173
+ else {
65
174
  return Effect.logError(`[${worker.id}] Error`, Cause.squash(exit.cause));
66
175
  }
67
- return Effect.void;
68
- }), Effect.tap((exit) => Deferred.complete(result, exit)))), Stream.onExit((exit) => exit._tag === "Failure" && !Deferred.isDoneUnsafe(result)
69
- ? Deferred.failCause(result, exit.cause)
70
- : Effect.void), Stream.runDrain, Effect.forkScoped);
71
- return yield* Deferred.await(result);
176
+ }))), Stream.runDrain, Effect.forkScoped);
177
+ });
178
+ const rootScope = yield* Effect.scope;
179
+ const workerdScopes = new Map();
180
+ const context = yield* Effect.context();
181
+ const instances = new Map();
182
+ const runInstance = Effect.fn(function* (options) {
183
+ const { id, props, bindings } = options;
184
+ const config = yield* buildConfig(options);
185
+ const url = yield* localProxy.registerWorker(id);
186
+ if (props.vite) {
187
+ console.log("starting vite dev server", id);
188
+ const devServer = yield* Vite.viteDev(props.vite.rootDir, props.env ?? {}, {
189
+ compatibilityDate: config.compatibility.date,
190
+ compatibilityFlags: config.compatibility.flags,
191
+ worker: {
192
+ name: config.name,
193
+ bindings: config.workerBindings,
194
+ durableObjectNamespaces: toRuntimeDurableObjectNamespaces(config.durableObjectNamespaces),
195
+ hyperdrives: config.hyperdrives,
196
+ assets: toRuntimeAssets(config.assets),
197
+ },
198
+ context,
199
+ });
200
+ console.log("vite dev server started", id);
201
+ const localAddress = devServer.resolvedUrls.local[0].slice(0, -1);
202
+ yield* localProxy.setLocalAddress(id, localAddress);
203
+ }
204
+ else {
205
+ yield* runServer(config);
206
+ }
207
+ return {
208
+ workerId: config.name,
209
+ workerName: config.name,
210
+ logpush: undefined,
211
+ url,
212
+ tags: [],
213
+ durableObjectNamespaces: config.durableObjectNamespaces,
214
+ domains: [],
215
+ crons: Array.from(new Set([...getCronBindings(bindings), ...(props.crons ?? [])])),
216
+ accountId,
217
+ };
72
218
  });
73
219
  return Sidecar.of({
74
- serve: Effect.fn(function* (worker) {
75
- const hash = Hash.structure(worker);
76
- const existing = watchers.get(worker.name);
220
+ diff: Effect.fn(function* (options) {
221
+ const hash = Hash.structure(options);
222
+ return {
223
+ action: instances.get(options.id)?.hash === hash ? "noop" : "update",
224
+ };
225
+ }),
226
+ reconcile: Effect.fn(function* (options) {
227
+ const hash = Hash.structure(options);
228
+ const existing = instances.get(options.id);
77
229
  if (existing) {
78
230
  if (existing.hash === hash) {
79
- yield* Effect.log(`[${worker.id}] No changes, using existing watcher`);
231
+ yield* Effect.log(`[${options.id}] No changes, using existing instance`);
80
232
  return yield* Fiber.join(existing.fiber);
81
233
  }
82
- yield* Effect.log(`[${worker.id}] Changes detected, interrupting existing watcher`);
234
+ yield* Effect.log(`[${options.id}] Changes detected, interrupting existing instance`);
83
235
  yield* Fiber.interrupt(existing.fiber);
84
236
  yield* Scope.close(existing.scope, Exit.void);
85
- watchers.delete(worker.name);
237
+ instances.delete(options.id);
86
238
  }
87
239
  const scope = yield* Scope.fork(rootScope);
88
- const fiber = yield* serveFiber(worker).pipe(Effect.forkDetach, Scope.provide(scope));
89
- watchers.set(worker.name, { hash, fiber, scope });
240
+ const fiber = yield* runInstance(options).pipe(Effect.forkDetach, Scope.provide(scope));
241
+ instances.set(options.id, { hash, fiber, scope });
90
242
  return yield* Fiber.join(fiber).pipe(Effect.onExit((exit) => Effect.sync(() => {
91
243
  if (exit._tag === "Failure") {
92
- watchers.delete(worker.name);
244
+ instances.delete(options.id);
93
245
  }
94
246
  })));
95
247
  }),
96
- stop: Effect.fn(function* (name) {
97
- const watcher = watchers.get(name);
98
- if (watcher) {
99
- yield* Fiber.interrupt(watcher.fiber);
100
- yield* Scope.close(watcher.scope, Exit.void);
101
- watchers.delete(name);
248
+ delete: Effect.fn(function* (id) {
249
+ const existing = instances.get(id);
250
+ if (existing) {
251
+ yield* Fiber.interrupt(existing.fiber);
252
+ yield* Scope.close(existing.scope, Exit.void);
253
+ instances.delete(id);
102
254
  }
103
255
  }),
104
256
  });
105
257
  }));
106
- function bundleOutputToWorkerModules(bundle) {
107
- const modules = [];
108
- for (const file of bundle.files) {
109
- if (file.path.endsWith(".map")) {
110
- continue;
111
- }
112
- if (file.content instanceof Uint8Array) {
113
- modules.push({
114
- name: file.path,
115
- type: file.path.endsWith(".wasm") ? "Wasm" : "Data",
116
- content: file.content,
258
+ const toRuntimeBinding = Effect.fnUntraced(function* (b) {
259
+ const unsupported = () => new ValidationError({
260
+ message: `${b.type} bindings are not supported in local mode`,
261
+ value: b,
262
+ });
263
+ switch (b.type) {
264
+ case "ai":
265
+ return Ai.remote(b.name);
266
+ case "analytics_engine":
267
+ return yield* unsupported();
268
+ case "artifacts":
269
+ return yield* unsupported();
270
+ case "assets":
271
+ return Assets.binding(b.name);
272
+ case "browser":
273
+ return Browser.binding(b.name);
274
+ case "d1":
275
+ return D1.remote(b.name, b.id);
276
+ case "data_blob":
277
+ return Data.binding(b.name, Buffer.from(b.part));
278
+ case "dispatch_namespace":
279
+ return yield* unsupported();
280
+ case "durable_object_namespace":
281
+ return DurableObjectNamespace.local({
282
+ name: b.name,
283
+ className: b.className,
284
+ scriptName: b.scriptName,
117
285
  });
118
- continue;
119
- }
120
- modules.push({
121
- name: file.path,
122
- type: "ESModule",
123
- content: file.content,
124
- });
286
+ case "hyperdrive":
287
+ return Hyperdrive.binding(b.name, b.id);
288
+ case "images":
289
+ return Images.remote(b.name);
290
+ case "inherit":
291
+ return yield* unsupported();
292
+ case "json":
293
+ return Json.binding(b.name, b.json);
294
+ case "kv_namespace":
295
+ return KvNamespace.remote(b.name, b.namespaceId);
296
+ case "mtls_certificate":
297
+ return yield* unsupported();
298
+ case "pipelines":
299
+ return yield* unsupported();
300
+ case "plain_text":
301
+ return Text.binding(b.name, b.text);
302
+ case "queue":
303
+ return yield* unsupported();
304
+ case "r2_bucket":
305
+ return R2Bucket.remote(b.name, b.bucketName, b.jurisdiction);
306
+ case "ratelimit":
307
+ return yield* unsupported();
308
+ case "secret_key":
309
+ return yield* unsupported();
310
+ case "secret_text":
311
+ return Text.binding(b.name, b.text);
312
+ case "secrets_store_secret":
313
+ return yield* unsupported();
314
+ case "send_email":
315
+ return yield* unsupported();
316
+ case "service":
317
+ return Service.local({ name: b.name, scriptName: b.service });
318
+ case "text_blob":
319
+ return Data.binding(b.name, Buffer.from(b.part));
320
+ case "vectorize":
321
+ return yield* unsupported();
322
+ case "version_metadata":
323
+ return VersionMetadata.binding(b.name);
324
+ case "wasm_module":
325
+ return WasmModule.binding(b.name, Buffer.from(b.part));
326
+ case "worker_loader":
327
+ return WorkerLoader.binding(b.name);
328
+ case "workflow":
329
+ return yield* unsupported();
330
+ default:
331
+ return yield* unsupported();
332
+ }
333
+ });
334
+ const toRuntimeAssets = (assets) => {
335
+ if (!assets)
336
+ return undefined;
337
+ if (typeof assets === "string") {
338
+ return {
339
+ directory: assets,
340
+ };
341
+ }
342
+ return {
343
+ directory: "directory" in assets ? assets.directory : assets.path,
344
+ headers: assets.config?.headers,
345
+ redirects: assets.config?.redirects,
346
+ htmlHandling: assets.config?.htmlHandling,
347
+ notFoundHandling: assets.config?.notFoundHandling,
348
+ runWorkerFirst: assets.config?.runWorkerFirst,
349
+ serveDirectly: assets.config?.serveDirectly,
350
+ };
351
+ };
352
+ const toRuntimeDurableObjectNamespaces = (namespaces) => {
353
+ return Object.entries(namespaces).map(([className, namespaceId]) => ({
354
+ className,
355
+ uniqueKey: namespaceId,
356
+ sql: true,
357
+ }));
358
+ };
359
+ const moduleTypeFromExtension = (ext) => {
360
+ switch (ext) {
361
+ case ".wasm":
362
+ return "Wasm";
363
+ case ".txt":
364
+ case ".html":
365
+ case ".sql":
366
+ case ".custom":
367
+ return "Text";
368
+ case ".bin":
369
+ return "Data";
370
+ case ".mjs":
371
+ case ".js":
372
+ return "ESModule";
373
+ case ".cjs":
374
+ return "CommonJsModule";
375
+ case ".map":
376
+ return "SourceMap";
377
+ default:
378
+ return "Text";
125
379
  }
126
- return modules;
127
- }
380
+ };
128
381
  //# sourceMappingURL=SidecarHandlers.js.map