UNPKG

9.67 kBTypeScriptView Raw
1/*
2 * Copyright 2018 Adobe. All rights reserved.
3 * This file is licensed to you under the Apache License, Version 2.0 (the "License");
4 * you may not use this file except in compliance with the License. You may obtain a copy
5 * of the License at http://www.apache.org/licenses/LICENSE-2.0
6 *
7 * Unless required by applicable law or agreed to in writing, software distributed under
8 * the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS
9 * OF ANY KIND, either express or implied. See the License for the specific language
10 * governing permissions and limitations under the License.
11 */
12
13/**
14 * The context thingie.
15 */
16export interface Context {
17 /**
18 * An error message that has been generated during pipeline processing.
19 * When this property is present, all other values can be ignored.
20 */
21 error?:
22 | string
23 | {
24 [k: string]: any;
25 };
26 request?: Request;
27 content?: Content;
28 response?: Response;
29}
30/**
31 * The HTTP Request
32 */
33export interface Request {
34 /**
35 * The path and request parameters of the client request URL.
36 */
37 url?: string;
38 /**
39 * The path of the client request URL
40 */
41 path?: string;
42 /**
43 * The part of the client path that is relative to the rootPath.
44 */
45 pathInfo?: string;
46 /**
47 * The request root path of the current strain.
48 */
49 rootPath?: string;
50 /**
51 * The selector (sub-type indicator).
52 */
53 selector?: string;
54 /**
55 * The extension of the requested resource.
56 */
57 extension?: string;
58 /**
59 * The HTTP method of the request. Note: method names can be lower-case.
60 */
61 method?: string;
62 /**
63 * The HTTP headers of the request. Note: all header names will be lower-case.
64 */
65 headers?: {
66 [k: string]: string;
67 };
68 /**
69 * The passed through (and filtered) URL parameters of the request.
70 */
71 params?: {
72 [k: string]: string | string[];
73 };
74 /**
75 * The original query string.
76 */
77 queryString?: string;
78}
79/**
80 * The content as retrieved from the repository and enriched in the pipeline.
81 */
82export interface Content {
83 /**
84 * List of URIs that have been retrieved for this piece of content
85 */
86 sources?: string[];
87 /**
88 * The content body of the retrieved source document
89 */
90 body?: string;
91 mdast?: MDAST;
92 /**
93 * The DOM-compatible representation of the document's inner HTML
94 */
95 document?: {
96 [k: string]: any;
97 };
98 /**
99 * The JSON object to emit.
100 */
101 json?: {
102 [k: string]: any;
103 };
104 /**
105 * The XML object to emit. See xmlbuilder-js for syntax.
106 */
107 xml?: {
108 [k: string]: any;
109 };
110 meta?: null | {
111 /**
112 * The CSS class to use for the section instead of the default `hlx-section` one
113 */
114 class?: string;
115 /**
116 * The element tag name to use for the section instead of the default `div` one (i.e. `section`, `main`, `aside`)
117 */
118 tagname?: string;
119 /**
120 * The inferred class names for the section
121 */
122 types?: string[];
123 /**
124 * Extracted title of the document
125 */
126 title?: string;
127 /**
128 * Extracted first paragraph of the document
129 */
130 intro?: string;
131 /**
132 * Path (can be relative) to the first image in the document
133 */
134 image?: string;
135 [k: string]: any;
136 };
137 /**
138 * Extracted title of the document
139 */
140 title?: string;
141 /**
142 * Extracted first paragraph of the document
143 */
144 intro?: string;
145 /**
146 * Path (can be relative) to the first image in the document
147 */
148 image?: string;
149 /**
150 * Custom object that can hold any user defined data.
151 */
152 data?: {
153 [k: string]: any;
154 };
155}
156/**
157 * A node in the Markdown AST
158 */
159export interface MDAST {
160 /**
161 * The node type of the MDAST node
162 */
163 type?:
164 | "root"
165 | "paragraph"
166 | "text"
167 | "heading"
168 | "thematicBreak"
169 | "blockquote"
170 | "list"
171 | "listItem"
172 | "table"
173 | "tableRow"
174 | "tableCell"
175 | "html"
176 | "code"
177 | "yaml"
178 | "definition"
179 | "footnoteDefinition"
180 | "emphasis"
181 | "strong"
182 | "delete"
183 | "inlineCode"
184 | "break"
185 | "link"
186 | "image"
187 | "linkReference"
188 | "imageReference"
189 | "footnote"
190 | "footnoteReference"
191 | "embed"
192 | "dataEmbed"
193 | "section"
194 | "icon";
195 children?: (
196 | MDAST
197 | {
198 /**
199 * The MDAST node type. Each section can be treated as a standalone document.
200 */
201 type?: {
202 [k: string]: any;
203 };
204 position?: Position;
205 /**
206 * The AST nodes making up the section. Section dividers are not included.
207 */
208 children?: MDAST[];
209 meta?: null | {
210 /**
211 * The CSS class to use for the section instead of the default `hlx-section` one
212 */
213 class?: string;
214 /**
215 * The element tag name to use for the section instead of the default `div` one (i.e. `section`, `main`, `aside`)
216 */
217 tagname?: string;
218 /**
219 * The inferred class names for the section
220 */
221 types?: string[];
222 /**
223 * Extracted title of the document
224 */
225 title?: string;
226 /**
227 * Extracted first paragraph of the document
228 */
229 intro?: string;
230 /**
231 * Path (can be relative) to the first image in the document
232 */
233 image?: string;
234 [k: string]: any;
235 };
236 /**
237 * Extracted title of the document
238 */
239 title?: string;
240 /**
241 * Extracted first paragraph of the document
242 */
243 intro?: string;
244 /**
245 * Path (can be relative) to the first image in the document
246 */
247 image?: string;
248 }
249 )[];
250 position?: Position;
251 /**
252 * The string value of the node, if it is a terminal node.
253 */
254 value?: string;
255 /**
256 * The payload of a frontmatter/yaml block
257 */
258 payload?: {
259 [k: string]: any;
260 };
261 /**
262 * The heading level
263 */
264 depth?: number;
265 /**
266 * Is the list ordered
267 */
268 ordered?: boolean;
269 /**
270 * Starting item of the list
271 */
272 start?: null | number;
273 /**
274 * A spread field can be present. It represents that any of its items is separated by a blank line from its siblings or contains two or more children (when true), or not (when false or not present).
275 */
276 spread?: null | boolean;
277 /**
278 * A checked field can be present. It represents whether the item is done (when true), not done (when false), or indeterminate or not applicable (when null or not present).
279 */
280 checked?: null | boolean;
281 /**
282 * For tables, an align field can be present. If present, it must be a list of alignTypes. It represents how cells in columns are aligned.
283 */
284 align?: (null | ("left" | "right" | "center" | null))[];
285 /**
286 * For code, a lang field can be present. It represents the language of computer code being marked up.
287 */
288 lang?: null | string;
289 /**
290 * For associations, an identifier field must be present. It can match an identifier field on another node.
291 */
292 identifier?: string;
293 /**
294 * For associations, a label field can be present. It represents the original value of the normalised identifier field.
295 */
296 label?: string;
297 /**
298 * For resources, an url field must be present. It represents a URL to the referenced resource.
299 */
300 url?: string;
301 meta?: null | {
302 /**
303 * The CSS class to use for the section instead of the default `hlx-section` one
304 */
305 class?: string;
306 /**
307 * The element tag name to use for the section instead of the default `div` one (i.e. `section`, `main`, `aside`)
308 */
309 tagname?: string;
310 /**
311 * The inferred class names for the section
312 */
313 types?: string[];
314 /**
315 * Extracted title of the document
316 */
317 title?: string;
318 /**
319 * Extracted first paragraph of the document
320 */
321 intro?: string;
322 /**
323 * Path (can be relative) to the first image in the document
324 */
325 image?: string;
326 [k: string]: any;
327 };
328 /**
329 * Extracted title of the document
330 */
331 title?: null | string;
332 /**
333 * Icon code
334 */
335 code?: string;
336 /**
337 * Extracted first paragraph of the document
338 */
339 intro?: null | string;
340 /**
341 * Path (can be relative) to the first image in the document
342 */
343 image?: null | string;
344 /**
345 * The inferred class names for the section
346 */
347 types?: string[];
348 /**
349 * An alt field should be present. It represents equivalent content for environments that cannot represent the node as intended.
350 */
351 alt?: string | null;
352 /**
353 * Represents the explicitness of a reference.
354 */
355 referenceType?: "shortcut" | "collapsed" | "full";
356 /**
357 * data is guaranteed to never be specified by unist or specifications implementing unist. Free data space.
358 */
359 data?: {
360 [k: string]: any;
361 };
362}
363/**
364 * Marks the position of an AST node in the original text flow
365 */
366export interface Position {
367 start?: TextCoordinates;
368 end?: TextCoordinates;
369 indent?: any[];
370}
371/**
372 * A position in a text document
373 */
374export interface TextCoordinates {
375 /**
376 * Line number
377 */
378 line?: number;
379 /**
380 * Column number
381 */
382 column?: number;
383 /**
384 * Character in the entire document
385 */
386 offset?: number;
387}
388/**
389 * The HTTP response object
390 */
391export interface Response {
392 /**
393 * The HTTP status code
394 */
395 status?: number;
396 body?: {
397 [k: string]: any;
398 };
399 /**
400 * The DOM-compatible representation of the response document
401 */
402 document?: {
403 [k: string]: any;
404 };
405 /**
406 * The HTTP headers of the response
407 */
408 headers?: {
409 [k: string]: string;
410 };
411}