chore: generate
This commit is contained in:
@@ -50,11 +50,7 @@ export function make<
|
|||||||
const T extends Tag | undefined = undefined,
|
const T extends Tag | undefined = undefined,
|
||||||
>(
|
>(
|
||||||
input: MakeInput<Implementation, Items, T>,
|
input: MakeInput<Implementation, Items, T>,
|
||||||
): Node<
|
): Node<Layer.Success<Implementation>, Layer.Error<Implementation> | Error<Items[number]>, T> {
|
||||||
Layer.Success<Implementation>,
|
|
||||||
Layer.Error<Implementation> | Error<Items[number]>,
|
|
||||||
T
|
|
||||||
> {
|
|
||||||
return {
|
return {
|
||||||
kind: "layer",
|
kind: "layer",
|
||||||
name: input.service !== undefined ? input.service.key : input.name,
|
name: input.service !== undefined ? input.service.key : input.name,
|
||||||
@@ -65,10 +61,7 @@ export function make<
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
export function unbound<R, Shape, const T extends Tag>(
|
export function unbound<R, Shape, const T extends Tag>(service: Context.Key<R, Shape>, tag: T): Node<R, never, T> {
|
||||||
service: Context.Key<R, Shape>,
|
|
||||||
tag: T,
|
|
||||||
): Node<R, never, T> {
|
|
||||||
return {
|
return {
|
||||||
kind: "unbound",
|
kind: "unbound",
|
||||||
name: service.key,
|
name: service.key,
|
||||||
@@ -100,16 +93,12 @@ export interface Tags<Config extends TagConfig> {
|
|||||||
) => <const Implementation extends Layer.Any, const Items extends NodeList>(
|
) => <const Implementation extends Layer.Any, const Items extends NodeList>(
|
||||||
input: DistributiveOmit<MakeInput<Implementation, Items, Tag<Name>>, "tag"> &
|
input: DistributiveOmit<MakeInput<Implementation, Items, Tag<Name>>, "tag"> &
|
||||||
CheckTags<Items, Name | Extract<Config[Name][number], string>>,
|
CheckTags<Items, Name | Extract<Config[Name][number], string>>,
|
||||||
) => Node<
|
) => Node<Layer.Success<Implementation>, Layer.Error<Implementation> | Error<Items[number]>, Tag<Name>>
|
||||||
Layer.Success<Implementation>,
|
|
||||||
Layer.Error<Implementation> | Error<Items[number]>,
|
|
||||||
Tag<Name>
|
|
||||||
>
|
|
||||||
}
|
}
|
||||||
|
|
||||||
export function tags<
|
export function tags<const Config extends { readonly [Name in keyof Config]: readonly (keyof Config & string)[] }>(
|
||||||
const Config extends { readonly [Name in keyof Config]: readonly (keyof Config & string)[] },
|
config: Config,
|
||||||
>(config: Config): Tags<Config> {
|
): Tags<Config> {
|
||||||
const names = Object.keys(config) as TagNames<Config>[]
|
const names = Object.keys(config) as TagNames<Config>[]
|
||||||
const values = Object.fromEntries(names.map((name) => [name, makeTag(name)])) as Tags<Config>["values"]
|
const values = Object.fromEntries(names.map((name) => [name, makeTag(name)])) as Tags<Config>["values"]
|
||||||
return {
|
return {
|
||||||
|
|||||||
@@ -311,10 +311,7 @@ export const layer = Layer.effect(
|
|||||||
.select({ seq: SessionMessageTable.seq })
|
.select({ seq: SessionMessageTable.seq })
|
||||||
.from(SessionMessageTable)
|
.from(SessionMessageTable)
|
||||||
.where(
|
.where(
|
||||||
and(
|
and(eq(SessionMessageTable.session_id, input.sessionID), eq(SessionMessageTable.id, input.cursor.id)),
|
||||||
eq(SessionMessageTable.session_id, input.sessionID),
|
|
||||||
eq(SessionMessageTable.id, input.cursor.id),
|
|
||||||
),
|
|
||||||
)
|
)
|
||||||
.get()
|
.get()
|
||||||
.pipe(Effect.orDie)
|
.pipe(Effect.orDie)
|
||||||
|
|||||||
@@ -16,8 +16,7 @@ class OtherError {
|
|||||||
|
|
||||||
const tags = LayerNode.tags({ app: [] })
|
const tags = LayerNode.tags({ app: [] })
|
||||||
const make = tags.make("app")
|
const make = tags.make("app")
|
||||||
const build = <A, E>(root: LayerNode.Node<A, E, any>) =>
|
const build = <A, E>(root: LayerNode.Node<A, E, any>) => LayerNodeTree.compile(root) as Layer.Layer<A, E>
|
||||||
LayerNodeTree.compile(root) as Layer.Layer<A, E>
|
|
||||||
const aLayer = Layer.succeed(A, A.of({}))
|
const aLayer = Layer.succeed(A, A.of({}))
|
||||||
const bLayer = Layer.effect(B, Effect.as(A, B.of({})))
|
const bLayer = Layer.effect(B, Effect.as(A, B.of({})))
|
||||||
const cLayer = Layer.effect(
|
const cLayer = Layer.effect(
|
||||||
|
|||||||
@@ -14,10 +14,10 @@ class App extends Context.Service<App, { readonly run: Effect.Effect<string[]> }
|
|||||||
const tags = LayerNode.tags({ app: [] })
|
const tags = LayerNode.tags({ app: [] })
|
||||||
const make = tags.make("app")
|
const make = tags.make("app")
|
||||||
const build = <A, E>(root: LayerNode.Node<A, E, any>, replacements?: readonly LayerNode.Replacement[]) =>
|
const build = <A, E>(root: LayerNode.Node<A, E, any>, replacements?: readonly LayerNode.Replacement[]) =>
|
||||||
LayerNodeTree.compile(
|
LayerNodeTree.compile(root, new Map(replacements?.map((item) => [item.source, item.replacement]))) as Layer.Layer<
|
||||||
root,
|
A,
|
||||||
new Map(replacements?.map((item) => [item.source, item.replacement])),
|
E
|
||||||
) as Layer.Layer<A, E>
|
>
|
||||||
const valueLayer = Layer.succeed(Value, Value.of({ value: "production" }))
|
const valueLayer = Layer.succeed(Value, Value.of({ value: "production" }))
|
||||||
const greetingLayer = Layer.effect(
|
const greetingLayer = Layer.effect(
|
||||||
Greeting,
|
Greeting,
|
||||||
|
|||||||
@@ -111,7 +111,9 @@ describe("LocationServiceMap", () => {
|
|||||||
}
|
}
|
||||||
}).pipe(
|
}).pipe(
|
||||||
Effect.scoped,
|
Effect.scoped,
|
||||||
Effect.provide(LocationServiceMap.Service.get(Location.Ref.make({ directory: AbsolutePath.make(directory) }))),
|
Effect.provide(
|
||||||
|
LocationServiceMap.Service.get(Location.Ref.make({ directory: AbsolutePath.make(directory) })),
|
||||||
|
),
|
||||||
)
|
)
|
||||||
|
|
||||||
const blockedState = yield* update(blocked.path)
|
const blockedState = yield* update(blocked.path)
|
||||||
|
|||||||
@@ -447,7 +447,11 @@ export const defaultLayer = layer.pipe(
|
|||||||
Layer.provide(locationServiceMapLayer),
|
Layer.provide(locationServiceMapLayer),
|
||||||
)
|
)
|
||||||
|
|
||||||
const locationServiceMapNode = LayerNode.make({ service: LocationServiceMap.Service, layer: locationServiceMapLayer, deps: [] })
|
const locationServiceMapNode = LayerNode.make({
|
||||||
|
service: LocationServiceMap.Service,
|
||||||
|
layer: locationServiceMapLayer,
|
||||||
|
deps: [],
|
||||||
|
})
|
||||||
|
|
||||||
export const node = LayerNode.make({
|
export const node = LayerNode.make({
|
||||||
service: Service,
|
service: Service,
|
||||||
|
|||||||
@@ -134,7 +134,11 @@ export const defaultLayer = layer.pipe(
|
|||||||
Layer.provide(locationServiceMapLayer),
|
Layer.provide(locationServiceMapLayer),
|
||||||
)
|
)
|
||||||
|
|
||||||
const locationServiceMapNode = LayerNode.make({ service: LocationServiceMap.Service, layer: locationServiceMapLayer, deps: [] })
|
const locationServiceMapNode = LayerNode.make({
|
||||||
|
service: LocationServiceMap.Service,
|
||||||
|
layer: locationServiceMapLayer,
|
||||||
|
deps: [],
|
||||||
|
})
|
||||||
|
|
||||||
export const node = LayerNode.make({
|
export const node = LayerNode.make({
|
||||||
service: Service,
|
service: Service,
|
||||||
|
|||||||
@@ -232,10 +232,7 @@ const fragmentFailureLLM = Layer.succeed(
|
|||||||
const fragmentFailureEnv = LayerNodeTree.compile(
|
const fragmentFailureEnv = LayerNodeTree.compile(
|
||||||
root,
|
root,
|
||||||
new Map(
|
new Map(
|
||||||
[...replacements, LayerNode.replace(LLM.layer, fragmentFailureLLM)].map((item) => [
|
[...replacements, LayerNode.replace(LLM.layer, fragmentFailureLLM)].map((item) => [item.source, item.replacement]),
|
||||||
item.source,
|
|
||||||
item.replacement,
|
|
||||||
]),
|
|
||||||
),
|
),
|
||||||
)
|
)
|
||||||
const itFragmentFailure = testEffect(fragmentFailureEnv)
|
const itFragmentFailure = testEffect(fragmentFailureEnv)
|
||||||
|
|||||||
@@ -45,7 +45,14 @@ function requestLayer(client: HttpClient.HttpClient) {
|
|||||||
function integrationLayer(client: HttpClient.HttpClient) {
|
function integrationLayer(client: HttpClient.HttpClient) {
|
||||||
const replacement = LayerNode.replace(FetchHttpClient.layer, Layer.succeed(HttpClient.HttpClient, client))
|
const replacement = LayerNode.replace(FetchHttpClient.layer, Layer.succeed(HttpClient.HttpClient, client))
|
||||||
return LayerNodeTree.compile(
|
return LayerNodeTree.compile(
|
||||||
LayerNode.group([ShareNext.node, EventV2Bridge.node, Session.node, SessionProjector.node, AccountRepo.node, Database.node]),
|
LayerNode.group([
|
||||||
|
ShareNext.node,
|
||||||
|
EventV2Bridge.node,
|
||||||
|
Session.node,
|
||||||
|
SessionProjector.node,
|
||||||
|
AccountRepo.node,
|
||||||
|
Database.node,
|
||||||
|
]),
|
||||||
new Map([[replacement.source, replacement.replacement]]),
|
new Map([[replacement.source, replacement.replacement]]),
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user