@platecms/delta-cast 1.0.0 → 1.3.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.
@@ -0,0 +1,229 @@
1
+ import {
2
+ CastSuggestion,
3
+ Code,
4
+ Content,
5
+ ExternalLink,
6
+ Heading,
7
+ InternalLink,
8
+ InterpolatedContentValue,
9
+ List,
10
+ Literal,
11
+ Parent,
12
+ Root,
13
+ Text,
14
+ } from "./schemas/schema";
15
+ import { InvalidCastError } from "./invalid-cast.error";
16
+ import { InvalidPrnError, PRN } from "@platecms/delta-plate-resource-notation";
17
+
18
+ /*
19
+ * Due to a circular dependency, we can't import the URL_REGEX from @platecms/delta-core.
20
+ * FIXME: move and import from @platecms/delta-core once the circular dependency is resolved
21
+ **/
22
+ export const URL_REGEX =
23
+ /^(https?:\/\/(?:www\.)?[-a-zA-Z0-9@:%._+~#=]{1,256}\.[a-zA-Z0-9()]{1,6}\b(?:[-a-zA-Z0-9()@:%_+.~#?&/=]*)|mailto:[^\s@]+@[^\s@]+\.[^\s@]+|tel:\+?[0-9\s\-().]{7,}|\/[^\s]*)$/u;
24
+
25
+ function assertNonNullObject(value: unknown): asserts value is object {
26
+ if (typeof value !== "object" || value == null) {
27
+ throw new InvalidCastError(`Invalid object`);
28
+ }
29
+ }
30
+
31
+ function assertTextNode(value: unknown): asserts value is Text {
32
+ assertNonNullObject(value);
33
+
34
+ if ("type" in value && typeof value.type === "string" && value.type !== "text") {
35
+ throw new InvalidCastError(`Invalid node: ${value.type} node is not a text node`);
36
+ }
37
+ }
38
+
39
+ function assertValidParent(value: unknown): asserts value is Parent {
40
+ assertNonNullObject(value);
41
+
42
+ const parent = value as Parent;
43
+ if (!Array.isArray(parent.children)) {
44
+ throw new InvalidCastError("Invalid parent: children is not an array");
45
+ }
46
+
47
+ // eslint-disable-next-line @typescript-eslint/no-use-before-define
48
+ parent.children.forEach(assertValidContent);
49
+ }
50
+
51
+ function assertValidLiteral(value: unknown): asserts value is Literal {
52
+ assertNonNullObject(value);
53
+
54
+ const literal = value as Literal;
55
+ if (typeof literal.value !== "string") {
56
+ throw new InvalidCastError("Invalid literal: value is not a string");
57
+ }
58
+ }
59
+
60
+ function assertValidHeading(value: unknown): asserts value is Heading {
61
+ assertNonNullObject(value);
62
+
63
+ const list = value as Heading;
64
+ if (typeof list.level !== "number" || list.level < 1 || list.level > 6) {
65
+ throw new InvalidCastError("Invalid heading");
66
+ }
67
+
68
+ assertValidParent(list);
69
+ }
70
+
71
+ function assertValidList(value: unknown): asserts value is List {
72
+ assertNonNullObject(value);
73
+
74
+ const list = value as List;
75
+ if (typeof list.ordered !== "boolean" || (list.start != null && typeof list.start !== "number")) {
76
+ throw new InvalidCastError("Invalid list");
77
+ }
78
+
79
+ assertValidParent(list);
80
+ }
81
+
82
+ function assertValidCode(value: unknown): asserts value is Code {
83
+ assertNonNullObject(value);
84
+
85
+ const code = value as Code;
86
+ if (code.lang != null && typeof code.lang !== "string") {
87
+ throw new InvalidCastError("Invalid code");
88
+ }
89
+
90
+ assertValidParent(code);
91
+ }
92
+
93
+ function assertValidInterpolatedContentValue(value: unknown): asserts value is InterpolatedContentValue {
94
+ assertNonNullObject(value);
95
+
96
+ const contentValue = value as InterpolatedContentValue;
97
+ try {
98
+ PRN.fromString(contentValue.prn);
99
+ } catch (error) {
100
+ if (error instanceof InvalidPrnError) {
101
+ throw new InvalidCastError(`Invalid contentValue: invalid PRN ${contentValue.prn}`);
102
+ }
103
+
104
+ throw error;
105
+ }
106
+ }
107
+
108
+ function assertValidExternalLink(value: unknown): asserts value is ExternalLink {
109
+ assertNonNullObject(value);
110
+ assertValidParent(value);
111
+
112
+ const link = value as ExternalLink;
113
+ if (typeof link.url !== "string") {
114
+ throw new InvalidCastError(`Invalid link: invalid url`);
115
+ }
116
+
117
+ if (!URL_REGEX.test(link.url)) {
118
+ throw new InvalidCastError(`Invalid link: invalid url ${link.url}`);
119
+ }
120
+
121
+ link.children.forEach(assertTextNode);
122
+ }
123
+
124
+ function assertValidInternalLink(value: unknown): asserts value is InternalLink {
125
+ assertNonNullObject(value);
126
+ assertValidParent(value);
127
+ const link = value as InternalLink;
128
+ try {
129
+ PRN.fromString(link.prn);
130
+ } catch (error) {
131
+ if (error instanceof InvalidPrnError) {
132
+ throw new InvalidCastError(`Invalid link: invalid PRN ${link.prn}`);
133
+ }
134
+
135
+ throw error;
136
+ }
137
+
138
+ link.children.forEach(assertTextNode);
139
+ }
140
+
141
+ function assertValidCastSuggestion(value: unknown): asserts value is CastSuggestion {
142
+ assertNonNullObject(value);
143
+
144
+ const suggestion = value as CastSuggestion;
145
+
146
+ // Validate required fields
147
+ if (!Array.isArray(suggestion.original)) {
148
+ throw new InvalidCastError("Invalid castSuggestion: original must be an array");
149
+ }
150
+
151
+ if (suggestion.suggested === null) {
152
+ throw new InvalidCastError("Invalid castSuggestion: suggested must be an array");
153
+ }
154
+
155
+ if (typeof suggestion.message !== "string") {
156
+ throw new InvalidCastError("Invalid castSuggestion: message must be a string");
157
+ }
158
+
159
+ if (typeof suggestion.method !== "string") {
160
+ throw new InvalidCastError("Invalid castSuggestion: method must be a string");
161
+ }
162
+
163
+ // eslint-disable-next-line @typescript-eslint/no-use-before-define
164
+ suggestion.original.forEach(assertValidContent);
165
+ }
166
+
167
+ export function assertValidContent(value: unknown): asserts value is Content {
168
+ assertNonNullObject(value);
169
+
170
+ const content = value as Content;
171
+ switch (content.type) {
172
+ case "paragraph":
173
+ case "listItem":
174
+ case "blockquote":
175
+ case "bold":
176
+ case "italic":
177
+ case "underline":
178
+ case "strikethrough":
179
+ case "highlight":
180
+ assertValidParent(content);
181
+ break;
182
+ case "externalLink":
183
+ assertValidExternalLink(content);
184
+ break;
185
+ case "internalLink":
186
+ assertValidInternalLink(content);
187
+ break;
188
+ case "castSuggestion":
189
+ assertValidCastSuggestion(content);
190
+ break;
191
+ case "heading":
192
+ assertValidHeading(content);
193
+ break;
194
+ case "text":
195
+ case "inlineCode":
196
+ assertValidLiteral(content);
197
+ break;
198
+ case "list":
199
+ assertValidList(content);
200
+ break;
201
+ case "code":
202
+ assertValidCode(content);
203
+ break;
204
+ case "contentValue":
205
+ assertValidInterpolatedContentValue(content);
206
+ break;
207
+ default:
208
+ throw new InvalidCastError(`Invalid Content type '${(content as { type: string }).type}'.`);
209
+ }
210
+ }
211
+
212
+ /**
213
+ * Validates a CAST object.
214
+ * @remarks Doesn't (and can't) check for circular references. This is done in the Content Management Center when validating the CAST.
215
+ */
216
+ export function validateCast(value: unknown): void {
217
+ assertNonNullObject(value);
218
+
219
+ const root = value as Root;
220
+ if (root.type !== "root") {
221
+ throw new InvalidCastError("Invalid root: type is not 'root'");
222
+ }
223
+
224
+ if (!Array.isArray(root.children)) {
225
+ throw new InvalidCastError("Invalid root: children is not an array");
226
+ }
227
+
228
+ root.children.forEach(assertValidContent);
229
+ }
package/src/index.js DELETED
@@ -1,7 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- const tslib_1 = require("tslib");
4
- tslib_1.__exportStar(require("./lib/validate-cast"), exports);
5
- tslib_1.__exportStar(require("./lib/invalid-cast.error"), exports);
6
- tslib_1.__exportStar(require("./lib/normalize-cast"), exports);
7
- //# sourceMappingURL=index.js.map
package/src/index.js.map DELETED
@@ -1 +0,0 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../../packages/cast/src/index.ts"],"names":[],"mappings":";;;AACA,8DAAoC;AACpC,mEAAyC;AACzC,+DAAqC"}
@@ -1,3 +0,0 @@
1
- export declare class InvalidCastError extends Error {
2
- constructor(message?: string);
3
- }
@@ -1,11 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.InvalidCastError = void 0;
4
- class InvalidCastError extends Error {
5
- constructor(message) {
6
- super(message);
7
- this.name = this.constructor.name;
8
- }
9
- }
10
- exports.InvalidCastError = InvalidCastError;
11
- //# sourceMappingURL=invalid-cast.error.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"invalid-cast.error.js","sourceRoot":"","sources":["../../../../../../packages/cast/src/lib/invalid-cast.error.ts"],"names":[],"mappings":";;;AAAA,MAAa,gBAAiB,SAAQ,KAAK;IACzC,YAAmB,OAAgB;QACjC,KAAK,CAAC,OAAO,CAAC,CAAC;QACf,IAAI,CAAC,IAAI,GAAG,IAAI,CAAC,WAAW,CAAC,IAAI,CAAC;IACpC,CAAC;CACF;AALD,4CAKC"}
@@ -1,9 +0,0 @@
1
- import { Root } from "./schemas/schema";
2
- export declare const FORMATTING_PRIORITY: {
3
- readonly bold: 1;
4
- readonly italic: 2;
5
- readonly underline: 3;
6
- readonly strikethrough: 4;
7
- readonly highlight: 5;
8
- };
9
- export declare function normalizeCast(root: Root): Root;
@@ -1,190 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.FORMATTING_PRIORITY = void 0;
4
- exports.normalizeCast = normalizeCast;
5
- exports.FORMATTING_PRIORITY = {
6
- bold: 1,
7
- italic: 2,
8
- underline: 3,
9
- strikethrough: 4,
10
- highlight: 5,
11
- };
12
- function hasChildren(node) {
13
- return "children" in node && Array.isArray(node.children);
14
- }
15
- function isFormattingNode(node) {
16
- const formattingTypes = ["bold", "italic", "underline", "strikethrough", "highlight"];
17
- return formattingTypes.includes(node.type);
18
- }
19
- function canMerge(node1, node2) {
20
- const mergeableTypes = ["bold", "italic", "underline", "strikethrough", "highlight", "text"];
21
- if (mergeableTypes.includes(node1.type) && node1.type === node2.type) {
22
- return true;
23
- }
24
- return false;
25
- }
26
- function mergeNodes(source, target) {
27
- if (source.type === "text" && target.type === "text") {
28
- target.value = source.value + target.value;
29
- }
30
- else if (source.type === target.type && hasChildren(source) && hasChildren(target)) {
31
- const sourceWithChildren = source;
32
- const targetWithChildren = target;
33
- targetWithChildren.children = [...sourceWithChildren.children, ...targetWithChildren.children];
34
- }
35
- }
36
- function shouldChildBeAboveParent(childType, parentType) {
37
- const childPriority = exports.FORMATTING_PRIORITY[childType] || 999;
38
- const parentPriority = exports.FORMATTING_PRIORITY[parentType] || 999;
39
- return childPriority < parentPriority;
40
- }
41
- function splitParentIntoSeparateNodes(grandParent, parent, child, parentIndexInGrandParent, childIndexInParent) {
42
- const siblingsBeforeChild = parent.children.slice(0, childIndexInParent);
43
- const siblingsAfterChild = parent.children.slice(childIndexInParent + 1);
44
- let insertionOffset = 0;
45
- if (siblingsBeforeChild.length > 0) {
46
- const newBeforeParent = { ...parent, children: siblingsBeforeChild };
47
- grandParent.children.splice(parentIndexInGrandParent, 0, newBeforeParent);
48
- insertionOffset = 1;
49
- }
50
- if (siblingsAfterChild.length > 0) {
51
- const newAfterParent = { ...parent, children: siblingsAfterChild };
52
- grandParent.children.splice(parentIndexInGrandParent + 1 + insertionOffset, 0, newAfterParent);
53
- }
54
- parent.children = [child];
55
- return insertionOffset;
56
- }
57
- function processFormattingChild(grandParent, parent, child, parentIndexInGrandParent, childIndexInParent) {
58
- if (!shouldChildBeAboveParent(child.type, parent.type)) {
59
- return false;
60
- }
61
- let parentIndexInGrandParentOffset = 0;
62
- if (parent.children.length > 1) {
63
- parentIndexInGrandParentOffset += splitParentIntoSeparateNodes(grandParent, parent, child, parentIndexInGrandParent, childIndexInParent);
64
- }
65
- parent.children = child.children;
66
- child.children = [parent];
67
- grandParent.children[parentIndexInGrandParent + parentIndexInGrandParentOffset] = child;
68
- return true;
69
- }
70
- function bubbleFormattingNodes(node, parent, nodeIndexInParent) {
71
- let hasChanges = false;
72
- if (!hasChildren(node)) {
73
- return hasChanges;
74
- }
75
- for (let i = 0; i < node.children.length; i++) {
76
- const child = node.children[i];
77
- if (hasChildren(child)) {
78
- hasChanges = bubbleFormattingNodes(child, node, i) || hasChanges;
79
- }
80
- }
81
- if (!isFormattingNode(node)) {
82
- return hasChanges;
83
- }
84
- if (!parent || nodeIndexInParent === undefined) {
85
- return hasChanges;
86
- }
87
- for (let i = 0; i < node.children.length; i++) {
88
- const child = node.children[i];
89
- if (isFormattingNode(child) && hasChildren(child)) {
90
- hasChanges = processFormattingChild(parent, node, child, nodeIndexInParent, i) || hasChanges;
91
- }
92
- }
93
- return hasChanges;
94
- }
95
- function shouldRemoveEmptyNode(node) {
96
- if (!isFormattingNode(node)) {
97
- return false;
98
- }
99
- if (!hasChildren(node) || node.children.length === 0) {
100
- return true;
101
- }
102
- return false;
103
- }
104
- function mergeAdjacentNodes(node) {
105
- let hasChanges = false;
106
- for (let i = 0; i < node.children.length - 1; i++) {
107
- const current = node.children[i];
108
- const next = node.children[i + 1];
109
- if (canMerge(current, next)) {
110
- mergeNodes(current, next);
111
- node.children.splice(i, 1);
112
- hasChanges = true;
113
- i--;
114
- }
115
- }
116
- for (const child of node.children) {
117
- if (hasChildren(child)) {
118
- hasChanges = mergeAdjacentNodes(child) || hasChanges;
119
- }
120
- }
121
- return hasChanges;
122
- }
123
- function reorderFormattingNodes(node) {
124
- let hasChanges = true;
125
- let anyChanges = false;
126
- while (hasChanges) {
127
- hasChanges = false;
128
- hasChanges = bubbleFormattingNodes(node) || hasChanges;
129
- if (hasChanges) {
130
- anyChanges = true;
131
- }
132
- }
133
- return anyChanges;
134
- }
135
- function removeDuplicateFormatting(node, ancestorsFormattingNodeTypes, parent, nodeIndexInParent) {
136
- let hasChanges = false;
137
- if (!hasChildren(node)) {
138
- return hasChanges;
139
- }
140
- const newAncestorsFormattingNodeTypes = isFormattingNode(node)
141
- ? [...ancestorsFormattingNodeTypes, node.type]
142
- : ancestorsFormattingNodeTypes;
143
- for (let i = 0; i < node.children.length; i++) {
144
- const child = node.children[i];
145
- if (hasChildren(child)) {
146
- hasChanges = removeDuplicateFormatting(child, newAncestorsFormattingNodeTypes, node, i) || hasChanges;
147
- }
148
- }
149
- if (!parent || nodeIndexInParent === undefined) {
150
- return hasChanges;
151
- }
152
- if (ancestorsFormattingNodeTypes.includes(node.type)) {
153
- parent.children.splice(nodeIndexInParent, 1, ...node.children);
154
- hasChanges = true;
155
- }
156
- return hasChanges;
157
- }
158
- function cleanupEmptyNodes(node) {
159
- let hasChanges = false;
160
- if (!hasChildren(node)) {
161
- return hasChanges;
162
- }
163
- for (let i = node.children.length - 1; i >= 0; i--) {
164
- const child = node.children[i];
165
- if (hasChildren(child)) {
166
- hasChanges = cleanupEmptyNodes(child) || hasChanges;
167
- }
168
- }
169
- for (let i = node.children.length - 1; i >= 0; i--) {
170
- const child = node.children[i];
171
- if (shouldRemoveEmptyNode(child)) {
172
- node.children.splice(i, 1);
173
- hasChanges = true;
174
- }
175
- }
176
- return hasChanges;
177
- }
178
- function normalizeCast(root) {
179
- let hasChanges = true;
180
- const currentRoot = JSON.parse(JSON.stringify(root));
181
- while (hasChanges) {
182
- hasChanges = false;
183
- hasChanges = mergeAdjacentNodes(currentRoot) || hasChanges;
184
- hasChanges = reorderFormattingNodes(currentRoot) || hasChanges;
185
- hasChanges = removeDuplicateFormatting(currentRoot, []) || hasChanges;
186
- hasChanges = cleanupEmptyNodes(currentRoot) || hasChanges;
187
- }
188
- return currentRoot;
189
- }
190
- //# sourceMappingURL=normalize-cast.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"normalize-cast.js","sourceRoot":"","sources":["../../../../../../packages/cast/src/lib/normalize-cast.ts"],"names":[],"mappings":";;;AAgXA,sCAqBC;AA/XY,QAAA,mBAAmB,GAAG;IACjC,IAAI,EAAE,CAAC;IACP,MAAM,EAAE,CAAC;IACT,SAAS,EAAE,CAAC;IACZ,aAAa,EAAE,CAAC;IAChB,SAAS,EAAE,CAAC;CACJ,CAAC;AAKX,SAAS,WAAW,CAAC,IAAsB;IACzC,OAAO,UAAU,IAAI,IAAI,IAAI,KAAK,CAAC,OAAO,CAAE,IAA8B,CAAC,QAAQ,CAAC,CAAC;AACvF,CAAC;AAKD,SAAS,gBAAgB,CAAC,IAAa;IACrC,MAAM,eAAe,GAAG,CAAC,MAAM,EAAE,QAAQ,EAAE,WAAW,EAAE,eAAe,EAAE,WAAW,CAAC,CAAC;IACtF,OAAO,eAAe,CAAC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,OAAO,UAAU,CAAC;AACpB,CAAC;AASD,SAAgB,aAAa,CAAC,IAAU;IACtC,IAAI,UAAU,GAAG,IAAI,CAAC;IACtB,MAAM,WAAW,GAAG,IAAI,CAAC,KAAK,CAAC,IAAI,CAAC,SAAS,CAAC,IAAI,CAAC,CAAS,CAAC;IAE7D,OAAO,UAAU,EAAE,CAAC;QAClB,UAAU,GAAG,KAAK,CAAC;QAGnB,UAAU,GAAG,kBAAkB,CAAC,WAAW,CAAC,IAAI,UAAU,CAAC;QAG3D,UAAU,GAAG,sBAAsB,CAAC,WAAW,CAAC,IAAI,UAAU,CAAC;QAG/D,UAAU,GAAG,yBAAyB,CAAC,WAAW,EAAE,EAAE,CAAC,IAAI,UAAU,CAAC;QAGtE,UAAU,GAAG,iBAAiB,CAAC,WAAW,CAAC,IAAI,UAAU,CAAC;IAC5D,CAAC;IAED,OAAO,WAAW,CAAC;AACrB,CAAC"}
@@ -1,105 +0,0 @@
1
- import { Node, Literal as UnistLiteral, Parent as UnistParent } from "unist";
2
- export type Content = BlockContent | InlineContent;
3
- export type BlockContent = BlockContentMap[keyof BlockContentMap];
4
- export type InlineContent = InlineContentMap[keyof InlineContentMap];
5
- export interface BlockContentMap {
6
- paragraph: Paragraph;
7
- heading: Heading;
8
- list: List;
9
- listItem: ListItem;
10
- blockquote: Blockquote;
11
- code: Code;
12
- }
13
- export interface InlineContentMap {
14
- text: Text;
15
- bold: Bold;
16
- italic: Italic;
17
- underline: Underline;
18
- strikethrough: Strikethrough;
19
- inlineCode: InlineCode;
20
- highlight: Highlight;
21
- contentValue: InterpolatedContentValue;
22
- externalLink: ExternalLink;
23
- internalLink: InternalLink;
24
- }
25
- export interface Parent extends UnistParent {
26
- children: Content[];
27
- }
28
- export interface Literal extends UnistLiteral {
29
- value: string;
30
- }
31
- export interface Root extends Parent {
32
- type: "root";
33
- }
34
- export interface Paragraph extends Parent {
35
- type: "paragraph";
36
- children: InlineContent[];
37
- }
38
- export interface Heading extends Parent {
39
- type: "heading";
40
- level: 1 | 2 | 3 | 4 | 5 | 6;
41
- children: InlineContent[];
42
- }
43
- export interface List extends Parent {
44
- type: "list";
45
- children: ListItem[];
46
- ordered: boolean;
47
- start?: number;
48
- }
49
- export interface ListItem extends Parent {
50
- type: "listItem";
51
- children: InlineContent[];
52
- }
53
- export interface Blockquote extends Parent {
54
- type: "blockquote";
55
- children: InlineContent[];
56
- }
57
- export interface Code extends Parent {
58
- type: "code";
59
- lang?: string;
60
- children: Text[];
61
- }
62
- export interface Text extends Literal {
63
- type: "text";
64
- }
65
- export interface Bold extends Parent {
66
- type: "bold";
67
- children: InlineContent[];
68
- }
69
- export interface Italic extends Parent {
70
- type: "italic";
71
- children: InlineContent[];
72
- }
73
- export interface Underline extends Parent {
74
- type: "underline";
75
- children: InlineContent[];
76
- }
77
- export interface Strikethrough extends Parent {
78
- type: "strikethrough";
79
- children: InlineContent[];
80
- }
81
- export interface InlineCode extends Literal {
82
- type: "inlineCode";
83
- }
84
- export interface Highlight extends Parent {
85
- type: "highlight";
86
- children: InlineContent[];
87
- }
88
- export interface InterpolatedContentValue extends Node {
89
- type: "contentValue";
90
- prn: string;
91
- value?: Root;
92
- }
93
- export interface ExternalLink extends Parent {
94
- type: "externalLink";
95
- children: Text[];
96
- url: string;
97
- target?: "_parent" | "_top" | "blank" | "self";
98
- }
99
- export interface InternalLink extends Parent {
100
- type: "internalLink";
101
- children: Text[];
102
- prn: string;
103
- url?: string;
104
- target?: "_parent" | "_top" | "blank" | "self";
105
- }
@@ -1,3 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- //# sourceMappingURL=schema.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"schema.js","sourceRoot":"","sources":["../../../../../../../packages/cast/src/lib/schemas/schema.ts"],"names":[],"mappings":""}
@@ -1,2 +0,0 @@
1
- export declare const URL_REGEX: RegExp;
2
- export declare function validateCast(value: unknown): void;