Skip to content
Myr

entry.ts

This file

Path

packages/rules/src/entry.ts

66 lines · 1.8 KiB · TypeScript

Last changed by

Merge build/comments-packages-rest into mainoscabrielbefore adoption38cd503

History of this file

Take it

The walk stopped after 200 commits: lines older than 678c8b8 point at it.

Merge build/comments-packages-rest into mainoscabrielbefore adoption38cd503

lines 1–2why, one step back
1// Imports only `effect` and the sdk's `Functions` key, which config code
2// brings anyway, so a bundler can inline it beside the sdk.

Merge build/614-env-service: deciders set write-only values for @sensitive items, the public sees the env shape, and checks see only placeholdersoscabrielbefore adoption678c8b8

lines 3–6why, one step back
3import { Functions } from "@repo/sdk/functions";
4import { Predicate } from "effect";5import type { Schema } from "effect";6

Merge build/comments-packages-rest into mainoscabrielbefore adoption38cd503

line 7why, one step back
7/** Function-valued rules ride under the sdk's `Functions` symbol, which JSON never meets. */

Merge build/614-env-service: deciders set write-only values for @sensitive items, the public sees the env shape, and checks see only placeholdersoscabrielbefore adoption678c8b8

lines 8–22why, one step back
8export type Definition = Schema.Json;
910export type Rule = (facts: Schema.Json) => boolean | Promise<boolean>;1112export interface Exported {13 readonly definition: Definition | undefined;14 readonly path: string;15}1617export interface CollectedData {18 readonly asks: readonly {19 readonly ask: Schema.Json;20 readonly path: string;21 }[];22 readonly project?: Schema.Json;

Merge build/608-datekit-maintainers-layer: datekit has a maintainers layer of sealed checks, each citing the clause it enforces, and the seed pushes itoscabrielbefore adoption166f6c9

line 23why, one step back
23 readonly visibility?: Schema.Json;

Merge build/614-env-service: deciders set write-only values for @sensitive items, the public sees the env shape, and checks see only placeholdersoscabrielbefore adoption678c8b8

lines 24–30why, one step back
24}
2526const dataOf = (definition: Definition | undefined): Schema.Json =>27 definition ?? null;2829export const collect = (30 project: Exported | undefined,

Merge build/608-datekit-maintainers-layer: datekit has a maintainers layer of sealed checks, each citing the clause it enforces, and the seed pushes itoscabrielbefore adoption166f6c9

lines 31–32why, one step back
31 asks: readonly Exported[],
32 visibility?: Exported

Merge build/614-env-service: deciders set write-only values for @sensitive items, the public sees the env shape, and checks see only placeholdersoscabrielbefore adoption678c8b8

lines 33–38why, one step back
33): CollectedData => {
34 const collected = asks.map(({ definition, path }) => ({35 ask: dataOf(definition),36 path,37 }));38

Merge build/608-datekit-maintainers-layer: datekit has a maintainers layer of sealed checks, each citing the clause it enforces, and the seed pushes itoscabrielbefore adoption166f6c9

lines 39–46why, one step back
39 const withProject: CollectedData =
40 project === undefined41 ? { asks: collected }42 : { asks: collected, project: dataOf(project.definition) };4344 return visibility === undefined45 ? withProject46 : { ...withProject, visibility: dataOf(visibility.definition) };

Merge build/614-env-service: deciders set write-only values for @sensitive items, the public sees the env shape, and checks see only placeholdersoscabrielbefore adoption678c8b8

lines 47–66why, one step back
47};
4849const isRule = (value: unknown): value is Rule => Predicate.isFunction(value);5051export const ruleOf = (52 definition: Definition | undefined,53 rule: string54): Rule | undefined => {55 if (!Predicate.hasProperty(definition, Functions)) {56 return undefined;57 }5859 const carried = definition[Functions];6061 const found = Predicate.hasProperty(carried, rule)62 ? carried[rule]63 : undefined;6465 return isRule(found) ? found : undefined;66};