layer-gate.ts
This file
Path
apps/platform/src/layer-gate.ts
42 lines · 1.2 KiB · TypeScript
Last changed by
Merge build/comments-platform into mainoscabrielbefore adoptionddf09e8
History of this fileTake it
12345678910111213141516171819202122232425262728293031323334353637383940414243import { RepoNotFound } from "@repo/artifacts/repo-host";import type { RepoName } from "@repo/artifacts/repo-host";import { Upstream } from "@repo/git/upstream";import type { LayerAccess } from "@repo/project/visibility-port";import type { LayerName, ProjectName } from "@repo/protocol/ids";import type { Principal } from "@repo/protocol/principal";import type { Option } from "effect";import { Context, Effect, Layer } from "effect";
export interface LayerTarget { readonly layer: LayerName; readonly project: ProjectName;}
export interface LayerReach { readonly access: LayerAccess; readonly target: LayerTarget;}
export interface LayerGatePort { readonly classify: ( repo: RepoName, who: Principal ) => Effect.Effect<Option.Option<LayerReach>>; readonly upstream: Upstream["Service"];}
export const noLayers: LayerGatePort = { classify: () => Effect.succeedNone, upstream: Upstream.of({ exchange: (repo) => Effect.fail(new RepoNotFound({ name: repo })), }),};
export const LayerGate = Context.Reference<LayerGatePort>( "platform/LayerGate", { defaultValue: () => noLayers, });
export const NoLayers: Layer.Layer<never> = Layer.succeed(LayerGate, noLayers);