@knpkv/atlassian-common 0.2.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.
- package/CHANGELOG.md +11 -0
- package/LICENSE +21 -0
- package/README.md +107 -0
- package/dist/Brand.d.ts +118 -0
- package/dist/Brand.d.ts.map +1 -0
- package/dist/Brand.js +107 -0
- package/dist/Brand.js.map +1 -0
- package/dist/Hash.d.ts +53 -0
- package/dist/Hash.d.ts.map +1 -0
- package/dist/Hash.js +63 -0
- package/dist/Hash.js.map +1 -0
- package/dist/SerializeError.d.ts +48 -0
- package/dist/SerializeError.d.ts.map +1 -0
- package/dist/SerializeError.js +42 -0
- package/dist/SerializeError.js.map +1 -0
- package/dist/ast/BlockNode.d.ts +429 -0
- package/dist/ast/BlockNode.d.ts.map +1 -0
- package/dist/ast/BlockNode.js +279 -0
- package/dist/ast/BlockNode.js.map +1 -0
- package/dist/ast/Document.d.ts +255 -0
- package/dist/ast/Document.d.ts.map +1 -0
- package/dist/ast/Document.js +80 -0
- package/dist/ast/Document.js.map +1 -0
- package/dist/ast/InlineNode.d.ts +483 -0
- package/dist/ast/InlineNode.d.ts.map +1 -0
- package/dist/ast/InlineNode.js +268 -0
- package/dist/ast/InlineNode.js.map +1 -0
- package/dist/ast/MacroNode.d.ts +214 -0
- package/dist/ast/MacroNode.d.ts.map +1 -0
- package/dist/ast/MacroNode.js +110 -0
- package/dist/ast/MacroNode.js.map +1 -0
- package/dist/ast/index.d.ts +10 -0
- package/dist/ast/index.d.ts.map +1 -0
- package/dist/ast/index.js +14 -0
- package/dist/ast/index.js.map +1 -0
- package/dist/auth/OAuthEndpoints.d.ts +95 -0
- package/dist/auth/OAuthEndpoints.d.ts.map +1 -0
- package/dist/auth/OAuthEndpoints.js +112 -0
- package/dist/auth/OAuthEndpoints.js.map +1 -0
- package/dist/auth/OAuthErrors.d.ts +76 -0
- package/dist/auth/OAuthErrors.d.ts.map +1 -0
- package/dist/auth/OAuthErrors.js +85 -0
- package/dist/auth/OAuthErrors.js.map +1 -0
- package/dist/auth/OAuthOperations.d.ts +87 -0
- package/dist/auth/OAuthOperations.d.ts.map +1 -0
- package/dist/auth/OAuthOperations.js +169 -0
- package/dist/auth/OAuthOperations.js.map +1 -0
- package/dist/auth/OAuthResponseSchemas.d.ts +65 -0
- package/dist/auth/OAuthResponseSchemas.d.ts.map +1 -0
- package/dist/auth/OAuthResponseSchemas.js +47 -0
- package/dist/auth/OAuthResponseSchemas.js.map +1 -0
- package/dist/auth/index.d.ts +11 -0
- package/dist/auth/index.d.ts.map +1 -0
- package/dist/auth/index.js +16 -0
- package/dist/auth/index.js.map +1 -0
- package/dist/auth/uuid.d.ts +14 -0
- package/dist/auth/uuid.d.ts.map +1 -0
- package/dist/auth/uuid.js +14 -0
- package/dist/auth/uuid.js.map +1 -0
- package/dist/config/ConfigPaths.d.ts +95 -0
- package/dist/config/ConfigPaths.d.ts.map +1 -0
- package/dist/config/ConfigPaths.js +102 -0
- package/dist/config/ConfigPaths.js.map +1 -0
- package/dist/config/OAuthSchemas.d.ts +144 -0
- package/dist/config/OAuthSchemas.d.ts.map +1 -0
- package/dist/config/OAuthSchemas.js +107 -0
- package/dist/config/OAuthSchemas.js.map +1 -0
- package/dist/config/TokenStorage.d.ts +96 -0
- package/dist/config/TokenStorage.d.ts.map +1 -0
- package/dist/config/TokenStorage.js +128 -0
- package/dist/config/TokenStorage.js.map +1 -0
- package/dist/config/index.d.ts +9 -0
- package/dist/config/index.d.ts.map +1 -0
- package/dist/config/index.js +12 -0
- package/dist/config/index.js.map +1 -0
- package/dist/index.d.ts +13 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +20 -0
- package/dist/index.js.map +1 -0
- package/dist/parsers/index.d.ts +7 -0
- package/dist/parsers/index.d.ts.map +1 -0
- package/dist/parsers/index.js +8 -0
- package/dist/parsers/index.js.map +1 -0
- package/dist/serializers/MarkdownSerializer.d.ts +63 -0
- package/dist/serializers/MarkdownSerializer.d.ts.map +1 -0
- package/dist/serializers/MarkdownSerializer.js +367 -0
- package/dist/serializers/MarkdownSerializer.js.map +1 -0
- package/dist/serializers/index.d.ts +7 -0
- package/dist/serializers/index.d.ts.map +1 -0
- package/dist/serializers/index.js +7 -0
- package/dist/serializers/index.js.map +1 -0
- package/package.json +86 -0
- package/src/Brand.ts +142 -0
- package/src/Hash.ts +68 -0
- package/src/SerializeError.ts +50 -0
- package/src/ast/BlockNode.ts +386 -0
- package/src/ast/Document.ts +101 -0
- package/src/ast/InlineNode.ts +328 -0
- package/src/ast/MacroNode.ts +172 -0
- package/src/ast/index.ts +87 -0
- package/src/auth/OAuthEndpoints.ts +142 -0
- package/src/auth/OAuthErrors.ts +101 -0
- package/src/auth/OAuthOperations.ts +276 -0
- package/src/auth/OAuthResponseSchemas.ts +70 -0
- package/src/auth/index.ts +47 -0
- package/src/auth/uuid.ts +14 -0
- package/src/config/ConfigPaths.ts +179 -0
- package/src/config/OAuthSchemas.ts +146 -0
- package/src/config/TokenStorage.ts +228 -0
- package/src/config/index.ts +43 -0
- package/src/index.ts +34 -0
- package/src/parsers/index.ts +8 -0
- package/src/serializers/MarkdownSerializer.ts +498 -0
- package/src/serializers/index.ts +7 -0
- package/test/Brand.test.ts +90 -0
- package/test/MarkdownSerializer.test.ts +82 -0
- package/test/OAuthEndpoints.test.ts +109 -0
- package/test/OAuthOperations.test.ts +315 -0
- package/tsconfig.json +11 -0
- package/tsconfig.tsbuildinfo +1 -0
- package/vitest.config.ts +12 -0
|
@@ -0,0 +1,279 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Block-level AST nodes for Atlassian content (headings, paragraphs, tables, lists, etc.).
|
|
3
|
+
*
|
|
4
|
+
* **Mental model**
|
|
5
|
+
*
|
|
6
|
+
* - **Schema-driven ADT**: Each node is an Effect `Schema.Struct` with a `_tag` discriminant,
|
|
7
|
+
* composed into the {@link BlockNode} union via `Schema.Union`.
|
|
8
|
+
* - **Recursive via suspend**: `List` → `ListItem` → `BlockNode` cycles use `Schema.suspend`
|
|
9
|
+
* to break infinite type recursion.
|
|
10
|
+
* - **Inline children**: Most blocks contain `InlineNode` children for text-level content.
|
|
11
|
+
*
|
|
12
|
+
* @module
|
|
13
|
+
*/
|
|
14
|
+
import * as Schema from "effect/Schema";
|
|
15
|
+
import { InlineNode } from "./InlineNode.js";
|
|
16
|
+
/**
|
|
17
|
+
* Schema version for migration support.
|
|
18
|
+
*
|
|
19
|
+
* @category Version
|
|
20
|
+
*/
|
|
21
|
+
export const SchemaVersion = Schema.Number.pipe(Schema.int(), Schema.positive(), Schema.optionalWith({ default: () => 1 }));
|
|
22
|
+
/**
|
|
23
|
+
* Optional raw source for exact roundtrip preservation.
|
|
24
|
+
*
|
|
25
|
+
* @category BlockNode
|
|
26
|
+
*/
|
|
27
|
+
export const RawSource = Schema.optional(Schema.String);
|
|
28
|
+
/**
|
|
29
|
+
* Heading element (h1-h6).
|
|
30
|
+
*
|
|
31
|
+
* @example
|
|
32
|
+
* ```typescript
|
|
33
|
+
* import { Heading, Text } from "@knpkv/atlassian-common/ast"
|
|
34
|
+
*
|
|
35
|
+
* const h1 = new Heading({
|
|
36
|
+
* level: 1,
|
|
37
|
+
* children: [new Text({ value: "Introduction" })]
|
|
38
|
+
* })
|
|
39
|
+
* ```
|
|
40
|
+
*
|
|
41
|
+
* @category BlockNode
|
|
42
|
+
*/
|
|
43
|
+
export class Heading extends Schema.TaggedClass()("Heading", {
|
|
44
|
+
version: SchemaVersion,
|
|
45
|
+
level: Schema.Literal(1, 2, 3, 4, 5, 6),
|
|
46
|
+
children: Schema.Array(InlineNode),
|
|
47
|
+
rawSource: RawSource
|
|
48
|
+
}) {
|
|
49
|
+
}
|
|
50
|
+
/**
|
|
51
|
+
* Text alignment options.
|
|
52
|
+
*
|
|
53
|
+
* @category BlockNode
|
|
54
|
+
*/
|
|
55
|
+
export const TextAlignment = Schema.Literal("left", "center", "right");
|
|
56
|
+
/**
|
|
57
|
+
* Paragraph element with optional alignment and indentation.
|
|
58
|
+
*
|
|
59
|
+
* @example
|
|
60
|
+
* ```typescript
|
|
61
|
+
* import { Paragraph, Text } from "@knpkv/atlassian-common/ast"
|
|
62
|
+
*
|
|
63
|
+
* const para = new Paragraph({
|
|
64
|
+
* children: [new Text({ value: "Hello world" })]
|
|
65
|
+
* })
|
|
66
|
+
* ```
|
|
67
|
+
*
|
|
68
|
+
* @category BlockNode
|
|
69
|
+
*/
|
|
70
|
+
export class Paragraph extends Schema.TaggedClass()("Paragraph", {
|
|
71
|
+
version: SchemaVersion,
|
|
72
|
+
alignment: Schema.optional(TextAlignment),
|
|
73
|
+
indent: Schema.optional(Schema.Number),
|
|
74
|
+
children: Schema.Array(InlineNode),
|
|
75
|
+
rawSource: RawSource
|
|
76
|
+
}) {
|
|
77
|
+
}
|
|
78
|
+
/**
|
|
79
|
+
* Code block with optional language.
|
|
80
|
+
*
|
|
81
|
+
* @example
|
|
82
|
+
* ```typescript
|
|
83
|
+
* import { CodeBlock } from "@knpkv/atlassian-common/ast"
|
|
84
|
+
*
|
|
85
|
+
* const code = new CodeBlock({
|
|
86
|
+
* language: "typescript",
|
|
87
|
+
* code: "const x = 1"
|
|
88
|
+
* })
|
|
89
|
+
* ```
|
|
90
|
+
*
|
|
91
|
+
* @category BlockNode
|
|
92
|
+
*/
|
|
93
|
+
export class CodeBlock extends Schema.TaggedClass()("CodeBlock", {
|
|
94
|
+
version: SchemaVersion,
|
|
95
|
+
language: Schema.optional(Schema.String),
|
|
96
|
+
code: Schema.String,
|
|
97
|
+
rawSource: RawSource
|
|
98
|
+
}) {
|
|
99
|
+
}
|
|
100
|
+
/**
|
|
101
|
+
* Thematic break / horizontal rule.
|
|
102
|
+
*
|
|
103
|
+
* @example
|
|
104
|
+
* ```typescript
|
|
105
|
+
* import { ThematicBreak } from "@knpkv/atlassian-common/ast"
|
|
106
|
+
*
|
|
107
|
+
* const hr = new ThematicBreak({})
|
|
108
|
+
* ```
|
|
109
|
+
*
|
|
110
|
+
* @category BlockNode
|
|
111
|
+
*/
|
|
112
|
+
export class ThematicBreak extends Schema.TaggedClass()("ThematicBreak", {
|
|
113
|
+
rawSource: RawSource
|
|
114
|
+
}) {
|
|
115
|
+
}
|
|
116
|
+
/**
|
|
117
|
+
* Attachment reference for images.
|
|
118
|
+
*
|
|
119
|
+
* @category BlockNode
|
|
120
|
+
*/
|
|
121
|
+
export const ImageAttachment = Schema.Struct({
|
|
122
|
+
filename: Schema.String,
|
|
123
|
+
version: Schema.optional(Schema.Number)
|
|
124
|
+
});
|
|
125
|
+
/**
|
|
126
|
+
* Image element with support for both URL and attachments.
|
|
127
|
+
*
|
|
128
|
+
* @example
|
|
129
|
+
* ```typescript
|
|
130
|
+
* import { Image } from "@knpkv/atlassian-common/ast"
|
|
131
|
+
*
|
|
132
|
+
* const img = new Image({
|
|
133
|
+
* src: "https://example.com/image.png",
|
|
134
|
+
* alt: "Example image"
|
|
135
|
+
* })
|
|
136
|
+
* ```
|
|
137
|
+
*
|
|
138
|
+
* @category BlockNode
|
|
139
|
+
*/
|
|
140
|
+
export class Image extends Schema.TaggedClass()("Image", {
|
|
141
|
+
version: SchemaVersion,
|
|
142
|
+
src: Schema.optional(Schema.String),
|
|
143
|
+
attachment: Schema.optional(ImageAttachment),
|
|
144
|
+
alt: Schema.optional(Schema.String),
|
|
145
|
+
title: Schema.optional(Schema.String),
|
|
146
|
+
align: Schema.optional(Schema.String),
|
|
147
|
+
width: Schema.optional(Schema.Number),
|
|
148
|
+
rawSource: RawSource
|
|
149
|
+
}) {
|
|
150
|
+
}
|
|
151
|
+
/**
|
|
152
|
+
* Table cell element.
|
|
153
|
+
*
|
|
154
|
+
* @example
|
|
155
|
+
* ```typescript
|
|
156
|
+
* import { TableCell, Text } from "@knpkv/atlassian-common/ast"
|
|
157
|
+
*
|
|
158
|
+
* const cell = new TableCell({
|
|
159
|
+
* isHeader: true,
|
|
160
|
+
* children: [new Text({ value: "Header" })]
|
|
161
|
+
* })
|
|
162
|
+
* ```
|
|
163
|
+
*
|
|
164
|
+
* @category BlockNode
|
|
165
|
+
*/
|
|
166
|
+
export class TableCell extends Schema.TaggedClass()("TableCell", {
|
|
167
|
+
isHeader: Schema.optionalWith(Schema.Boolean, { default: () => false }),
|
|
168
|
+
children: Schema.Array(InlineNode),
|
|
169
|
+
rawSource: RawSource
|
|
170
|
+
}) {
|
|
171
|
+
}
|
|
172
|
+
/**
|
|
173
|
+
* Table row element.
|
|
174
|
+
*
|
|
175
|
+
* @category BlockNode
|
|
176
|
+
*/
|
|
177
|
+
export class TableRow extends Schema.TaggedClass()("TableRow", {
|
|
178
|
+
cells: Schema.Array(TableCell),
|
|
179
|
+
rawSource: RawSource
|
|
180
|
+
}) {
|
|
181
|
+
}
|
|
182
|
+
/**
|
|
183
|
+
* Table element with optional header row.
|
|
184
|
+
*
|
|
185
|
+
* @category BlockNode
|
|
186
|
+
*/
|
|
187
|
+
export class Table extends Schema.TaggedClass()("Table", {
|
|
188
|
+
version: SchemaVersion,
|
|
189
|
+
header: Schema.optional(TableRow),
|
|
190
|
+
rows: Schema.Array(TableRow),
|
|
191
|
+
rawSource: RawSource
|
|
192
|
+
}) {
|
|
193
|
+
}
|
|
194
|
+
/**
|
|
195
|
+
* Unsupported block element - preserves raw content for round-tripping.
|
|
196
|
+
*
|
|
197
|
+
* @category BlockNode
|
|
198
|
+
*/
|
|
199
|
+
export class UnsupportedBlock extends Schema.TaggedClass()("UnsupportedBlock", {
|
|
200
|
+
rawHtml: Schema.optional(Schema.String),
|
|
201
|
+
rawMarkdown: Schema.optional(Schema.String),
|
|
202
|
+
rawAdf: Schema.optional(Schema.String),
|
|
203
|
+
source: Schema.Literal("confluence", "markdown", "adf")
|
|
204
|
+
}) {
|
|
205
|
+
}
|
|
206
|
+
// Non-recursive block nodes
|
|
207
|
+
const SimpleBlockNode = Schema.Union(Heading, Paragraph, CodeBlock, ThematicBreak, Image, Table, UnsupportedBlock);
|
|
208
|
+
/**
|
|
209
|
+
* Block quote element with nested block content.
|
|
210
|
+
*
|
|
211
|
+
* @category BlockNode
|
|
212
|
+
*/
|
|
213
|
+
export const BlockQuote = Schema.Struct({
|
|
214
|
+
_tag: Schema.Literal("BlockQuote"),
|
|
215
|
+
version: SchemaVersion,
|
|
216
|
+
children: Schema.Array(SimpleBlockNode),
|
|
217
|
+
rawSource: RawSource
|
|
218
|
+
});
|
|
219
|
+
/**
|
|
220
|
+
* List item with nested block content.
|
|
221
|
+
*
|
|
222
|
+
* @category BlockNode
|
|
223
|
+
*/
|
|
224
|
+
export const ListItem = Schema.Struct({
|
|
225
|
+
_tag: Schema.Literal("ListItem"),
|
|
226
|
+
checked: Schema.optional(Schema.Boolean),
|
|
227
|
+
children: Schema.Array(SimpleBlockNode),
|
|
228
|
+
rawSource: RawSource
|
|
229
|
+
});
|
|
230
|
+
/**
|
|
231
|
+
* List element (ordered or unordered).
|
|
232
|
+
*
|
|
233
|
+
* @category BlockNode
|
|
234
|
+
*/
|
|
235
|
+
export const List = Schema.Struct({
|
|
236
|
+
_tag: Schema.Literal("List"),
|
|
237
|
+
version: SchemaVersion,
|
|
238
|
+
ordered: Schema.Boolean,
|
|
239
|
+
start: Schema.optional(Schema.Number),
|
|
240
|
+
children: Schema.Array(ListItem),
|
|
241
|
+
rawSource: RawSource
|
|
242
|
+
});
|
|
243
|
+
/**
|
|
244
|
+
* Task item with status.
|
|
245
|
+
*
|
|
246
|
+
* @category BlockNode
|
|
247
|
+
*/
|
|
248
|
+
export const TaskItem = Schema.Struct({
|
|
249
|
+
_tag: Schema.Literal("TaskItem"),
|
|
250
|
+
id: Schema.String,
|
|
251
|
+
uuid: Schema.String,
|
|
252
|
+
status: Schema.Literal("incomplete", "complete"),
|
|
253
|
+
body: Schema.Array(InlineNode),
|
|
254
|
+
rawSource: RawSource
|
|
255
|
+
});
|
|
256
|
+
/**
|
|
257
|
+
* Task list.
|
|
258
|
+
*
|
|
259
|
+
* @category BlockNode
|
|
260
|
+
*/
|
|
261
|
+
export const TaskList = Schema.Struct({
|
|
262
|
+
_tag: Schema.Literal("TaskList"),
|
|
263
|
+
version: SchemaVersion,
|
|
264
|
+
children: Schema.Array(TaskItem),
|
|
265
|
+
rawSource: RawSource
|
|
266
|
+
});
|
|
267
|
+
/**
|
|
268
|
+
* Union of all block node types.
|
|
269
|
+
*
|
|
270
|
+
* @category BlockNode
|
|
271
|
+
*/
|
|
272
|
+
export const BlockNode = Schema.Union(Heading, Paragraph, CodeBlock, ThematicBreak, BlockQuote, Image, Table, List, TaskList, UnsupportedBlock);
|
|
273
|
+
/**
|
|
274
|
+
* Simple block nodes (non-recursive).
|
|
275
|
+
*
|
|
276
|
+
* @category BlockNode
|
|
277
|
+
*/
|
|
278
|
+
export { SimpleBlockNode };
|
|
279
|
+
//# sourceMappingURL=BlockNode.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"BlockNode.js","sourceRoot":"","sources":["../../src/ast/BlockNode.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;GAYG;AACH,OAAO,KAAK,MAAM,MAAM,eAAe,CAAA;AACvC,OAAO,EAAE,UAAU,EAAqC,MAAM,iBAAiB,CAAA;AAE/E;;;;GAIG;AACH,MAAM,CAAC,MAAM,aAAa,GAAG,MAAM,CAAC,MAAM,CAAC,IAAI,CAC7C,MAAM,CAAC,GAAG,EAAE,EACZ,MAAM,CAAC,QAAQ,EAAE,EACjB,MAAM,CAAC,YAAY,CAAC,EAAE,OAAO,EAAE,GAAG,EAAE,CAAC,CAAC,EAAE,CAAC,CAC1C,CAAA;AAED;;;;GAIG;AACH,MAAM,CAAC,MAAM,SAAS,GAAG,MAAM,CAAC,QAAQ,CAAC,MAAM,CAAC,MAAM,CAAC,CAAA;AAEvD;;;;;;;;;;;;;;GAcG;AACH,MAAM,OAAO,OAAQ,SAAQ,MAAM,CAAC,WAAW,EAAW,CAAC,SAAS,EAAE;IACpE,OAAO,EAAE,aAAa;IACtB,KAAK,EAAE,MAAM,CAAC,OAAO,CAAC,CAAC,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* Root AST node wrapping a sequence of {@link DocumentNode} children.
|
|
3
|
+
*
|
|
4
|
+
* **Mental model**
|
|
5
|
+
*
|
|
6
|
+
* - **Document = version + children**: The top-level container for parsed Atlassian content.
|
|
7
|
+
* `children` is a union of `BlockNode | MacroNode`.
|
|
8
|
+
* - **Raw source preservation**: Optional `rawSource` field enables lossless roundtripping.
|
|
9
|
+
*
|
|
10
|
+
* **Common tasks**
|
|
11
|
+
*
|
|
12
|
+
* - Construct a document: {@link makeDocument}
|
|
13
|
+
* - Type-guard check: {@link isDocument}
|
|
14
|
+
*
|
|
15
|
+
* @module
|
|
16
|
+
*/
|
|
17
|
+
import * as Schema from "effect/Schema";
|
|
18
|
+
import { type BlockNode as BlockNodeType } from "./BlockNode.js";
|
|
19
|
+
import { type MacroNode as MacroNodeType } from "./MacroNode.js";
|
|
20
|
+
/**
|
|
21
|
+
* Document node - represents a Block or Macro node.
|
|
22
|
+
*
|
|
23
|
+
* @category Document
|
|
24
|
+
*/
|
|
25
|
+
export declare const DocumentNode: Schema.Union<[Schema.Union<[typeof import("./BlockNode.js").Heading, typeof import("./BlockNode.js").Paragraph, typeof import("./BlockNode.js").CodeBlock, typeof import("./BlockNode.js").ThematicBreak, Schema.Struct<{
|
|
26
|
+
_tag: Schema.Literal<["BlockQuote"]>;
|
|
27
|
+
version: Schema.optionalWith<Schema.filter<Schema.filter<typeof Schema.Number>>, {
|
|
28
|
+
default: () => number;
|
|
29
|
+
}>;
|
|
30
|
+
children: Schema.Array$<Schema.Union<[typeof import("./BlockNode.js").Heading, typeof import("./BlockNode.js").Paragraph, typeof import("./BlockNode.js").CodeBlock, typeof import("./BlockNode.js").ThematicBreak, typeof import("./BlockNode.js").Image, typeof import("./BlockNode.js").Table, typeof import("./BlockNode.js").UnsupportedBlock]>>;
|
|
31
|
+
rawSource: Schema.optional<typeof Schema.String>;
|
|
32
|
+
}>, typeof import("./BlockNode.js").Image, typeof import("./BlockNode.js").Table, Schema.Struct<{
|
|
33
|
+
_tag: Schema.Literal<["List"]>;
|
|
34
|
+
version: Schema.optionalWith<Schema.filter<Schema.filter<typeof Schema.Number>>, {
|
|
35
|
+
default: () => number;
|
|
36
|
+
}>;
|
|
37
|
+
ordered: typeof Schema.Boolean;
|
|
38
|
+
start: Schema.optional<typeof Schema.Number>;
|
|
39
|
+
children: Schema.Array$<Schema.Struct<{
|
|
40
|
+
_tag: Schema.Literal<["ListItem"]>;
|
|
41
|
+
checked: Schema.optional<typeof Schema.Boolean>;
|
|
42
|
+
children: Schema.Array$<Schema.Union<[typeof import("./BlockNode.js").Heading, typeof import("./BlockNode.js").Paragraph, typeof import("./BlockNode.js").CodeBlock, typeof import("./BlockNode.js").ThematicBreak, typeof import("./BlockNode.js").Image, typeof import("./BlockNode.js").Table, typeof import("./BlockNode.js").UnsupportedBlock]>>;
|
|
43
|
+
rawSource: Schema.optional<typeof Schema.String>;
|
|
44
|
+
}>>;
|
|
45
|
+
rawSource: Schema.optional<typeof Schema.String>;
|
|
46
|
+
}>, Schema.Struct<{
|
|
47
|
+
_tag: Schema.Literal<["TaskList"]>;
|
|
48
|
+
version: Schema.optionalWith<Schema.filter<Schema.filter<typeof Schema.Number>>, {
|
|
49
|
+
default: () => number;
|
|
50
|
+
}>;
|
|
51
|
+
children: Schema.Array$<Schema.Struct<{
|
|
52
|
+
_tag: Schema.Literal<["TaskItem"]>;
|
|
53
|
+
id: typeof Schema.String;
|
|
54
|
+
uuid: typeof Schema.String;
|
|
55
|
+
status: Schema.Literal<["incomplete", "complete"]>;
|
|
56
|
+
body: Schema.Array$<Schema.Union<[typeof import("./InlineNode.ts").Text, typeof import("./InlineNode.ts").Strong, typeof import("./InlineNode.ts").Emphasis, typeof import("./InlineNode.ts").InlineCode, typeof import("./InlineNode.ts").Link, typeof import("./InlineNode.ts").LineBreak, typeof import("./InlineNode.ts").Emoticon, typeof import("./InlineNode.ts").UserMention, typeof import("./InlineNode.ts").DateTime, typeof import("./InlineNode.ts").Underline, typeof import("./InlineNode.ts").Subscript, typeof import("./InlineNode.ts").Superscript, typeof import("./InlineNode.ts").Strikethrough, typeof import("./InlineNode.ts").ColoredText, typeof import("./InlineNode.ts").Highlight, typeof import("./InlineNode.ts").UnsupportedInline]>>;
|
|
57
|
+
rawSource: Schema.optional<typeof Schema.String>;
|
|
58
|
+
}>>;
|
|
59
|
+
rawSource: Schema.optional<typeof Schema.String>;
|
|
60
|
+
}>, typeof import("./BlockNode.js").UnsupportedBlock]>, Schema.Union<[Schema.Struct<{
|
|
61
|
+
_tag: Schema.Literal<["InfoPanel"]>;
|
|
62
|
+
version: Schema.optionalWith<Schema.filter<Schema.filter<typeof Schema.Number>>, {
|
|
63
|
+
default: () => number;
|
|
64
|
+
}>;
|
|
65
|
+
panelType: Schema.Literal<["info", "warning", "note", "tip", "error", "panel"]>;
|
|
66
|
+
title: Schema.optional<typeof Schema.String>;
|
|
67
|
+
children: Schema.Array$<Schema.Union<[typeof import("./BlockNode.js").Heading, typeof import("./BlockNode.js").Paragraph, typeof import("./BlockNode.js").CodeBlock, typeof import("./BlockNode.js").ThematicBreak, typeof import("./BlockNode.js").Image, typeof import("./BlockNode.js").Table, typeof import("./BlockNode.js").UnsupportedBlock]>>;
|
|
68
|
+
rawSource: Schema.optional<typeof Schema.String>;
|
|
69
|
+
}>, Schema.Struct<{
|
|
70
|
+
_tag: Schema.Literal<["ExpandMacro"]>;
|
|
71
|
+
version: Schema.optionalWith<Schema.filter<Schema.filter<typeof Schema.Number>>, {
|
|
72
|
+
default: () => number;
|
|
73
|
+
}>;
|
|
74
|
+
title: Schema.optional<typeof Schema.String>;
|
|
75
|
+
children: Schema.Array$<Schema.Union<[typeof import("./BlockNode.js").Heading, typeof import("./BlockNode.js").Paragraph, typeof import("./BlockNode.js").CodeBlock, typeof import("./BlockNode.js").ThematicBreak, typeof import("./BlockNode.js").Image, typeof import("./BlockNode.js").Table, typeof import("./BlockNode.js").UnsupportedBlock]>>;
|
|
76
|
+
rawSource: Schema.optional<typeof Schema.String>;
|
|
77
|
+
}>, Schema.Struct<{
|
|
78
|
+
_tag: Schema.Literal<["TocMacro"]>;
|
|
79
|
+
version: Schema.optionalWith<Schema.filter<Schema.filter<typeof Schema.Number>>, {
|
|
80
|
+
default: () => number;
|
|
81
|
+
}>;
|
|
82
|
+
minLevel: Schema.optional<typeof Schema.Number>;
|
|
83
|
+
maxLevel: Schema.optional<typeof Schema.Number>;
|
|
84
|
+
rawSource: Schema.optional<typeof Schema.String>;
|
|
85
|
+
}>, Schema.Struct<{
|
|
86
|
+
_tag: Schema.Literal<["CodeMacro"]>;
|
|
87
|
+
version: Schema.optionalWith<Schema.filter<Schema.filter<typeof Schema.Number>>, {
|
|
88
|
+
default: () => number;
|
|
89
|
+
}>;
|
|
90
|
+
language: Schema.optional<typeof Schema.String>;
|
|
91
|
+
title: Schema.optional<typeof Schema.String>;
|
|
92
|
+
code: typeof Schema.String;
|
|
93
|
+
lineNumbers: Schema.optionalWith<typeof Schema.Boolean, {
|
|
94
|
+
default: () => false;
|
|
95
|
+
}>;
|
|
96
|
+
collapse: Schema.optionalWith<typeof Schema.Boolean, {
|
|
97
|
+
default: () => false;
|
|
98
|
+
}>;
|
|
99
|
+
firstLine: Schema.optional<typeof Schema.Number>;
|
|
100
|
+
rawSource: Schema.optional<typeof Schema.String>;
|
|
101
|
+
}>, Schema.Struct<{
|
|
102
|
+
_tag: Schema.Literal<["StatusMacro"]>;
|
|
103
|
+
version: Schema.optionalWith<Schema.filter<Schema.filter<typeof Schema.Number>>, {
|
|
104
|
+
default: () => number;
|
|
105
|
+
}>;
|
|
106
|
+
text: typeof Schema.String;
|
|
107
|
+
color: Schema.Literal<["Grey", "Red", "Yellow", "Green", "Blue"]>;
|
|
108
|
+
rawSource: Schema.optional<typeof Schema.String>;
|
|
109
|
+
}>]>]>;
|
|
110
|
+
/**
|
|
111
|
+
* Type for document nodes.
|
|
112
|
+
*
|
|
113
|
+
* @category Types
|
|
114
|
+
*/
|
|
115
|
+
export type DocumentNode = BlockNodeType | MacroNodeType;
|
|
116
|
+
/**
|
|
117
|
+
* Document schema - the root AST node.
|
|
118
|
+
*
|
|
119
|
+
* @example
|
|
120
|
+
* ```typescript
|
|
121
|
+
* import { Document, Heading, Paragraph, Text } from "@knpkv/atlassian-common/ast"
|
|
122
|
+
* import * as Schema from "effect/Schema"
|
|
123
|
+
*
|
|
124
|
+
* const doc = {
|
|
125
|
+
* version: 1,
|
|
126
|
+
* children: [
|
|
127
|
+
* new Heading({ level: 1, children: [new Text({ value: "Title" })] }),
|
|
128
|
+
* new Paragraph({ children: [new Text({ value: "Content" })] })
|
|
129
|
+
* ]
|
|
130
|
+
* }
|
|
131
|
+
*
|
|
132
|
+
* const validated = Schema.decodeUnknownSync(Document)(doc)
|
|
133
|
+
* ```
|
|
134
|
+
*
|
|
135
|
+
* @category Document
|
|
136
|
+
*/
|
|
137
|
+
export declare const Document: Schema.Struct<{
|
|
138
|
+
version: Schema.optionalWith<Schema.filter<Schema.filter<typeof Schema.Number>>, {
|
|
139
|
+
default: () => number;
|
|
140
|
+
}>;
|
|
141
|
+
children: Schema.Array$<Schema.Union<[Schema.Union<[typeof import("./BlockNode.js").Heading, typeof import("./BlockNode.js").Paragraph, typeof import("./BlockNode.js").CodeBlock, typeof import("./BlockNode.js").ThematicBreak, Schema.Struct<{
|
|
142
|
+
_tag: Schema.Literal<["BlockQuote"]>;
|
|
143
|
+
version: Schema.optionalWith<Schema.filter<Schema.filter<typeof Schema.Number>>, {
|
|
144
|
+
default: () => number;
|
|
145
|
+
}>;
|
|
146
|
+
children: Schema.Array$<Schema.Union<[typeof import("./BlockNode.js").Heading, typeof import("./BlockNode.js").Paragraph, typeof import("./BlockNode.js").CodeBlock, typeof import("./BlockNode.js").ThematicBreak, typeof import("./BlockNode.js").Image, typeof import("./BlockNode.js").Table, typeof import("./BlockNode.js").UnsupportedBlock]>>;
|
|
147
|
+
rawSource: Schema.optional<typeof Schema.String>;
|
|
148
|
+
}>, typeof import("./BlockNode.js").Image, typeof import("./BlockNode.js").Table, Schema.Struct<{
|
|
149
|
+
_tag: Schema.Literal<["List"]>;
|
|
150
|
+
version: Schema.optionalWith<Schema.filter<Schema.filter<typeof Schema.Number>>, {
|
|
151
|
+
default: () => number;
|
|
152
|
+
}>;
|
|
153
|
+
ordered: typeof Schema.Boolean;
|
|
154
|
+
start: Schema.optional<typeof Schema.Number>;
|
|
155
|
+
children: Schema.Array$<Schema.Struct<{
|
|
156
|
+
_tag: Schema.Literal<["ListItem"]>;
|
|
157
|
+
checked: Schema.optional<typeof Schema.Boolean>;
|
|
158
|
+
children: Schema.Array$<Schema.Union<[typeof import("./BlockNode.js").Heading, typeof import("./BlockNode.js").Paragraph, typeof import("./BlockNode.js").CodeBlock, typeof import("./BlockNode.js").ThematicBreak, typeof import("./BlockNode.js").Image, typeof import("./BlockNode.js").Table, typeof import("./BlockNode.js").UnsupportedBlock]>>;
|
|
159
|
+
rawSource: Schema.optional<typeof Schema.String>;
|
|
160
|
+
}>>;
|
|
161
|
+
rawSource: Schema.optional<typeof Schema.String>;
|
|
162
|
+
}>, Schema.Struct<{
|
|
163
|
+
_tag: Schema.Literal<["TaskList"]>;
|
|
164
|
+
version: Schema.optionalWith<Schema.filter<Schema.filter<typeof Schema.Number>>, {
|
|
165
|
+
default: () => number;
|
|
166
|
+
}>;
|
|
167
|
+
children: Schema.Array$<Schema.Struct<{
|
|
168
|
+
_tag: Schema.Literal<["TaskItem"]>;
|
|
169
|
+
id: typeof Schema.String;
|
|
170
|
+
uuid: typeof Schema.String;
|
|
171
|
+
status: Schema.Literal<["incomplete", "complete"]>;
|
|
172
|
+
body: Schema.Array$<Schema.Union<[typeof import("./InlineNode.ts").Text, typeof import("./InlineNode.ts").Strong, typeof import("./InlineNode.ts").Emphasis, typeof import("./InlineNode.ts").InlineCode, typeof import("./InlineNode.ts").Link, typeof import("./InlineNode.ts").LineBreak, typeof import("./InlineNode.ts").Emoticon, typeof import("./InlineNode.ts").UserMention, typeof import("./InlineNode.ts").DateTime, typeof import("./InlineNode.ts").Underline, typeof import("./InlineNode.ts").Subscript, typeof import("./InlineNode.ts").Superscript, typeof import("./InlineNode.ts").Strikethrough, typeof import("./InlineNode.ts").ColoredText, typeof import("./InlineNode.ts").Highlight, typeof import("./InlineNode.ts").UnsupportedInline]>>;
|
|
173
|
+
rawSource: Schema.optional<typeof Schema.String>;
|
|
174
|
+
}>>;
|
|
175
|
+
rawSource: Schema.optional<typeof Schema.String>;
|
|
176
|
+
}>, typeof import("./BlockNode.js").UnsupportedBlock]>, Schema.Union<[Schema.Struct<{
|
|
177
|
+
_tag: Schema.Literal<["InfoPanel"]>;
|
|
178
|
+
version: Schema.optionalWith<Schema.filter<Schema.filter<typeof Schema.Number>>, {
|
|
179
|
+
default: () => number;
|
|
180
|
+
}>;
|
|
181
|
+
panelType: Schema.Literal<["info", "warning", "note", "tip", "error", "panel"]>;
|
|
182
|
+
title: Schema.optional<typeof Schema.String>;
|
|
183
|
+
children: Schema.Array$<Schema.Union<[typeof import("./BlockNode.js").Heading, typeof import("./BlockNode.js").Paragraph, typeof import("./BlockNode.js").CodeBlock, typeof import("./BlockNode.js").ThematicBreak, typeof import("./BlockNode.js").Image, typeof import("./BlockNode.js").Table, typeof import("./BlockNode.js").UnsupportedBlock]>>;
|
|
184
|
+
rawSource: Schema.optional<typeof Schema.String>;
|
|
185
|
+
}>, Schema.Struct<{
|
|
186
|
+
_tag: Schema.Literal<["ExpandMacro"]>;
|
|
187
|
+
version: Schema.optionalWith<Schema.filter<Schema.filter<typeof Schema.Number>>, {
|
|
188
|
+
default: () => number;
|
|
189
|
+
}>;
|
|
190
|
+
title: Schema.optional<typeof Schema.String>;
|
|
191
|
+
children: Schema.Array$<Schema.Union<[typeof import("./BlockNode.js").Heading, typeof import("./BlockNode.js").Paragraph, typeof import("./BlockNode.js").CodeBlock, typeof import("./BlockNode.js").ThematicBreak, typeof import("./BlockNode.js").Image, typeof import("./BlockNode.js").Table, typeof import("./BlockNode.js").UnsupportedBlock]>>;
|
|
192
|
+
rawSource: Schema.optional<typeof Schema.String>;
|
|
193
|
+
}>, Schema.Struct<{
|
|
194
|
+
_tag: Schema.Literal<["TocMacro"]>;
|
|
195
|
+
version: Schema.optionalWith<Schema.filter<Schema.filter<typeof Schema.Number>>, {
|
|
196
|
+
default: () => number;
|
|
197
|
+
}>;
|
|
198
|
+
minLevel: Schema.optional<typeof Schema.Number>;
|
|
199
|
+
maxLevel: Schema.optional<typeof Schema.Number>;
|
|
200
|
+
rawSource: Schema.optional<typeof Schema.String>;
|
|
201
|
+
}>, Schema.Struct<{
|
|
202
|
+
_tag: Schema.Literal<["CodeMacro"]>;
|
|
203
|
+
version: Schema.optionalWith<Schema.filter<Schema.filter<typeof Schema.Number>>, {
|
|
204
|
+
default: () => number;
|
|
205
|
+
}>;
|
|
206
|
+
language: Schema.optional<typeof Schema.String>;
|
|
207
|
+
title: Schema.optional<typeof Schema.String>;
|
|
208
|
+
code: typeof Schema.String;
|
|
209
|
+
lineNumbers: Schema.optionalWith<typeof Schema.Boolean, {
|
|
210
|
+
default: () => false;
|
|
211
|
+
}>;
|
|
212
|
+
collapse: Schema.optionalWith<typeof Schema.Boolean, {
|
|
213
|
+
default: () => false;
|
|
214
|
+
}>;
|
|
215
|
+
firstLine: Schema.optional<typeof Schema.Number>;
|
|
216
|
+
rawSource: Schema.optional<typeof Schema.String>;
|
|
217
|
+
}>, Schema.Struct<{
|
|
218
|
+
_tag: Schema.Literal<["StatusMacro"]>;
|
|
219
|
+
version: Schema.optionalWith<Schema.filter<Schema.filter<typeof Schema.Number>>, {
|
|
220
|
+
default: () => number;
|
|
221
|
+
}>;
|
|
222
|
+
text: typeof Schema.String;
|
|
223
|
+
color: Schema.Literal<["Grey", "Red", "Yellow", "Green", "Blue"]>;
|
|
224
|
+
rawSource: Schema.optional<typeof Schema.String>;
|
|
225
|
+
}>]>]>>;
|
|
226
|
+
rawSource: Schema.optional<typeof Schema.String>;
|
|
227
|
+
}>;
|
|
228
|
+
/**
|
|
229
|
+
* Type for Document.
|
|
230
|
+
*
|
|
231
|
+
* @category Types
|
|
232
|
+
*/
|
|
233
|
+
export type Document = Schema.Schema.Type<typeof Document>;
|
|
234
|
+
/**
|
|
235
|
+
* Create a new Document with default version.
|
|
236
|
+
*
|
|
237
|
+
* @example
|
|
238
|
+
* ```typescript
|
|
239
|
+
* import { makeDocument, Heading, Text } from "@knpkv/atlassian-common/ast"
|
|
240
|
+
*
|
|
241
|
+
* const doc = makeDocument([
|
|
242
|
+
* new Heading({ level: 1, children: [new Text({ value: "Hello" })] })
|
|
243
|
+
* ])
|
|
244
|
+
* ```
|
|
245
|
+
*
|
|
246
|
+
* @category Constructors
|
|
247
|
+
*/
|
|
248
|
+
export declare const makeDocument: (children: ReadonlyArray<DocumentNode>, rawSource?: string) => Document;
|
|
249
|
+
/**
|
|
250
|
+
* Check if a node is a Document.
|
|
251
|
+
*
|
|
252
|
+
* @category Guards
|
|
253
|
+
*/
|
|
254
|
+
export declare const isDocument: (value: unknown) => value is Document;
|
|
255
|
+
//# sourceMappingURL=Document.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"Document.d.ts","sourceRoot":"","sources":["../../src/ast/Document.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;GAeG;AACH,OAAO,KAAK,MAAM,MAAM,eAAe,CAAA;AACvC,OAAO,EAAa,KAAK,SAAS,IAAI,aAAa,EAA4B,MAAM,gBAAgB,CAAA;AACrG,OAAO,EAAa,KAAK,SAAS,IAAI,aAAa,EAAE,MAAM,gBAAgB,CAAA;AAE3E;;;;GAIG;AACH,eAAO,MAAM,YAAY;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;MAAqC,CAAA;AAE9D;;;;GAIG;AACH,MAAM,MAAM,YAAY,GAAG,aAAa,GAAG,aAAa,CAAA;AAExD;;;;;;;;;;;;;;;;;;;;GAoBG;AACH,eAAO,MAAM,QAAQ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;EAInB,CAAA;AAEF;;;;GAIG;AACH,MAAM,MAAM,QAAQ,GAAG,MAAM,CAAC,MAAM,CAAC,IAAI,CAAC,OAAO,QAAQ,CAAC,CAAA;AAE1D;;;;;;;;;;;;;GAaG;AACH,eAAO,MAAM,YAAY,GACvB,UAAU,aAAa,CAAC,YAAY,CAAC,EACrC,YAAY,MAAM,KACjB,QAID,CAAA;AAEF;;;;GAIG;AACH,eAAO,MAAM,UAAU,GAAI,OAAO,OAAO,KAAG,KAAK,IAAI,QAIR,CAAA"}
|
|
@@ -0,0 +1,80 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Root AST node wrapping a sequence of {@link DocumentNode} children.
|
|
3
|
+
*
|
|
4
|
+
* **Mental model**
|
|
5
|
+
*
|
|
6
|
+
* - **Document = version + children**: The top-level container for parsed Atlassian content.
|
|
7
|
+
* `children` is a union of `BlockNode | MacroNode`.
|
|
8
|
+
* - **Raw source preservation**: Optional `rawSource` field enables lossless roundtripping.
|
|
9
|
+
*
|
|
10
|
+
* **Common tasks**
|
|
11
|
+
*
|
|
12
|
+
* - Construct a document: {@link makeDocument}
|
|
13
|
+
* - Type-guard check: {@link isDocument}
|
|
14
|
+
*
|
|
15
|
+
* @module
|
|
16
|
+
*/
|
|
17
|
+
import * as Schema from "effect/Schema";
|
|
18
|
+
import { BlockNode, RawSource, SchemaVersion } from "./BlockNode.js";
|
|
19
|
+
import { MacroNode } from "./MacroNode.js";
|
|
20
|
+
/**
|
|
21
|
+
* Document node - represents a Block or Macro node.
|
|
22
|
+
*
|
|
23
|
+
* @category Document
|
|
24
|
+
*/
|
|
25
|
+
export const DocumentNode = Schema.Union(BlockNode, MacroNode);
|
|
26
|
+
/**
|
|
27
|
+
* Document schema - the root AST node.
|
|
28
|
+
*
|
|
29
|
+
* @example
|
|
30
|
+
* ```typescript
|
|
31
|
+
* import { Document, Heading, Paragraph, Text } from "@knpkv/atlassian-common/ast"
|
|
32
|
+
* import * as Schema from "effect/Schema"
|
|
33
|
+
*
|
|
34
|
+
* const doc = {
|
|
35
|
+
* version: 1,
|
|
36
|
+
* children: [
|
|
37
|
+
* new Heading({ level: 1, children: [new Text({ value: "Title" })] }),
|
|
38
|
+
* new Paragraph({ children: [new Text({ value: "Content" })] })
|
|
39
|
+
* ]
|
|
40
|
+
* }
|
|
41
|
+
*
|
|
42
|
+
* const validated = Schema.decodeUnknownSync(Document)(doc)
|
|
43
|
+
* ```
|
|
44
|
+
*
|
|
45
|
+
* @category Document
|
|
46
|
+
*/
|
|
47
|
+
export const Document = Schema.Struct({
|
|
48
|
+
version: SchemaVersion,
|
|
49
|
+
children: Schema.Array(DocumentNode),
|
|
50
|
+
rawSource: RawSource
|
|
51
|
+
});
|
|
52
|
+
/**
|
|
53
|
+
* Create a new Document with default version.
|
|
54
|
+
*
|
|
55
|
+
* @example
|
|
56
|
+
* ```typescript
|
|
57
|
+
* import { makeDocument, Heading, Text } from "@knpkv/atlassian-common/ast"
|
|
58
|
+
*
|
|
59
|
+
* const doc = makeDocument([
|
|
60
|
+
* new Heading({ level: 1, children: [new Text({ value: "Hello" })] })
|
|
61
|
+
* ])
|
|
62
|
+
* ```
|
|
63
|
+
*
|
|
64
|
+
* @category Constructors
|
|
65
|
+
*/
|
|
66
|
+
export const makeDocument = (children, rawSource) => ({
|
|
67
|
+
version: 1,
|
|
68
|
+
children,
|
|
69
|
+
...(rawSource !== undefined ? { rawSource } : {})
|
|
70
|
+
});
|
|
71
|
+
/**
|
|
72
|
+
* Check if a node is a Document.
|
|
73
|
+
*
|
|
74
|
+
* @category Guards
|
|
75
|
+
*/
|
|
76
|
+
export const isDocument = (value) => typeof value === "object" &&
|
|
77
|
+
value !== null &&
|
|
78
|
+
"children" in value &&
|
|
79
|
+
Array.isArray(value.children);
|
|
80
|
+
//# sourceMappingURL=Document.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"Document.js","sourceRoot":"","sources":["../../src/ast/Document.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;GAeG;AACH,OAAO,KAAK,MAAM,MAAM,eAAe,CAAA;AACvC,OAAO,EAAE,SAAS,EAAmC,SAAS,EAAE,aAAa,EAAE,MAAM,gBAAgB,CAAA;AACrG,OAAO,EAAE,SAAS,EAAmC,MAAM,gBAAgB,CAAA;AAE3E;;;;GAIG;AACH,MAAM,CAAC,MAAM,YAAY,GAAG,MAAM,CAAC,KAAK,CAAC,SAAS,EAAE,SAAS,CAAC,CAAA;AAS9D;;;;;;;;;;;;;;;;;;;;GAoBG;AACH,MAAM,CAAC,MAAM,QAAQ,GAAG,MAAM,CAAC,MAAM,CAAC;IACpC,OAAO,EAAE,aAAa;IACtB,QAAQ,EAAE,MAAM,CAAC,KAAK,CAAC,YAAY,CAAC;IACpC,SAAS,EAAE,SAAS;CACrB,CAAC,CAAA;AASF;;;;;;;;;;;;;GAaG;AACH,MAAM,CAAC,MAAM,YAAY,GAAG,CAC1B,QAAqC,EACrC,SAAkB,EACR,EAAE,CAAC,CAAC;IACd,OAAO,EAAE,CAAC;IACV,QAAQ;IACR,GAAG,CAAC,SAAS,KAAK,SAAS,CAAC,CAAC,CAAC,EAAE,SAAS,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC;CAClD,CAAC,CAAA;AAEF;;;;GAIG;AACH,MAAM,CAAC,MAAM,UAAU,GAAG,CAAC,KAAc,EAAqB,EAAE,CAC9D,OAAO,KAAK,KAAK,QAAQ;IACzB,KAAK,KAAK,IAAI;IACd,UAAU,IAAI,KAAK;IACnB,KAAK,CAAC,OAAO,CAAE,KAAkB,CAAC,QAAQ,CAAC,CAAA"}
|