Skip to content

Commit aa18f3a

Browse files
committed
fix: Instance<Queue> maps to Queue instead of Resource<..>
1 parent 742c205 commit aa18f3a

File tree

2 files changed

+11
-30
lines changed

2 files changed

+11
-30
lines changed

@alchemy.run/effect/src/binding.ts

Lines changed: 4 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -37,13 +37,13 @@ export interface Binding<
3737
Cap extends Capability = Capability,
3838
Props = any,
3939
Tag extends string = Cap["type"],
40-
IsCustomTag extends boolean = Cap["type"] extends Tag ? false : true,
40+
IsCustom extends boolean = Cap["type"] extends Tag ? false : true,
4141
> {
4242
runtime: Run;
4343
capability: Cap;
4444
tag: Tag;
4545
props: Props;
46-
isCustomTag: IsCustomTag;
46+
isCustom: IsCustom;
4747
}
4848

4949
/** Tag for a Service that can bind a Capability to a Runtime */
@@ -64,23 +64,13 @@ export interface Bind<
6464
}
6565

6666
export const Binding: {
67-
<
68-
F extends (
69-
resource: any,
70-
props?: any,
71-
) => AnyBinding & { isCustomTag: true },
72-
>(
67+
<F extends (resource: any, props?: any) => AnyBinding & { isCustom: true }>(
7368
runtime: ReturnType<F>["runtime"],
7469
resource: new () => ReturnType<F>["capability"]["resource"],
7570
type: ReturnType<F>["capability"]["type"],
7671
tag: ReturnType<F>["tag"],
7772
): F & BindingDeclaration<ReturnType<F>["runtime"], F>;
78-
<
79-
F extends (
80-
resource: any,
81-
props?: any,
82-
) => AnyBinding & { isCustomTag: false },
83-
>(
73+
<F extends (resource: any, props?: any) => AnyBinding & { isCustom: false }>(
8474
runtime: ReturnType<F>["runtime"],
8575
resource: new () => ReturnType<F>["capability"]["resource"],
8676
type: ReturnType<F>["capability"]["type"],
@@ -122,17 +112,6 @@ export interface BindingDeclaration<
122112
};
123113
}
124114

125-
// <Self>(): Self =>
126-
// Object.assign(
127-
// Context.Tag(
128-
// `${capability.action}(${tag}, ${runtime})` as `${Cap["action"]}(${Tag}, ${Runtime})`,
129-
// )<Self, BindingService<Cap["resource"], Props>>(),
130-
// {
131-
// Kind: "Binding",
132-
// Capability: capability,
133-
// },
134-
// ) as Self;
135-
136115
export type BindingService<
137116
Target = any,
138117
R extends Resource = Resource,

@alchemy.run/effect/src/policy.ts

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -57,11 +57,13 @@ export function Policy(...bindings: AnyBinding[]): any {
5757
export const declare = <S extends Capability>() =>
5858
Effect.gen(function* () {}) as Effect.Effect<void, never, S>;
5959

60-
export type Instance<T> = { id: string } extends T
61-
? T
62-
: T extends new (...args: any) => infer I
63-
? I
64-
: never;
60+
export type Instance<T> = T extends { id: string }
61+
? string extends T["id"]
62+
? T
63+
: T extends new (...args: any) => infer I
64+
? I
65+
: never
66+
: never;
6567
// syntactic sugar for mapping `typeof Messages` -> Messages, e.g. so it's SQS.SendMessage<Messages> instead of SQS.SendMessage<typeof Messages>
6668
// e.g. <Q extends SQS.Queue>(queue: Q) => SQS.SendMessage<To<Q>>
6769
export type From<T> = Instance<T>;

0 commit comments

Comments
 (0)