@antithesishq/bombadil 0.1.1
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.
- package/README.md +39 -0
- package/dist/defaults.d.ts +5 -0
- package/dist/defaults.d.ts.map +1 -0
- package/dist/index.d.ts +83 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/internal.d.ts +40 -0
- package/dist/internal.d.ts.map +1 -0
- package/package.json +1 -0
package/README.md
ADDED
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
# @antithesishq/bombadil
|
|
2
|
+
|
|
3
|
+
> Version 0.1.1
|
|
4
|
+
|
|
5
|
+
Type definitions for writing [Bombadil](https://github.com/antithesishq/bombadil) specifications.
|
|
6
|
+
|
|
7
|
+
Bombadil is property-based testing for web UIs, autonomously exploring and
|
|
8
|
+
validating correctness properties, *finding harder bugs earlier*.
|
|
9
|
+
|
|
10
|
+
## Install
|
|
11
|
+
|
|
12
|
+
```
|
|
13
|
+
npm install --save-dev @antithesishq/bombadil
|
|
14
|
+
```
|
|
15
|
+
|
|
16
|
+
## Usage
|
|
17
|
+
|
|
18
|
+
Re-export the default properties:
|
|
19
|
+
|
|
20
|
+
```typescript
|
|
21
|
+
export * from "@antithesishq/bombadil/defaults";
|
|
22
|
+
```
|
|
23
|
+
|
|
24
|
+
Or write custom properties:
|
|
25
|
+
|
|
26
|
+
```typescript
|
|
27
|
+
import { always, eventually, extract, now } from "@antithesishq/bombadil";
|
|
28
|
+
|
|
29
|
+
const title = extract((state) =>
|
|
30
|
+
state.document.querySelector("h1")?.textContent ?? ""
|
|
31
|
+
);
|
|
32
|
+
|
|
33
|
+
export const has_title = always(() => title.current.trim() !== "");
|
|
34
|
+
```
|
|
35
|
+
|
|
36
|
+
## Documentation
|
|
37
|
+
|
|
38
|
+
See the [Bombadil repository](https://github.com/antithesishq/bombadil) for
|
|
39
|
+
full usage instructions and more examples.
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
export declare const no_http_error_codes: import("bombadil").Always;
|
|
2
|
+
export declare const no_uncaught_exceptions: import("bombadil").Always;
|
|
3
|
+
export declare const no_unhandled_promise_rejections: import("bombadil").Always;
|
|
4
|
+
export declare const no_console_errors: import("bombadil").Always;
|
|
5
|
+
//# sourceMappingURL=defaults.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"defaults.d.ts","sourceRoot":"","sources":["../../9sp1ldc23f4jrk4xdmc9h05c77xcx7a8-source/src/specification/defaults.ts"],"names":[],"mappings":"AASA,eAAO,MAAM,mBAAmB,2BAE/B,CAAC;AAIF,eAAO,MAAM,sBAAsB,2BAElC,CAAC;AAMF,eAAO,MAAM,+BAA+B,2BAE3C,CAAC;AAMF,eAAO,MAAM,iBAAiB,2BAE7B,CAAC"}
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,83 @@
|
|
|
1
|
+
import { type JSON, Duration, type TimeUnit, type Cell } from "bombadil/internal";
|
|
2
|
+
export { time, type Cell } from "bombadil/internal";
|
|
3
|
+
export declare class Formula {
|
|
4
|
+
not(): Formula;
|
|
5
|
+
and(that: IntoFormula): Formula;
|
|
6
|
+
or(that: IntoFormula): Formula;
|
|
7
|
+
implies(that: IntoFormula): Formula;
|
|
8
|
+
}
|
|
9
|
+
export declare class Pure extends Formula {
|
|
10
|
+
private pretty;
|
|
11
|
+
value: boolean;
|
|
12
|
+
constructor(pretty: string, value: boolean);
|
|
13
|
+
toString(): string;
|
|
14
|
+
}
|
|
15
|
+
export declare class And extends Formula {
|
|
16
|
+
left: Formula;
|
|
17
|
+
right: Formula;
|
|
18
|
+
constructor(left: Formula, right: Formula);
|
|
19
|
+
toString(): string;
|
|
20
|
+
}
|
|
21
|
+
export declare class Or extends Formula {
|
|
22
|
+
left: Formula;
|
|
23
|
+
right: Formula;
|
|
24
|
+
constructor(left: Formula, right: Formula);
|
|
25
|
+
}
|
|
26
|
+
export declare class Implies extends Formula {
|
|
27
|
+
left: Formula;
|
|
28
|
+
right: Formula;
|
|
29
|
+
constructor(left: Formula, right: Formula);
|
|
30
|
+
toString(): string;
|
|
31
|
+
}
|
|
32
|
+
export declare class Not extends Formula {
|
|
33
|
+
subformula: Formula;
|
|
34
|
+
constructor(subformula: Formula);
|
|
35
|
+
toString(): string;
|
|
36
|
+
}
|
|
37
|
+
export declare class Next extends Formula {
|
|
38
|
+
subformula: Formula;
|
|
39
|
+
constructor(subformula: Formula);
|
|
40
|
+
toString(): string;
|
|
41
|
+
}
|
|
42
|
+
export declare class Always extends Formula {
|
|
43
|
+
bound: Duration | null;
|
|
44
|
+
subformula: Formula;
|
|
45
|
+
constructor(bound: Duration | null, subformula: Formula);
|
|
46
|
+
within(n: number, unit: TimeUnit): Formula;
|
|
47
|
+
toString(): string;
|
|
48
|
+
}
|
|
49
|
+
export declare class Eventually extends Formula {
|
|
50
|
+
bound: Duration | null;
|
|
51
|
+
subformula: Formula;
|
|
52
|
+
constructor(bound: Duration | null, subformula: Formula);
|
|
53
|
+
within(n: number, unit: TimeUnit): Formula;
|
|
54
|
+
toString(): string;
|
|
55
|
+
}
|
|
56
|
+
export declare class Thunk extends Formula {
|
|
57
|
+
private pretty;
|
|
58
|
+
apply: () => Formula;
|
|
59
|
+
constructor(pretty: string, apply: () => Formula);
|
|
60
|
+
toString(): string;
|
|
61
|
+
}
|
|
62
|
+
type IntoFormula = (() => Formula | boolean) | Formula;
|
|
63
|
+
export declare function not(value: IntoFormula): Not;
|
|
64
|
+
export declare function now(x: IntoFormula): Formula;
|
|
65
|
+
export declare function next(x: IntoFormula): Formula;
|
|
66
|
+
export declare function always(x: IntoFormula): Always;
|
|
67
|
+
export declare function eventually(x: IntoFormula): Eventually;
|
|
68
|
+
export declare function extract<T extends JSON>(query: (state: State) => T): Cell<T>;
|
|
69
|
+
export interface State {
|
|
70
|
+
document: HTMLDocument;
|
|
71
|
+
window: Window;
|
|
72
|
+
errors: {
|
|
73
|
+
uncaught_exception: JSON;
|
|
74
|
+
unhandled_promise_rejection: JSON;
|
|
75
|
+
};
|
|
76
|
+
console: ConsoleEntry[];
|
|
77
|
+
}
|
|
78
|
+
export type ConsoleEntry = {
|
|
79
|
+
timestamp: number;
|
|
80
|
+
level: "warning" | "error";
|
|
81
|
+
args: JSON[];
|
|
82
|
+
};
|
|
83
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../9sp1ldc23f4jrk4xdmc9h05c77xcx7a8-source/src/specification/index.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,KAAK,IAAI,EAGT,QAAQ,EACR,KAAK,QAAQ,EACb,KAAK,IAAI,EACV,MAAM,mBAAmB,CAAC;AAM3B,OAAO,EAAE,IAAI,EAAE,KAAK,IAAI,EAAE,MAAM,mBAAmB,CAAC;AAEpD,qBAAa,OAAO;IAClB,GAAG,IAAI,OAAO;IAGd,GAAG,CAAC,IAAI,EAAE,WAAW,GAAG,OAAO;IAG/B,EAAE,CAAC,IAAI,EAAE,WAAW,GAAG,OAAO;IAG9B,OAAO,CAAC,IAAI,EAAE,WAAW,GAAG,OAAO;CAGpC;AAED,qBAAa,IAAK,SAAQ,OAAO;IAE7B,OAAO,CAAC,MAAM;IACP,KAAK,EAAE,OAAO;gBADb,MAAM,EAAE,MAAM,EACf,KAAK,EAAE,OAAO;IAKd,QAAQ;CAGlB;AAED,qBAAa,GAAI,SAAQ,OAAO;IAErB,IAAI,EAAE,OAAO;IACb,KAAK,EAAE,OAAO;gBADd,IAAI,EAAE,OAAO,EACb,KAAK,EAAE,OAAO;IAKd,QAAQ;CAGlB;AAED,qBAAa,EAAG,SAAQ,OAAO;IAEpB,IAAI,EAAE,OAAO;IACb,KAAK,EAAE,OAAO;gBADd,IAAI,EAAE,OAAO,EACb,KAAK,EAAE,OAAO;CAIxB;AAED,qBAAa,OAAQ,SAAQ,OAAO;IAEzB,IAAI,EAAE,OAAO;IACb,KAAK,EAAE,OAAO;gBADd,IA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,MAAM,CAE7C;AAED,wBAAgB,UAAU,CAAC,CAAC,EAAE,WAAW,GAAG,UAAU,CAErD;AAED,wBAAgB,OAAO,CAAC,CAAC,SAAS,IAAI,EAAE,KAAK,EAAE,CAAC,KAAK,EAAE,KAAK,KAAK,CAAC,GAAG,IAAI,CAAC,CAAC,CAAC,CAE3E;AAED,MAAM,WAAW,KAAK;IACpB,QAAQ,EAAE,YAAY,CAAC;IACvB,MAAM,EAAE,MAAM,CAAC;IACf,MAAM,EAAE;QACN,kBAAkB,EAAE,IAAI,CAAC;QACzB,2BAA2B,EAAE,IAAI,CAAC;KACnC,CAAC;IACF,OAAO,EAAE,YAAY,EAAE,CAAC;CACzB;AAED,MAAM,MAAM,YAAY,GAAG;IACzB,SAAS,EAAE,MAAM,CAAC;IAClB,KAAK,EAAE,SAAS,GAAG,OAAO,CAAC;IAC3B,IAAI,EAAE,IAAI,EAAE,CAAC;CACd,CAAC"}
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
export type Time = number;
|
|
2
|
+
export type TimeUnit = "milliseconds" | "seconds";
|
|
3
|
+
export declare class Duration {
|
|
4
|
+
private n;
|
|
5
|
+
private unit;
|
|
6
|
+
constructor(n: number, unit: TimeUnit);
|
|
7
|
+
get milliseconds(): number;
|
|
8
|
+
}
|
|
9
|
+
export interface Cell<T> {
|
|
10
|
+
get current(): T;
|
|
11
|
+
at(time: Time): T;
|
|
12
|
+
update(snapshot: T, time: Time): void;
|
|
13
|
+
}
|
|
14
|
+
export type JSON = string | number | boolean | null | JSON[] | {
|
|
15
|
+
[key: string | number | symbol]: JSON;
|
|
16
|
+
} | {
|
|
17
|
+
toJSON(): JSON;
|
|
18
|
+
};
|
|
19
|
+
export declare class ExtractorCell<T extends JSON, S> implements Cell<T> {
|
|
20
|
+
private extract;
|
|
21
|
+
private snapshots;
|
|
22
|
+
constructor(runtime: Runtime<S>, extract: (state: S) => T);
|
|
23
|
+
update(snapshot: T, time: Time): void;
|
|
24
|
+
get current(): T;
|
|
25
|
+
at(other: Time): T;
|
|
26
|
+
as_js_function(): string;
|
|
27
|
+
}
|
|
28
|
+
export declare class TimeCell implements Cell<Time> {
|
|
29
|
+
private time;
|
|
30
|
+
constructor();
|
|
31
|
+
update(_: {}, time: Time): void;
|
|
32
|
+
get current(): Time;
|
|
33
|
+
at(time: Time): Time;
|
|
34
|
+
}
|
|
35
|
+
export declare const time: Cell<Time>;
|
|
36
|
+
export declare class Runtime<S> {
|
|
37
|
+
extractors: ExtractorCell<any, S>[];
|
|
38
|
+
register_extractor(cell: ExtractorCell<any, S>): void;
|
|
39
|
+
}
|
|
40
|
+
//# sourceMappingURL=internal.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"internal.d.ts","sourceRoot":"","sources":["../../9sp1ldc23f4jrk4xdmc9h05c77xcx7a8-source/src/specification/internal.ts"],"names":[],"mappings":"AAAA,MAAM,MAAM,IAAI,GAAG,MAAM,CAAC;AAE1B,MAAM,MAAM,QAAQ,GAAG,cAAc,GAAG,SAAS,CAAC;AAElD,qBAAa,QAAQ;IAEjB,OAAO,CAAC,CAAC;IACT,OAAO,CAAC,IAAI;gBADJ,CAAC,EAAE,MAAM,EACT,IAAI,EAAE,QAAQ;IAGxB,IAAI,YAAY,IAAI,MAAM,CAOzB;CACF;AAED,MAAM,WAAW,IAAI,CAAC,CAAC;IACrB,IAAI,OAAO,IAAI,CAAC,CAAC;IACjB,EAAE,CAAC,IAAI,EAAE,IAAI,GAAG,CAAC,CAAC;IAClB,MAAM,CAAC,QAAQ,EAAE,CAAC,EAAE,IAAI,EAAE,IAAI,GAAG,IAAI,CAAC;CACvC;AAED,MAAM,MAAM,IAAI,GACZ,MAAM,GACN,MAAM,GACN,OAAO,GACP,IAAI,GACJ,IAAI,EAAE,GACN;IAAE,CAAC,GAAG,EAAE,MAAM,GAAG,MAAM,GAAG,MAAM,GAAG,IAAI,CAAA;CAAE,GACzC;IAAE,MAAM,IAAI,IAAI,CAAA;CAAE,CAAC;AAEvB,qBAAa,aAAa,CAAC,CAAC,SAAS,IAAI,EAAE,CAAC,CAAE,YAAW,IAAI,CAAC,CAAC,CAAC;IAI5D,OAAO,CAAC,OAAO;IAHjB,OAAO,CAAC,SAAS,CAAsB;gBAErC,OAAO,EAAE,OAAO,CAAC,CAAC,CAAC,EACX,OAAO,EAAE,CAAC,KAAK,EAAE,CAAC,KAAK,CAAC;IAKlC,MAAM,CAAC,QAAQ,EAAE,CAAC,EAAE,IAAI,EAAE,IAAI,GAAG,IAAI;IAIrC,IAAI,OAAO,IAAI,CAAC,CASf;IAED,EAAE,CAAC,KAAK,EAAE,IAAI,GAAG,CAAC;IAclB,cAAc,IAAI,MAAM;CAGzB;AAED,qBAAa,QAAS,YAAW,IAAI,CAAC,IAAI,CAAC;IACzC,OAAO,CAAC,IAAI,CAA+B;;IAG3C,MAAM,CAAC,CAAC,EAAE,EAAE,EAAE,IAAI,EAAE,IAAI;IAIxB,IAAI,OAAO,IAAI,IAAI,CAKlB;IAED,EAAE,CAAC,IAAI,EAAE,IAAI,GAAG,IAAI;CAGrB;AAED,eAAO,MAAM,IAAI,EAAE,IAAI,CAAC,IAAI,CAAkB,CAAC;AAE/C,qBAAa,OAAO,CAAC,CAAC;IACpB,UAAU,EAAE,aAAa,CAAC,GAAG,EAAE,CAAC,CAAC,EAAE,CAAM;IAEzC,kBAAkB,CAAC,IAAI,EAAE,aAAa,CAAC,GAAG,EAAE,CAAC,CAAC;CAG/C"}
|
package/package.json
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"description":"Type definitions for writing Bombadil specifications","exports":{".":{"types":"./dist/index.d.ts"},"./defaults":{"types":"./dist/defaults.d.ts"},"./internal":{"types":"./dist/internal.d.ts"}},"files":["dist","README.md"],"homepage":"https://github.com/antithesishq/bombadil","license":"MIT","name":"@antithesishq/bombadil","repository":{"type":"git","url":"https://github.com/antithesishq/bombadil"},"types":"./dist/index.d.ts","version":"0.1.1"}
|