alchemy 2.0.0-beta.50 → 2.0.0-beta.52
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/bin/exec.js +133 -135
- package/bin/exec.js.map +1 -1
- package/lib/AWS/Lambda/BucketEventSource.d.ts.map +1 -1
- package/lib/AWS/Lambda/BucketEventSource.js +13 -2
- package/lib/AWS/Lambda/BucketEventSource.js.map +1 -1
- package/lib/AWS/S3/Bucket.d.ts.map +1 -1
- package/lib/AWS/S3/Bucket.js +49 -0
- package/lib/AWS/S3/Bucket.js.map +1 -1
- package/lib/AWS/S3/BucketNotifications.d.ts +10 -0
- package/lib/AWS/S3/BucketNotifications.d.ts.map +1 -1
- package/lib/AWS/S3/BucketNotifications.js.map +1 -1
- package/lib/Apply.js +15 -3
- package/lib/Apply.js.map +1 -1
- package/lib/Auth/AuthProvider.js +1 -1
- package/lib/Auth/AuthProvider.js.map +1 -1
- package/lib/Binding.d.ts.map +1 -1
- package/lib/Binding.js +12 -8
- package/lib/Binding.js.map +1 -1
- package/lib/Build/DevServer.d.ts +113 -0
- package/lib/Build/DevServer.d.ts.map +1 -0
- package/lib/Build/DevServer.js +212 -0
- package/lib/Build/DevServer.js.map +1 -0
- package/lib/Build/Local.d.ts +2 -0
- package/lib/Build/Local.d.ts.map +1 -0
- package/lib/Build/Local.js +4 -0
- package/lib/Build/Local.js.map +1 -0
- package/lib/Bundle/Bundle.js +1 -1
- package/lib/Bundle/Bundle.js.map +1 -1
- package/lib/Cli/commands/cloudflare.d.ts +1 -1
- package/lib/Cloudflare/Access.js +1 -1
- package/lib/Cloudflare/Access.js.map +1 -1
- package/lib/Cloudflare/AiGateway/AiGateway.d.ts +1 -1
- package/lib/Cloudflare/AiGateway/AiGateway.js +1 -1
- package/lib/Cloudflare/AiGateway/AiGatewayBinding.d.ts +1 -1
- package/lib/Cloudflare/AiGateway/AiGatewayBinding.d.ts.map +1 -1
- package/lib/Cloudflare/AiGateway/AiGatewayBinding.js +6 -2
- package/lib/Cloudflare/AiGateway/AiGatewayBinding.js.map +1 -1
- package/lib/Cloudflare/Browser/Browser.d.ts +84 -12
- package/lib/Cloudflare/Browser/Browser.d.ts.map +1 -1
- package/lib/Cloudflare/Browser/Browser.js +80 -9
- package/lib/Cloudflare/Browser/Browser.js.map +1 -1
- package/lib/Cloudflare/Browser/BrowserBinding.d.ts +90 -16
- package/lib/Cloudflare/Browser/BrowserBinding.d.ts.map +1 -1
- package/lib/Cloudflare/Browser/BrowserBinding.js +41 -6
- package/lib/Cloudflare/Browser/BrowserBinding.js.map +1 -1
- package/lib/Cloudflare/Browser/index.d.ts +1 -1
- package/lib/Cloudflare/Browser/index.d.ts.map +1 -1
- package/lib/Cloudflare/Browser/index.js.map +1 -1
- package/lib/Cloudflare/Container/ContainerBinding.d.ts.map +1 -1
- package/lib/Cloudflare/Container/ContainerBinding.js +2 -4
- package/lib/Cloudflare/Container/ContainerBinding.js.map +1 -1
- package/lib/Cloudflare/Images/Images.d.ts +4 -3
- package/lib/Cloudflare/Images/Images.d.ts.map +1 -1
- package/lib/Cloudflare/Images/Images.js.map +1 -1
- package/lib/Cloudflare/Providers.d.ts +1 -1
- package/lib/Cloudflare/Providers.d.ts.map +1 -1
- package/lib/Cloudflare/Providers.js +6 -1
- package/lib/Cloudflare/Providers.js.map +1 -1
- package/lib/Cloudflare/RateLimit/RateLimit.d.ts +4 -3
- package/lib/Cloudflare/RateLimit/RateLimit.d.ts.map +1 -1
- package/lib/Cloudflare/RateLimit/RateLimit.js.map +1 -1
- package/lib/Cloudflare/Ruleset/Ruleset.d.ts +82 -0
- package/lib/Cloudflare/Ruleset/Ruleset.d.ts.map +1 -0
- package/lib/Cloudflare/Ruleset/Ruleset.js +126 -0
- package/lib/Cloudflare/Ruleset/Ruleset.js.map +1 -0
- package/lib/Cloudflare/Ruleset/index.d.ts +2 -0
- package/lib/Cloudflare/Ruleset/index.d.ts.map +1 -0
- package/lib/Cloudflare/Ruleset/index.js +2 -0
- package/lib/Cloudflare/Ruleset/index.js.map +1 -0
- package/lib/Cloudflare/SecretsStore/Secret.d.ts +1 -0
- package/lib/Cloudflare/SecretsStore/Secret.d.ts.map +1 -1
- package/lib/Cloudflare/SecretsStore/Secret.js +2 -0
- package/lib/Cloudflare/SecretsStore/Secret.js.map +1 -1
- package/lib/Cloudflare/StateStore/State.d.ts +1 -1
- package/lib/Cloudflare/StateStore/State.d.ts.map +1 -1
- package/lib/Cloudflare/Website/StaticSite.d.ts +64 -12
- package/lib/Cloudflare/Website/StaticSite.d.ts.map +1 -1
- package/lib/Cloudflare/Website/StaticSite.js +80 -30
- package/lib/Cloudflare/Website/StaticSite.js.map +1 -1
- package/lib/Cloudflare/Website/Vite.d.ts +36 -7
- package/lib/Cloudflare/Website/Vite.d.ts.map +1 -1
- package/lib/Cloudflare/Website/Vite.js +26 -8
- package/lib/Cloudflare/Website/Vite.js.map +1 -1
- package/lib/Cloudflare/Workers/Assets.d.ts +10 -4
- package/lib/Cloudflare/Workers/Assets.d.ts.map +1 -1
- package/lib/Cloudflare/Workers/Assets.js +6 -6
- package/lib/Cloudflare/Workers/Assets.js.map +1 -1
- package/lib/Cloudflare/Workers/DurableObjectChatPersistence.d.ts +69 -0
- package/lib/Cloudflare/Workers/DurableObjectChatPersistence.d.ts.map +1 -0
- package/lib/Cloudflare/Workers/DurableObjectChatPersistence.js +104 -0
- package/lib/Cloudflare/Workers/DurableObjectChatPersistence.js.map +1 -0
- package/lib/Cloudflare/Workers/DynamicWorkerLoader.d.ts +4 -4
- package/lib/Cloudflare/Workers/InferEnv.d.ts +1 -1
- package/lib/Cloudflare/Workers/InferEnv.d.ts.map +1 -1
- package/lib/Cloudflare/Workers/LocalWorkerProvider.d.ts.map +1 -1
- package/lib/Cloudflare/Workers/LocalWorkerProvider.js +45 -11
- package/lib/Cloudflare/Workers/LocalWorkerProvider.js.map +1 -1
- package/lib/Cloudflare/Workers/RpcDurableObjectNamespace.d.ts +5 -4
- package/lib/Cloudflare/Workers/RpcDurableObjectNamespace.d.ts.map +1 -1
- package/lib/Cloudflare/Workers/RpcDurableObjectNamespace.js +4 -2
- package/lib/Cloudflare/Workers/RpcDurableObjectNamespace.js.map +1 -1
- package/lib/Cloudflare/Workers/RpcWorker.d.ts +3 -2
- package/lib/Cloudflare/Workers/RpcWorker.d.ts.map +1 -1
- package/lib/Cloudflare/Workers/RpcWorker.js +5 -3
- package/lib/Cloudflare/Workers/RpcWorker.js.map +1 -1
- package/lib/Cloudflare/Workers/VersionMetadata.d.ts +99 -0
- package/lib/Cloudflare/Workers/VersionMetadata.d.ts.map +1 -0
- package/lib/Cloudflare/Workers/VersionMetadata.js +65 -0
- package/lib/Cloudflare/Workers/VersionMetadata.js.map +1 -0
- package/lib/Cloudflare/Workers/VersionMetadataBinding.d.ts +35 -0
- package/lib/Cloudflare/Workers/VersionMetadataBinding.d.ts.map +1 -0
- package/lib/Cloudflare/Workers/VersionMetadataBinding.js +31 -0
- package/lib/Cloudflare/Workers/VersionMetadataBinding.js.map +1 -0
- package/lib/Cloudflare/Workers/Worker.d.ts +20 -19
- package/lib/Cloudflare/Workers/Worker.d.ts.map +1 -1
- package/lib/Cloudflare/Workers/Worker.js +23 -37
- package/lib/Cloudflare/Workers/Worker.js.map +1 -1
- package/lib/Cloudflare/Workers/WorkerAsyncBindings.d.ts.map +1 -1
- package/lib/Cloudflare/Workers/WorkerAsyncBindings.js +16 -0
- package/lib/Cloudflare/Workers/WorkerAsyncBindings.js.map +1 -1
- package/lib/Cloudflare/Workers/WorkerBinding.d.ts +3 -1
- package/lib/Cloudflare/Workers/WorkerBinding.d.ts.map +1 -1
- package/lib/Cloudflare/Workers/WorkerBinding.js.map +1 -1
- package/lib/Cloudflare/Workers/Workflow.d.ts +8 -1
- package/lib/Cloudflare/Workers/Workflow.d.ts.map +1 -1
- package/lib/Cloudflare/Workers/Workflow.js +1 -0
- package/lib/Cloudflare/Workers/Workflow.js.map +1 -1
- package/lib/Cloudflare/Workers/WorkflowBridge.d.ts.map +1 -1
- package/lib/Cloudflare/Workers/WorkflowBridge.js +31 -2
- package/lib/Cloudflare/Workers/WorkflowBridge.js.map +1 -1
- package/lib/Cloudflare/Workers/index.d.ts +3 -0
- package/lib/Cloudflare/Workers/index.d.ts.map +1 -1
- package/lib/Cloudflare/Workers/index.js +3 -0
- package/lib/Cloudflare/Workers/index.js.map +1 -1
- package/lib/Cloudflare/Zaraz/ZarazConfig.d.ts.map +1 -1
- package/lib/Cloudflare/index.d.ts +1 -0
- package/lib/Cloudflare/index.d.ts.map +1 -1
- package/lib/Cloudflare/index.js +1 -0
- package/lib/Cloudflare/index.js.map +1 -1
- package/lib/Deploy.d.ts +3 -2
- package/lib/Deploy.d.ts.map +1 -1
- package/lib/Deploy.js.map +1 -1
- package/lib/Destroy.d.ts +3 -2
- package/lib/Destroy.d.ts.map +1 -1
- package/lib/Destroy.js.map +1 -1
- package/lib/Diff.d.ts.map +1 -1
- package/lib/Diff.js +7 -0
- package/lib/Diff.js.map +1 -1
- package/lib/Drizzle/Postgres.d.ts +13 -12
- package/lib/Drizzle/Postgres.d.ts.map +1 -1
- package/lib/Drizzle/Postgres.js +13 -12
- package/lib/Drizzle/Postgres.js.map +1 -1
- package/lib/Drizzle/Schema.d.ts +1 -1
- package/lib/Drizzle/Schema.d.ts.map +1 -1
- package/lib/Drizzle/Schema.js +20 -9
- package/lib/Drizzle/Schema.js.map +1 -1
- package/lib/Local/RpcSerialization.js +5 -2
- package/lib/Local/RpcSerialization.js.map +1 -1
- package/lib/Output.d.ts.map +1 -1
- package/lib/Output.js +11 -10
- package/lib/Output.js.map +1 -1
- package/lib/Plan.d.ts.map +1 -1
- package/lib/Plan.js +5 -1
- package/lib/Plan.js.map +1 -1
- package/lib/Planetscale/MySQL/MySQLDatabase.d.ts +0 -2
- package/lib/Planetscale/MySQL/MySQLDatabase.d.ts.map +1 -1
- package/lib/Planetscale/MySQL/MySQLDatabase.js +1 -3
- package/lib/Planetscale/MySQL/MySQLDatabase.js.map +1 -1
- package/lib/Planetscale/Postgres/PostgresDatabase.d.ts +0 -2
- package/lib/Planetscale/Postgres/PostgresDatabase.d.ts.map +1 -1
- package/lib/Planetscale/Postgres/PostgresDatabase.js +1 -3
- package/lib/Planetscale/Postgres/PostgresDatabase.js.map +1 -1
- package/lib/Platform.d.ts +4 -4
- package/lib/Platform.d.ts.map +1 -1
- package/lib/Platform.js +27 -25
- package/lib/Platform.js.map +1 -1
- package/lib/Resource.d.ts +7 -1
- package/lib/Resource.d.ts.map +1 -1
- package/lib/Resource.js +11 -12
- package/lib/Resource.js.map +1 -1
- package/lib/Runtime.d.ts +1 -1
- package/lib/Runtime.d.ts.map +1 -1
- package/lib/Runtime.js +3 -4
- package/lib/Runtime.js.map +1 -1
- package/lib/Stack.d.ts +5 -4
- package/lib/Stack.d.ts.map +1 -1
- package/lib/Stack.js.map +1 -1
- package/lib/Test/Core.d.ts +2 -2
- package/lib/Test/Core.d.ts.map +1 -1
- package/lib/Util/effect.d.ts.map +1 -1
- package/lib/Util/effect.js +13 -15
- package/lib/Util/effect.js.map +1 -1
- package/lib/Util/poll.d.ts +0 -1
- package/lib/Util/poll.d.ts.map +1 -1
- package/lib/Util/poll.js +2 -2
- package/lib/Util/poll.js.map +1 -1
- package/lib/tsconfig.test.tsbuildinfo +1 -1
- package/package.json +20 -20
- package/src/AWS/Lambda/BucketEventSource.ts +16 -1
- package/src/AWS/S3/Bucket.ts +78 -0
- package/src/AWS/S3/BucketNotifications.ts +10 -0
- package/src/Apply.ts +22 -3
- package/src/Auth/AuthProvider.ts +1 -1
- package/src/Binding.ts +45 -38
- package/src/Build/DevServer.ts +330 -0
- package/src/Build/Local.ts +4 -0
- package/src/Bundle/Bundle.ts +1 -1
- package/src/Cloudflare/Access.ts +1 -1
- package/src/Cloudflare/AiGateway/AiGateway.ts +1 -1
- package/src/Cloudflare/AiGateway/AiGatewayBinding.ts +8 -3
- package/src/Cloudflare/Browser/Browser.ts +84 -12
- package/src/Cloudflare/Browser/BrowserBinding.ts +205 -33
- package/src/Cloudflare/Browser/index.ts +15 -2
- package/src/Cloudflare/Container/ContainerBinding.ts +5 -10
- package/src/Cloudflare/Images/Images.ts +4 -3
- package/src/Cloudflare/Providers.ts +8 -0
- package/src/Cloudflare/RateLimit/RateLimit.ts +4 -3
- package/src/Cloudflare/Ruleset/Ruleset.ts +223 -0
- package/src/Cloudflare/Ruleset/index.ts +1 -0
- package/src/Cloudflare/SecretsStore/Secret.ts +4 -0
- package/src/Cloudflare/Website/StaticSite.ts +154 -41
- package/src/Cloudflare/Website/Vite.ts +73 -25
- package/src/Cloudflare/Workers/Assets.ts +10 -8
- package/src/Cloudflare/Workers/DurableObjectChatPersistence.ts +131 -0
- package/src/Cloudflare/Workers/DynamicWorkerLoader.ts +4 -4
- package/src/Cloudflare/Workers/InferEnv.ts +14 -12
- package/src/Cloudflare/Workers/LocalWorkerProvider.ts +54 -13
- package/src/Cloudflare/Workers/RpcDurableObjectNamespace.ts +11 -8
- package/src/Cloudflare/Workers/RpcWorker.ts +8 -7
- package/src/Cloudflare/Workers/VersionMetadata.ts +129 -0
- package/src/Cloudflare/Workers/VersionMetadataBinding.ts +82 -0
- package/src/Cloudflare/Workers/Worker.ts +66 -82
- package/src/Cloudflare/Workers/WorkerAsyncBindings.ts +14 -0
- package/src/Cloudflare/Workers/WorkerBinding.ts +4 -0
- package/src/Cloudflare/Workers/Workflow.ts +12 -1
- package/src/Cloudflare/Workers/WorkflowBridge.ts +47 -6
- package/src/Cloudflare/Workers/index.ts +3 -0
- package/src/Cloudflare/index.ts +1 -0
- package/src/Deploy.ts +2 -1
- package/src/Destroy.ts +2 -1
- package/src/Diff.ts +7 -0
- package/src/Drizzle/Postgres.ts +13 -12
- package/src/Drizzle/Schema.ts +27 -9
- package/src/Local/RpcSerialization.ts +5 -2
- package/src/Output.ts +12 -10
- package/src/Plan.ts +5 -1
- package/src/Planetscale/MySQL/MySQLDatabase.ts +1 -6
- package/src/Planetscale/Postgres/PostgresDatabase.ts +1 -5
- package/src/Platform.ts +48 -36
- package/src/Resource.ts +22 -13
- package/src/Runtime.ts +3 -7
- package/src/Stack.ts +11 -10
- package/src/Util/effect.ts +13 -17
- package/src/Util/poll.ts +3 -3
|
@@ -89,7 +89,7 @@ export const unwrapRpcHandlers = <T extends Record<string, any>>(
|
|
|
89
89
|
) as RpcUnwrapped<T>;
|
|
90
90
|
};
|
|
91
91
|
|
|
92
|
-
const serializeError = Schema.encodeSync(Schema.Defect);
|
|
92
|
+
const serializeError = Schema.encodeSync(Schema.Defect());
|
|
93
93
|
|
|
94
94
|
const wrapRpcEffectHandler = <Args extends Array<any>, Success, Error>(
|
|
95
95
|
handler: RpcEffectHandler<Args, Success, Error>,
|
|
@@ -107,7 +107,10 @@ const wrapRpcEffectHandler = <Args extends Array<any>, Success, Error>(
|
|
|
107
107
|
cause: exit.cause.reasons.map((reason): RpcSerializedCause<Error> => {
|
|
108
108
|
switch (reason._tag) {
|
|
109
109
|
case "Fail":
|
|
110
|
-
return {
|
|
110
|
+
return {
|
|
111
|
+
_tag: "Fail",
|
|
112
|
+
error: serializeError(reason.error) as Error,
|
|
113
|
+
};
|
|
111
114
|
case "Die":
|
|
112
115
|
return { _tag: "Die", defect: serializeError(reason.defect) };
|
|
113
116
|
case "Interrupt":
|
package/src/Output.ts
CHANGED
|
@@ -72,6 +72,8 @@ export type ToOutput<A, Req = never> = [Extract<A, object>] extends [never]
|
|
|
72
72
|
|
|
73
73
|
export const ExprSymbol = Symbol.for("alchemy/Expr");
|
|
74
74
|
|
|
75
|
+
const exprKind = (node: any): unknown => node?.[ExprSymbol]?.kind ?? node?.kind;
|
|
76
|
+
|
|
75
77
|
export const isExpr = (value: any): value is Expr<any> =>
|
|
76
78
|
value &&
|
|
77
79
|
(typeof value === "object" || typeof value === "function") &&
|
|
@@ -145,7 +147,7 @@ export type ArrayExpr<A extends any[], Req = any> = Output<A, Req> & {
|
|
|
145
147
|
|
|
146
148
|
export const isResourceExpr = <Value = any, Req = any>(
|
|
147
149
|
node: Expr<Value, Req> | any,
|
|
148
|
-
): node is ResourceExpr<Value, Req> => node
|
|
150
|
+
): node is ResourceExpr<Value, Req> => exprKind(node) === "ResourceExpr";
|
|
149
151
|
|
|
150
152
|
export class ResourceExpr<Value, Req = never> extends BaseExpr<Value, Req> {
|
|
151
153
|
readonly kind = "ResourceExpr";
|
|
@@ -163,7 +165,7 @@ export class ResourceExpr<Value, Req = never> extends BaseExpr<Value, Req> {
|
|
|
163
165
|
|
|
164
166
|
export const isPropExpr = <A = any, Prop extends keyof A = keyof A, Req = any>(
|
|
165
167
|
node: any,
|
|
166
|
-
): node is PropExpr<A, Prop, Req> => node
|
|
168
|
+
): node is PropExpr<A, Prop, Req> => exprKind(node) === "PropExpr";
|
|
167
169
|
|
|
168
170
|
export class PropExpr<
|
|
169
171
|
A = any,
|
|
@@ -186,7 +188,7 @@ export class PropExpr<
|
|
|
186
188
|
export const literal = <A>(value: A) => new LiteralExpr(value);
|
|
187
189
|
|
|
188
190
|
export const isLiteralExpr = <A = any>(node: any): node is LiteralExpr<A> =>
|
|
189
|
-
node
|
|
191
|
+
exprKind(node) === "LiteralExpr";
|
|
190
192
|
|
|
191
193
|
export class LiteralExpr<A> extends BaseExpr<A, never> {
|
|
192
194
|
readonly kind = "LiteralExpr";
|
|
@@ -217,7 +219,7 @@ export const map: {
|
|
|
217
219
|
//Output.ApplyExpr<any, any, ResourceLike, any>
|
|
218
220
|
export const isApplyExpr = <In = any, Out = any, Req = any>(
|
|
219
221
|
node: Output<Out, Req>,
|
|
220
|
-
): node is ApplyExpr<In, Out, Req> => node
|
|
222
|
+
): node is ApplyExpr<In, Out, Req> => exprKind(node) === "ApplyExpr";
|
|
221
223
|
|
|
222
224
|
export class ApplyExpr<A, B, Req = never> extends BaseExpr<B, Req> {
|
|
223
225
|
readonly kind = "ApplyExpr";
|
|
@@ -259,7 +261,7 @@ export const flatMap: {
|
|
|
259
261
|
|
|
260
262
|
export const isFlatMapExpr = <In = any, Out = any, Req = any, Req2 = any>(
|
|
261
263
|
node: any,
|
|
262
|
-
): node is FlatMapExpr<In, Out, Req, Req2> => node
|
|
264
|
+
): node is FlatMapExpr<In, Out, Req, Req2> => exprKind(node) === "FlatMapExpr";
|
|
263
265
|
|
|
264
266
|
export class FlatMapExpr<A, B, Req = never, Req2 = never> extends BaseExpr<
|
|
265
267
|
B,
|
|
@@ -280,7 +282,7 @@ export class FlatMapExpr<A, B, Req = never, Req2 = never> extends BaseExpr<
|
|
|
280
282
|
|
|
281
283
|
export const isEffectExpr = <In = any, Out = any, Req = any, Req2 = any>(
|
|
282
284
|
node: any,
|
|
283
|
-
): node is EffectExpr<In, Out, Req, Req2> => node
|
|
285
|
+
): node is EffectExpr<In, Out, Req, Req2> => exprKind(node) === "EffectExpr";
|
|
284
286
|
|
|
285
287
|
export class EffectExpr<A, B, Req = never, Req2 = never> extends BaseExpr<
|
|
286
288
|
B,
|
|
@@ -301,7 +303,7 @@ export class EffectExpr<A, B, Req = never, Req2 = never> extends BaseExpr<
|
|
|
301
303
|
|
|
302
304
|
export const isNamedExpr = <A = any, Req = any>(
|
|
303
305
|
node: any,
|
|
304
|
-
): node is NamedExpr<A, Req> => node
|
|
306
|
+
): node is NamedExpr<A, Req> => exprKind(node) === "NamedExpr";
|
|
305
307
|
|
|
306
308
|
/**
|
|
307
309
|
* Wraps another `Expr` and overrides its `toString()` / inspect output.
|
|
@@ -352,7 +354,7 @@ type Tuple<
|
|
|
352
354
|
|
|
353
355
|
export const isAllExpr = <Outs extends Expr[] = Expr[]>(
|
|
354
356
|
node: any,
|
|
355
|
-
): node is AllExpr<Outs> => node
|
|
357
|
+
): node is AllExpr<Outs> => exprKind(node) === "AllExpr";
|
|
356
358
|
|
|
357
359
|
export class AllExpr<Outs extends Expr[]> extends BaseExpr<Outs> {
|
|
358
360
|
readonly kind = "AllExpr";
|
|
@@ -366,7 +368,7 @@ export class AllExpr<Outs extends Expr[]> extends BaseExpr<Outs> {
|
|
|
366
368
|
}
|
|
367
369
|
|
|
368
370
|
export const isRefExpr = <A = any>(node: any): node is RefExpr<A> =>
|
|
369
|
-
node
|
|
371
|
+
exprKind(node) === "RefExpr";
|
|
370
372
|
|
|
371
373
|
export class RefExpr<A> extends BaseExpr<A, never> {
|
|
372
374
|
readonly kind = "RefExpr";
|
|
@@ -384,7 +386,7 @@ export class RefExpr<A> extends BaseExpr<A, never> {
|
|
|
384
386
|
}
|
|
385
387
|
|
|
386
388
|
export const isStackRefExpr = <A = any>(node: any): node is StackRefExpr<A> =>
|
|
387
|
-
node
|
|
389
|
+
exprKind(node) === "StackRefExpr";
|
|
388
390
|
|
|
389
391
|
/**
|
|
390
392
|
* A reference to the persisted output of a Stack at `(stack, stage)`.
|
package/src/Plan.ts
CHANGED
|
@@ -714,7 +714,10 @@ export const make = <A>(
|
|
|
714
714
|
.pipe(providePlanScope(fqn, adoptInstanceId));
|
|
715
715
|
if (readResult !== undefined) {
|
|
716
716
|
const isUnowned = Unowned.is(readResult);
|
|
717
|
-
|
|
717
|
+
// A resource-scoped `adopt(...)` (captured on the resource at
|
|
718
|
+
// registration) overrides the stack/CLI default.
|
|
719
|
+
const adoptThis = resource.Adopt ?? (yield* shouldAdopt);
|
|
720
|
+
if (isUnowned && !adoptThis) {
|
|
718
721
|
return yield* new OwnedBySomeoneElse({
|
|
719
722
|
message:
|
|
720
723
|
`Cannot adopt resource '${fqn}' (${resource.Type}): ` +
|
|
@@ -1229,6 +1232,7 @@ export const make = <A>(
|
|
|
1229
1232
|
Binding: undefined!,
|
|
1230
1233
|
Provider: Provider(resourceType),
|
|
1231
1234
|
RemovalPolicy: oldState.removalPolicy,
|
|
1235
|
+
Adopt: undefined,
|
|
1232
1236
|
RuntimeContext: undefined!,
|
|
1233
1237
|
Providers: undefined,
|
|
1234
1238
|
} as ResourceLike,
|
|
@@ -66,9 +66,6 @@ export interface MySQLDatabaseProps extends BaseDatabaseProps {
|
|
|
66
66
|
* Output attributes of a deployed MySQL PlanetScale database.
|
|
67
67
|
*/
|
|
68
68
|
export interface MySQLDatabaseAttributes extends BaseDatabaseAttributes {
|
|
69
|
-
/** Engine kind discriminator. */
|
|
70
|
-
kind: "mysql";
|
|
71
|
-
|
|
72
69
|
/**
|
|
73
70
|
* Whether to copy migration data to new branches and in deploy requests.
|
|
74
71
|
*/
|
|
@@ -177,7 +174,7 @@ export const MySQLDatabaseProvider = () =>
|
|
|
177
174
|
const createBr = yield* ops.createBranch;
|
|
178
175
|
|
|
179
176
|
return {
|
|
180
|
-
stables: ["id", "organization", "
|
|
177
|
+
stables: ["id", "organization", "region"],
|
|
181
178
|
|
|
182
179
|
diff: Effect.fn(function* ({ news, olds, output }) {
|
|
183
180
|
if (!isResolved(news)) return undefined;
|
|
@@ -249,7 +246,6 @@ export const MySQLDatabaseProvider = () =>
|
|
|
249
246
|
output?.migrationsTable ?? olds?.migrationsTable,
|
|
250
247
|
migrationsHashes: output?.migrationsHashes ?? {},
|
|
251
248
|
importHashes: output?.importHashes ?? {},
|
|
252
|
-
kind: "mysql" as const,
|
|
253
249
|
clusterSize: output?.clusterSize ?? "",
|
|
254
250
|
requireApprovalForDeploy:
|
|
255
251
|
data.require_approval_for_deploy ?? false,
|
|
@@ -415,7 +411,6 @@ export const MySQLDatabaseProvider = () =>
|
|
|
415
411
|
updatedAt: updated.updated_at,
|
|
416
412
|
htmlUrl: updated.html_url,
|
|
417
413
|
region: { slug: updated.region.slug },
|
|
418
|
-
kind: "mysql" as const,
|
|
419
414
|
clusterSize,
|
|
420
415
|
migrationsDir: news.migrationsDir,
|
|
421
416
|
migrationsTable: news.migrationsDir ? migrationsTable : undefined,
|
|
@@ -53,8 +53,6 @@ export interface PostgresDatabaseProps extends BaseDatabaseProps {
|
|
|
53
53
|
* Output attributes of a deployed PostgreSQL PlanetScale database.
|
|
54
54
|
*/
|
|
55
55
|
export interface PostgresDatabaseAttributes extends BaseDatabaseAttributes {
|
|
56
|
-
/** Engine kind discriminator. */
|
|
57
|
-
kind: "postgresql";
|
|
58
56
|
/** PostgreSQL CPU architecture. */
|
|
59
57
|
arch: "x86" | "arm";
|
|
60
58
|
}
|
|
@@ -125,7 +123,7 @@ export const PostgresDatabaseProvider = () =>
|
|
|
125
123
|
const createBr = yield* ops.createBranch;
|
|
126
124
|
|
|
127
125
|
return {
|
|
128
|
-
stables: ["id", "organization", "
|
|
126
|
+
stables: ["id", "organization", "region"],
|
|
129
127
|
|
|
130
128
|
diff: Effect.fn(function* ({ news, olds, output }) {
|
|
131
129
|
if (!isResolved(news)) return undefined;
|
|
@@ -222,7 +220,6 @@ export const PostgresDatabaseProvider = () =>
|
|
|
222
220
|
migrationsTable: output?.migrationsTable ?? olds?.migrationsTable,
|
|
223
221
|
migrationsHashes: output?.migrationsHashes ?? {},
|
|
224
222
|
importHashes: output?.importHashes ?? {},
|
|
225
|
-
kind: "postgresql" as const,
|
|
226
223
|
clusterSize,
|
|
227
224
|
arch,
|
|
228
225
|
requireApprovalForDeploy: data.require_approval_for_deploy ?? false,
|
|
@@ -378,7 +375,6 @@ export const PostgresDatabaseProvider = () =>
|
|
|
378
375
|
updatedAt: updated.updated_at,
|
|
379
376
|
htmlUrl: updated.html_url,
|
|
380
377
|
region: { slug: updated.region.slug },
|
|
381
|
-
kind: "postgresql" as const,
|
|
382
378
|
clusterSize: clusterSize,
|
|
383
379
|
migrationsDir: news.migrationsDir,
|
|
384
380
|
migrationsTable: news.migrationsDir ? migrationsTable : undefined,
|
package/src/Platform.ts
CHANGED
|
@@ -2,13 +2,12 @@ import * as ConfigError from "effect/Config";
|
|
|
2
2
|
import * as ConfigProvider from "effect/ConfigProvider";
|
|
3
3
|
import * as Context from "effect/Context";
|
|
4
4
|
import * as Effect from "effect/Effect";
|
|
5
|
-
import
|
|
5
|
+
import * as Effectable from "effect/Effectable";
|
|
6
6
|
import * as Layer from "effect/Layer";
|
|
7
7
|
import * as Option from "effect/Option";
|
|
8
8
|
import * as Redacted from "effect/Redacted";
|
|
9
9
|
import type { Scope } from "effect/Scope";
|
|
10
10
|
import type { HttpClient } from "effect/unstable/http/HttpClient";
|
|
11
|
-
import { SingleShotGen } from "effect/Utils";
|
|
12
11
|
import type { PolicyLike } from "./Binding.ts";
|
|
13
12
|
import type { Dependencies } from "./Dependencies.ts";
|
|
14
13
|
import type { ExecutionContext } from "./ExecutionContext.ts";
|
|
@@ -76,7 +75,11 @@ export interface Platform<
|
|
|
76
75
|
id: string,
|
|
77
76
|
props:
|
|
78
77
|
| InputProps<Resource["Props"]>
|
|
79
|
-
| Effect.Effect<
|
|
78
|
+
| Effect.Effect<
|
|
79
|
+
InputProps<Resource["Props"]>,
|
|
80
|
+
ConfigError.ConfigError,
|
|
81
|
+
PropsReq
|
|
82
|
+
>,
|
|
80
83
|
): Effect.Effect<
|
|
81
84
|
Resource & Rpc<Self> & Dependencies<Deps>,
|
|
82
85
|
never,
|
|
@@ -103,7 +106,7 @@ export interface Platform<
|
|
|
103
106
|
id: string,
|
|
104
107
|
props:
|
|
105
108
|
| InputProps<Resource["Props"]>
|
|
106
|
-
| Effect.Effect<Resource["Props"],
|
|
109
|
+
| Effect.Effect<Resource["Props"], ConfigError.ConfigError, PropsReq>,
|
|
107
110
|
impl: Effect.Effect<Shape, ConfigError.ConfigError, InitReq>,
|
|
108
111
|
): Effect.Effect<
|
|
109
112
|
Resource & Rpc<Self>,
|
|
@@ -118,7 +121,11 @@ export interface Platform<
|
|
|
118
121
|
id: string,
|
|
119
122
|
props:
|
|
120
123
|
| InputProps<Resource["Props"]>
|
|
121
|
-
| Effect.Effect<
|
|
124
|
+
| Effect.Effect<
|
|
125
|
+
InputProps<Resource["Props"]>,
|
|
126
|
+
ConfigError.ConfigError,
|
|
127
|
+
PropsReq
|
|
128
|
+
>,
|
|
122
129
|
): Effect.Effect<
|
|
123
130
|
Resource & Rpc<Self>,
|
|
124
131
|
never,
|
|
@@ -134,7 +141,7 @@ export interface Platform<
|
|
|
134
141
|
>;
|
|
135
142
|
new (_: never): MakeShape<Shape, BaseShape>;
|
|
136
143
|
} & (<InitReq extends Services | PlatformServices | Resource = never>(
|
|
137
|
-
impl: Effect.Effect<Shape,
|
|
144
|
+
impl: Effect.Effect<Shape, ConfigError.ConfigError, InitReq>,
|
|
138
145
|
) => Effect.Effect<
|
|
139
146
|
Resource & Rpc<Self>,
|
|
140
147
|
never,
|
|
@@ -217,7 +224,7 @@ export const Platform = <
|
|
|
217
224
|
constructor(id, props, impl, true);
|
|
218
225
|
} else if (!impl) {
|
|
219
226
|
const cls = makeClass(id, props);
|
|
220
|
-
const
|
|
227
|
+
const evaluate = () =>
|
|
221
228
|
(!isTag
|
|
222
229
|
? // this is a non-tagged resource yielded without providing an implementation
|
|
223
230
|
// e.g.
|
|
@@ -264,7 +271,7 @@ export const Platform = <
|
|
|
264
271
|
);
|
|
265
272
|
return Object.assign(
|
|
266
273
|
function (impl: Impl) {
|
|
267
|
-
return cls.
|
|
274
|
+
return cls.Self.pipe(Effect.provide(cls.make(impl)));
|
|
268
275
|
},
|
|
269
276
|
// we splice in the Effect so this can be yielded to indicate a non-Effect native instance
|
|
270
277
|
// e.g. here, we yield it - in this case we don't want to provide an implementation
|
|
@@ -272,42 +279,29 @@ export const Platform = <
|
|
|
272
279
|
// main: "./src/worker.ts"
|
|
273
280
|
// });
|
|
274
281
|
cls,
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
|
|
282
|
+
// Spread the Effect prototype LAST so it overrides the evaluate copied
|
|
283
|
+
// from `cls`: yielding this no-impl form bridges to the (possibly
|
|
284
|
+
// non-Effect-native) resource rather than resolving the Self tag.
|
|
285
|
+
Effectable.Prototype({
|
|
286
|
+
label: `${type}<${id}>`,
|
|
287
|
+
evaluate,
|
|
288
|
+
}),
|
|
281
289
|
);
|
|
282
290
|
} else {
|
|
283
291
|
// impl was provided inline, this is a non-tagged eager instance
|
|
284
292
|
// e.g.
|
|
285
293
|
// export default Cloudflare.Worker("id", { main: "./src/worker.ts" }, Effect.gen(function* () { .. })
|
|
286
294
|
const cls = makeClass(id, props);
|
|
287
|
-
return cls.
|
|
295
|
+
return cls.Self.pipe(Effect.provide(cls.make(impl)), effectClass);
|
|
288
296
|
}
|
|
289
297
|
};
|
|
290
298
|
|
|
291
299
|
const makeClass = (id: string, props: Props) => {
|
|
292
|
-
|
|
300
|
+
class Platform {
|
|
293
301
|
static readonly Self = Self(`${type}<${id}>`);
|
|
294
302
|
static readonly Platform = Context.Service<Platform, Platform>(
|
|
295
303
|
`Platform<${type}<${id}>>`,
|
|
296
304
|
);
|
|
297
|
-
static [Symbol.iterator](): Iterator<
|
|
298
|
-
Effect.Effect<void, never, Self>,
|
|
299
|
-
Resource,
|
|
300
|
-
void
|
|
301
|
-
> {
|
|
302
|
-
return new SingleShotGen(this.asEffect()) as any;
|
|
303
|
-
}
|
|
304
|
-
static asEffect() {
|
|
305
|
-
return this.Self;
|
|
306
|
-
}
|
|
307
|
-
static pipe(...args: any[]) {
|
|
308
|
-
// @ts-expect-error
|
|
309
|
-
return pipe(this, ...args);
|
|
310
|
-
}
|
|
311
305
|
static of = (shape: any) => shape;
|
|
312
306
|
static make = (impl: Impl) => {
|
|
313
307
|
// build the Layer once for the root Self
|
|
@@ -452,13 +446,31 @@ export const Platform = <
|
|
|
452
446
|
SelfLayer,
|
|
453
447
|
);
|
|
454
448
|
};
|
|
455
|
-
}
|
|
449
|
+
}
|
|
450
|
+
// Make the platform class itself a real Effect: `yield* MyWorker` resolves
|
|
451
|
+
// the Self tag. Replaces the hand-rolled asEffect/pipe/[Symbol.iterator].
|
|
452
|
+
return Object.assign(
|
|
453
|
+
Platform,
|
|
454
|
+
Effectable.Prototype({
|
|
455
|
+
label: `${type}<${id}>`,
|
|
456
|
+
evaluate: () => Platform.Self,
|
|
457
|
+
}),
|
|
458
|
+
);
|
|
456
459
|
};
|
|
457
460
|
|
|
458
|
-
const instance = Object.assign(
|
|
459
|
-
|
|
460
|
-
|
|
461
|
-
|
|
462
|
-
|
|
461
|
+
const instance = Object.assign(
|
|
462
|
+
constructor,
|
|
463
|
+
resource,
|
|
464
|
+
// Spread the Effect prototype LAST so it overrides any evaluate inherited
|
|
465
|
+
// from `resource`; `yield* Cloudflare.Worker` resolves the resource Self.
|
|
466
|
+
Effectable.Prototype({
|
|
467
|
+
label: `${type}`,
|
|
468
|
+
evaluate: () => resource.Self,
|
|
469
|
+
}),
|
|
470
|
+
{
|
|
471
|
+
Platform: Platform,
|
|
472
|
+
...methods,
|
|
473
|
+
},
|
|
474
|
+
) as any;
|
|
463
475
|
return instance;
|
|
464
476
|
};
|
package/src/Resource.ts
CHANGED
|
@@ -1,7 +1,8 @@
|
|
|
1
1
|
import * as Effect from "effect/Effect";
|
|
2
|
+
import * as Effectable from "effect/Effectable";
|
|
2
3
|
import * as Option from "effect/Option";
|
|
3
|
-
import {
|
|
4
|
-
import {
|
|
4
|
+
import type { Pipeable } from "effect/Pipeable";
|
|
5
|
+
import { AdoptPolicy } from "./AdoptPolicy.ts";
|
|
5
6
|
import { toFqn } from "./FQN.ts";
|
|
6
7
|
import type { Input, InputProps } from "./Input.ts";
|
|
7
8
|
import { CurrentNamespace, type NamespaceNode } from "./Namespace.ts";
|
|
@@ -106,6 +107,12 @@ export interface ResourceLike<
|
|
|
106
107
|
* Removal Policy of the Resource.
|
|
107
108
|
*/
|
|
108
109
|
RemovalPolicy: RemovalPolicy["Service"];
|
|
110
|
+
/**
|
|
111
|
+
* Per-resource adoption policy captured from the ambient {@link AdoptPolicy}
|
|
112
|
+
* at registration time (e.g. via `.pipe(adopt(true))`). `undefined` means no
|
|
113
|
+
* resource-scoped override — the planner falls back to the stack/CLI default.
|
|
114
|
+
*/
|
|
115
|
+
Adopt: boolean | undefined;
|
|
109
116
|
/** @internal phantom */
|
|
110
117
|
Attributes: Attributes;
|
|
111
118
|
/** @internal phantom */
|
|
@@ -246,6 +253,9 @@ export function Resource<R extends ResourceLike>(
|
|
|
246
253
|
RemovalPolicy: yield* Effect.serviceOption(RemovalPolicy).pipe(
|
|
247
254
|
Effect.map(Option.getOrElse(() => defaultRemovalPolicy)),
|
|
248
255
|
),
|
|
256
|
+
Adopt: yield* Effect.serviceOption(AdoptPolicy).pipe(
|
|
257
|
+
Effect.map(Option.getOrUndefined),
|
|
258
|
+
),
|
|
249
259
|
bind,
|
|
250
260
|
toString(this: typeof target) {
|
|
251
261
|
return `Resource<${this.Type}>(${this.LogicalId})`;
|
|
@@ -277,17 +287,6 @@ export function Resource<R extends ResourceLike>(
|
|
|
277
287
|
const ProviderTag = Provider(type);
|
|
278
288
|
|
|
279
289
|
const Service = {
|
|
280
|
-
[Symbol.iterator]() {
|
|
281
|
-
return new SingleShotGen(this.asEffect());
|
|
282
|
-
},
|
|
283
|
-
pipe() {
|
|
284
|
-
return pipeArguments(this, arguments);
|
|
285
|
-
},
|
|
286
|
-
asEffect() {
|
|
287
|
-
return Effect.succeed((id: string, props: R["Props"]) =>
|
|
288
|
-
constructor(id, props),
|
|
289
|
-
);
|
|
290
|
-
},
|
|
291
290
|
/**
|
|
292
291
|
* Build a typed reference to a deployed instance of this resource
|
|
293
292
|
* — in the current stack/stage by default, or in another via
|
|
@@ -313,6 +312,16 @@ export function Resource<R extends ResourceLike>(
|
|
|
313
312
|
? Object.assign(ResourceClass, args[0])
|
|
314
313
|
: constructor(...(args as [string, R["Props"]])),
|
|
315
314
|
Service,
|
|
315
|
+
// Make the constructor itself a real Effect: `yield* MyResource` resolves
|
|
316
|
+
// to the constructor function (same as the old `asEffect()`), and
|
|
317
|
+
// `Effect.isEffect(MyResource)` is now true so `Effect.all`/`forEach` work.
|
|
318
|
+
Effectable.Prototype({
|
|
319
|
+
label: `Resource<${type}>`,
|
|
320
|
+
evaluate: () =>
|
|
321
|
+
Effect.succeed((id: string, props: R["Props"]) =>
|
|
322
|
+
constructor(id, props),
|
|
323
|
+
),
|
|
324
|
+
}),
|
|
316
325
|
) as any;
|
|
317
326
|
|
|
318
327
|
return ResourceClass;
|
package/src/Runtime.ts
CHANGED
|
@@ -7,6 +7,7 @@
|
|
|
7
7
|
*/
|
|
8
8
|
|
|
9
9
|
import * as Layer from "effect/Layer";
|
|
10
|
+
import { asEffect } from "./Util/types.ts";
|
|
10
11
|
|
|
11
12
|
/**
|
|
12
13
|
* Resolve the user's default-export entrypoint into a `Layer` for the
|
|
@@ -14,7 +15,7 @@ import * as Layer from "effect/Layer";
|
|
|
14
15
|
*
|
|
15
16
|
* `entrypoint` may be any of:
|
|
16
17
|
* - a `Layer` factory (`{ build: (...) => ... }`) — used as-is
|
|
17
|
-
* - an
|
|
18
|
+
* - an Alchemy `Platform`/`Worker` construct (now a real `Effect`)
|
|
18
19
|
* - a plain `Effect`
|
|
19
20
|
*
|
|
20
21
|
* Centralized so the inline ternary doesn't have to be re-emitted into
|
|
@@ -29,10 +30,5 @@ export const makeEntrypointLayer = (
|
|
|
29
30
|
if (typeof entrypoint?.build === "function") {
|
|
30
31
|
return entrypoint;
|
|
31
32
|
}
|
|
32
|
-
return Layer.effect(
|
|
33
|
-
tag,
|
|
34
|
-
typeof entrypoint?.asEffect === "function"
|
|
35
|
-
? entrypoint.asEffect()
|
|
36
|
-
: entrypoint,
|
|
37
|
-
);
|
|
33
|
+
return Layer.effect(tag, asEffect(entrypoint));
|
|
38
34
|
};
|
package/src/Stack.ts
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import type { ConfigError } from "effect/Config";
|
|
1
2
|
import { ConfigProvider } from "effect/ConfigProvider";
|
|
2
3
|
import * as Context from "effect/Context";
|
|
3
4
|
import * as Effect from "effect/Effect";
|
|
@@ -77,16 +78,16 @@ export const Stack: Context.ServiceClass<
|
|
|
77
78
|
},
|
|
78
79
|
effect: Effect.Effect<
|
|
79
80
|
NoInfer<A extends object ? InputProps<A> : Input<A>>,
|
|
80
|
-
|
|
81
|
+
ConfigError,
|
|
81
82
|
Req
|
|
82
83
|
>,
|
|
83
|
-
): Effect.Effect<CompiledStack<A
|
|
84
|
+
): Effect.Effect<CompiledStack<A>, ConfigError>;
|
|
84
85
|
<Self>(): {
|
|
85
86
|
<A, Req>(
|
|
86
87
|
stackName: string,
|
|
87
88
|
options: StackProps<NoInfer<Req>>,
|
|
88
|
-
eff: Effect.Effect<A,
|
|
89
|
-
): Effect.Effect<Self> & {
|
|
89
|
+
eff: Effect.Effect<A, ConfigError, Req>,
|
|
90
|
+
): Effect.Effect<Self, ConfigError> & {
|
|
90
91
|
new (_: never): A extends object ? A : {};
|
|
91
92
|
stage: {
|
|
92
93
|
[stage: string]: Effect.Effect<Self>;
|
|
@@ -99,8 +100,8 @@ export const Stack: Context.ServiceClass<
|
|
|
99
100
|
new (_: never): Output.ToOutput<Shape>;
|
|
100
101
|
make: <A, Req>(
|
|
101
102
|
options: StackProps<NoInfer<Req>>,
|
|
102
|
-
effect: Effect.Effect<A,
|
|
103
|
-
) => Effect.Effect<CompiledStack<A
|
|
103
|
+
effect: Effect.Effect<A, ConfigError, Req>,
|
|
104
|
+
) => Effect.Effect<CompiledStack<A>, ConfigError>;
|
|
104
105
|
stage: {
|
|
105
106
|
[stage: string]: Effect.Effect<Self>;
|
|
106
107
|
};
|
|
@@ -109,15 +110,15 @@ export const Stack: Context.ServiceClass<
|
|
|
109
110
|
<A, Req>(
|
|
110
111
|
stackName: string,
|
|
111
112
|
options: StackProps<NoInfer<Req>>,
|
|
112
|
-
eff: Effect.Effect<A,
|
|
113
|
-
): Effect.Effect<CompiledStack<A
|
|
113
|
+
eff: Effect.Effect<A, ConfigError, Req | StackServices>,
|
|
114
|
+
): Effect.Effect<CompiledStack<A>, ConfigError>;
|
|
114
115
|
} = Object.assign(
|
|
115
116
|
taggedFunction(
|
|
116
117
|
Context.Service<Stack, Omit<StackSpec, "output">>()("Stack"),
|
|
117
118
|
<A, Req>(
|
|
118
119
|
stackName?: string,
|
|
119
120
|
options?: StackProps<NoInfer<Req>>,
|
|
120
|
-
eff?: Effect.Effect<A,
|
|
121
|
+
eff?: Effect.Effect<A, ConfigError, Req>,
|
|
121
122
|
) => {
|
|
122
123
|
if (!stackName) {
|
|
123
124
|
return (stackName: string) =>
|
|
@@ -131,7 +132,7 @@ export const Stack: Context.ServiceClass<
|
|
|
131
132
|
providers: options?.providers,
|
|
132
133
|
make: <Req = never>(
|
|
133
134
|
options: StackProps<NoInfer<Req>>,
|
|
134
|
-
eff: Effect.Effect<A,
|
|
135
|
+
eff: Effect.Effect<A, ConfigError, Req>,
|
|
135
136
|
) => Stack(stackName, options, eff),
|
|
136
137
|
},
|
|
137
138
|
);
|
package/src/Util/effect.ts
CHANGED
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
import * as Context from "effect/Context";
|
|
2
2
|
import * as Effect from "effect/Effect";
|
|
3
|
-
import
|
|
4
|
-
import { SingleShotGen } from "effect/Utils";
|
|
3
|
+
import * as Effectable from "effect/Effectable";
|
|
5
4
|
|
|
6
5
|
export type EffectClass<Shape, A, Err = never, Req = never> = Effect.Effect<
|
|
7
6
|
A,
|
|
@@ -22,18 +21,15 @@ export const effectClass: {
|
|
|
22
21
|
impl === undefined
|
|
23
22
|
? (innerImpl: any) => effectClass(innerImpl)
|
|
24
23
|
: (Object.assign(
|
|
25
|
-
class {
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
}
|
|
35
|
-
},
|
|
36
|
-
impl,
|
|
24
|
+
class {},
|
|
25
|
+
// Spreading the Effect prototype onto the class (static side) makes the
|
|
26
|
+
// class itself a real Effect — `Effect.isEffect(X)` is true, so
|
|
27
|
+
// `Effect.all([X])` / `Effect.forEach` work — and subclasses
|
|
28
|
+
// (`class Y extends effectClass(impl)`) inherit the protocol statically.
|
|
29
|
+
Effectable.Prototype({
|
|
30
|
+
label: "alchemy/EffectClass",
|
|
31
|
+
evaluate: () => impl,
|
|
32
|
+
}),
|
|
37
33
|
) as unknown as EffectClass<any, any, any, any>)) as any;
|
|
38
34
|
|
|
39
35
|
export const taggedFunction = <
|
|
@@ -43,10 +39,10 @@ export const taggedFunction = <
|
|
|
43
39
|
tag: Tag,
|
|
44
40
|
fn: Fn,
|
|
45
41
|
): Tag & Fn => {
|
|
42
|
+
// The Proxy below forwards every Effect-protocol key to `tag` (already an
|
|
43
|
+
// Effect), so `asEffect`/`[Symbol.iterator]`/`pipe` need no explicit
|
|
44
|
+
// override — only `toString` diverges.
|
|
46
45
|
const overrides = {
|
|
47
|
-
asEffect: () => tag,
|
|
48
|
-
[Symbol.iterator]: () => tag[Symbol.iterator](),
|
|
49
|
-
pipe: (...fns: any[]) => pipeArguments(tag, fns as any),
|
|
50
46
|
toString: () => `${tag.toString()}.${fn.name}`,
|
|
51
47
|
};
|
|
52
48
|
|
package/src/Util/poll.ts
CHANGED
|
@@ -27,7 +27,6 @@ export const poll = Effect.fn("poll")(
|
|
|
27
27
|
effect: Effect.Effect<A, E, R>;
|
|
28
28
|
predicate: (value: A) => boolean;
|
|
29
29
|
schedule?: Schedule.Schedule<unknown, unknown, never>;
|
|
30
|
-
times?: number;
|
|
31
30
|
}) =>
|
|
32
31
|
input.effect.pipe(
|
|
33
32
|
Effect.filterOrFail(
|
|
@@ -40,8 +39,9 @@ export const poll = Effect.fn("poll")(
|
|
|
40
39
|
),
|
|
41
40
|
Effect.retry({
|
|
42
41
|
while: isPredicateFailed,
|
|
43
|
-
schedule:
|
|
44
|
-
|
|
42
|
+
schedule:
|
|
43
|
+
input.schedule ??
|
|
44
|
+
Schedule.both(Schedule.spaced("5 seconds"), Schedule.recurs(50)),
|
|
45
45
|
}),
|
|
46
46
|
),
|
|
47
47
|
);
|