@toiroakr/chisel 0.0.0-stage → 0.1.0

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.
Files changed (84) hide show
  1. package/README.md +464 -2
  2. package/dist/behavior.d.ts +181 -0
  3. package/dist/behavior.js +422 -0
  4. package/dist/behavior.js.map +1 -0
  5. package/dist/beside.d.ts +27 -0
  6. package/dist/beside.js +88 -0
  7. package/dist/beside.js.map +1 -0
  8. package/dist/border.d.ts +64 -0
  9. package/dist/border.js +426 -0
  10. package/dist/border.js.map +1 -0
  11. package/dist/cli.d.ts +5 -0
  12. package/dist/cli.js +567 -0
  13. package/dist/cli.js.map +1 -0
  14. package/dist/codec.d.ts +6 -0
  15. package/dist/codec.js +83 -0
  16. package/dist/codec.js.map +1 -0
  17. package/dist/codegen.d.ts +2 -0
  18. package/dist/codegen.js +65 -0
  19. package/dist/codegen.js.map +1 -0
  20. package/dist/composition.d.ts +38 -0
  21. package/dist/composition.js +242 -0
  22. package/dist/composition.js.map +1 -0
  23. package/dist/data.d.ts +16 -0
  24. package/dist/data.js +49 -0
  25. package/dist/data.js.map +1 -0
  26. package/dist/dependency.d.ts +98 -0
  27. package/dist/dependency.js +155 -0
  28. package/dist/dependency.js.map +1 -0
  29. package/dist/domain.d.ts +8 -0
  30. package/dist/domain.js +217 -0
  31. package/dist/domain.js.map +1 -0
  32. package/dist/ensures.d.ts +15 -0
  33. package/dist/ensures.js +88 -0
  34. package/dist/ensures.js.map +1 -0
  35. package/dist/exact.d.ts +21 -0
  36. package/dist/exact.js +80 -0
  37. package/dist/exact.js.map +1 -0
  38. package/dist/feasibility.d.ts +61 -0
  39. package/dist/feasibility.js +984 -0
  40. package/dist/feasibility.js.map +1 -0
  41. package/dist/guard-borders.d.ts +50 -0
  42. package/dist/guard-borders.js +809 -0
  43. package/dist/guard-borders.js.map +1 -0
  44. package/dist/index.d.ts +37 -0
  45. package/dist/index.js +19 -0
  46. package/dist/index.js.map +1 -0
  47. package/dist/interval.d.ts +3 -0
  48. package/dist/interval.js +161 -0
  49. package/dist/interval.js.map +1 -0
  50. package/dist/isolated.d.ts +9 -0
  51. package/dist/isolated.js +41 -0
  52. package/dist/isolated.js.map +1 -0
  53. package/dist/model.d.ts +95 -0
  54. package/dist/model.js +343 -0
  55. package/dist/model.js.map +1 -0
  56. package/dist/pairs.d.ts +26 -0
  57. package/dist/pairs.js +107 -0
  58. package/dist/pairs.js.map +1 -0
  59. package/dist/partition.d.ts +44 -0
  60. package/dist/partition.js +275 -0
  61. package/dist/partition.js.map +1 -0
  62. package/dist/proof.d.ts +15 -0
  63. package/dist/proof.js +482 -0
  64. package/dist/proof.js.map +1 -0
  65. package/dist/report-json.d.ts +11 -0
  66. package/dist/report-json.js +94 -0
  67. package/dist/report-json.js.map +1 -0
  68. package/dist/rule.d.ts +146 -0
  69. package/dist/rule.js +599 -0
  70. package/dist/rule.js.map +1 -0
  71. package/dist/schema.d.ts +163 -0
  72. package/dist/schema.js +524 -0
  73. package/dist/schema.js.map +1 -0
  74. package/dist/specification.d.ts +256 -0
  75. package/dist/specification.js +1583 -0
  76. package/dist/specification.js.map +1 -0
  77. package/dist/text.d.ts +1 -0
  78. package/dist/text.js +11 -0
  79. package/dist/text.js.map +1 -0
  80. package/dist/ways.d.ts +25 -0
  81. package/dist/ways.js +95 -0
  82. package/dist/ways.js.map +1 -0
  83. package/package.json +53 -4
  84. package/schema/report.schema.json +1062 -0
package/dist/rule.d.ts ADDED
@@ -0,0 +1,146 @@
1
+ import { Rational } from "./exact.js";
2
+ import type { Decimal } from "decimal.js";
3
+ import type { Temporal as TemporalTypes } from "temporal-spec";
4
+ import type { Execution, Guard } from "./behavior.js";
5
+ type Moment = TemporalTypes.Instant | TemporalTypes.PlainDate | TemporalTypes.PlainTime | TemporalTypes.PlainDateTime;
6
+ export type Comparable = number | bigint | Rational | string | Moment | Decimal;
7
+ declare const TERM: unique symbol;
8
+ export interface PositionTermData {
9
+ readonly kind: "position";
10
+ readonly path: readonly string[];
11
+ readonly measure: "value" | "length";
12
+ }
13
+ export interface LinearPart {
14
+ readonly path: readonly string[];
15
+ readonly measure: "value" | "length";
16
+ readonly coefficient: number;
17
+ }
18
+ export interface LinearTermData {
19
+ readonly kind: "linear";
20
+ readonly parts: readonly LinearPart[];
21
+ readonly constant: number | Decimal;
22
+ }
23
+ export type TermData = PositionTermData | LinearTermData;
24
+ export type Term<T> = {
25
+ readonly [TERM]: TermData;
26
+ readonly __value?: {
27
+ bivariant(value: T): void;
28
+ }["bivariant"];
29
+ };
30
+ export type Operand<T> = Term<T> | T;
31
+ export interface Condition {
32
+ $and(other: Rule): Rule & Condition;
33
+ $or(other: Rule): Rule & Condition;
34
+ $not(): Rule & Condition;
35
+ $else<Input, Result, Effect, Deps = unknown>(orElse: (input: Input, deps: Deps) => Execution<Result, Effect>): Guard<Input, Result, Effect, Deps>;
36
+ }
37
+ interface Ordered<T> {
38
+ $lt(other: Operand<T>): Rule & Condition;
39
+ $lte(other: Operand<T>): Rule & Condition;
40
+ $gt(other: Operand<T>): Rule & Condition;
41
+ $gte(other: Operand<T>): Rule & Condition;
42
+ $eq(other: Operand<T>): Rule & Condition;
43
+ $ne(other: Operand<T>): Rule & Condition;
44
+ }
45
+ interface Arithmetic<T> {
46
+ $plus(other: Operand<T>): TermOf<T>;
47
+ $minus(other: Operand<T>): TermOf<T>;
48
+ }
49
+ interface Equatable<T> {
50
+ $eq(other: Operand<T>): Rule & Condition;
51
+ $ne(other: Operand<T>): Rule & Condition;
52
+ }
53
+ interface Measured {
54
+ $length(): TermOf<number>;
55
+ }
56
+ interface Quantified<E> {
57
+ $all(each: (element: TermOf<E>) => Rule): Rule & Condition;
58
+ $any(each: (element: TermOf<E>) => Rule): Rule & Condition;
59
+ }
60
+ type TermOperator = "$lt" | "$lte" | "$gt" | "$gte" | "$eq" | "$ne" | "$length" | "$all" | "$any" | "$plus" | "$minus";
61
+ type Fields<T> = {
62
+ readonly [K in Exclude<keyof T & string, TermOperator>]-?: TermOf<Exclude<T[K], undefined>>;
63
+ };
64
+ export type TermOf<T> = Term<T> & (0 extends 1 & T ? {
65
+ readonly [key: string]: any;
66
+ } : [T] extends [boolean] ? Equatable<T> : [T] extends [number | Decimal] ? Ordered<T> & Arithmetic<T> : [T] extends [bigint | Rational] ? Ordered<T> : [T] extends [Moment] ? Ordered<T> : [T] extends [string] ? Ordered<T> & Measured : [T] extends [readonly (infer E)[]] ? Measured & Quantified<E> : [T] extends [object] ? string extends keyof T ? unknown extends T[string & keyof T] ? {
67
+ readonly [key: string]: any;
68
+ } : Measured & {
69
+ readonly [key: string]: TermOf<Exclude<T[string & keyof T], undefined>>;
70
+ } : Fields<T> : unknown);
71
+ export type InvariantRule<T> = {
72
+ bivariant(self: TermOf<T>): Rule;
73
+ }["bivariant"];
74
+ export type Operator = "<" | "<=" | ">" | ">=" | "==" | "!=";
75
+ export interface CompareRule {
76
+ readonly kind: "compare";
77
+ readonly operator: Operator;
78
+ readonly left: Operand<unknown>;
79
+ readonly right: Operand<unknown>;
80
+ }
81
+ export interface AllRule {
82
+ readonly kind: "all";
83
+ readonly of: Term<readonly unknown[]>;
84
+ readonly element: string;
85
+ readonly each: Rule;
86
+ }
87
+ export interface AnyRule {
88
+ readonly kind: "any";
89
+ readonly of: Term<readonly unknown[]>;
90
+ readonly element: string;
91
+ readonly each: Rule;
92
+ }
93
+ export interface AndRule {
94
+ readonly kind: "and";
95
+ readonly rules: readonly Rule[];
96
+ }
97
+ export interface OrRule {
98
+ readonly kind: "or";
99
+ readonly rules: readonly Rule[];
100
+ }
101
+ export interface NotRule {
102
+ readonly kind: "not";
103
+ readonly rule: Rule;
104
+ }
105
+ export type Rule = (CompareRule | AllRule | AnyRule | AndRule | OrRule | NotRule) & {
106
+ readonly name?: string;
107
+ };
108
+ export type Distinction = CompareRule | AllRule | AnyRule;
109
+ export declare function conjuncts(rule: Rule): readonly Rule[];
110
+ export declare const DEPS = "#deps";
111
+ export declare function depsTerm<T>(): TermOf<T>;
112
+ export declare function bindElement(scope: unknown, name: string, element: unknown): unknown;
113
+ export declare function withLocal(scope: unknown, name: string, value: unknown): unknown;
114
+ export declare function withDeps(input: unknown, deps: unknown): unknown;
115
+ export declare function rootTerm<T>(key: string): TermOf<T>;
116
+ export declare function termPaths(rule: Rule): readonly (readonly string[])[];
117
+ export declare function rootsRead(rule: Rule): ReadonlySet<string | undefined>;
118
+ export declare function selfTerm<T>(): TermOf<T>;
119
+ export declare function isTerm(value: unknown): value is Term<unknown>;
120
+ export declare function termData(term: Term<unknown>): TermData;
121
+ export declare function boundTermPath(rule: Rule): readonly string[] | undefined;
122
+ export declare function shiftTerms(rule: CompareRule): CompareRule;
123
+ export declare function stepInto(rule: Rule, key: string): Rule | undefined;
124
+ export type ComparisonObserver = (rule: CompareRule, scope: unknown) => void;
125
+ export type DistinctionObserver = (distinction: Distinction, outcome: boolean) => void;
126
+ export declare function holds(rule: Rule, value: unknown, observe?: ComparisonObserver, decide?: DistinctionObserver): boolean;
127
+ export declare function satisfy(rule: Rule, value: unknown, stepAt?: StepAt): unknown;
128
+ export type ElementLabels = Readonly<Record<string, string>>;
129
+ export declare function describeRule(rule: Rule, path?: string, elements?: ElementLabels): string;
130
+ export type Step = (bound: unknown, direction: 1 | -1) => unknown;
131
+ export type StepAt = (path: readonly string[]) => Step | {
132
+ readonly among: readonly unknown[];
133
+ } | undefined;
134
+ export declare function isDecimal(value: unknown): value is Decimal;
135
+ export declare function decimalUnits(value: Decimal, scale: number, rounding: "floor" | "ceil"): bigint;
136
+ export declare function decimalOfUnits(like: Decimal, units: bigint, scale: number): Decimal;
137
+ export declare function decimalStep(scale: number): Step;
138
+ export declare function sizeOf(value: unknown): number;
139
+ export declare function resize(current: unknown, size: number, empty?: () => unknown): unknown;
140
+ export declare function positionTerm(path: readonly string[], measure: PositionTermData["measure"]): Term<unknown>;
141
+ export declare function differenceOf(rule: CompareRule): LinearTermData;
142
+ export declare function positionData(term: Term<unknown>): PositionTermData | undefined;
143
+ export declare function positionOf(term: Term<unknown>): PositionTermData;
144
+ export declare function readOperand(operand: unknown, value: unknown): unknown;
145
+ export declare function describeTerm(term: Term<unknown>, path?: string): string;
146
+ export {};