1 | var fs = require('fs');
|
2 | var path = require('path');
|
3 |
|
4 | function _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'default' in e ? e : { 'default': e }; }
|
5 |
|
6 | var fs__default = _interopDefaultLegacy(fs);
|
7 | var path__default = _interopDefaultLegacy(path);
|
8 |
|
9 | function _extends() {
|
10 | _extends = Object.assign || function (target) {
|
11 | for (var i = 1; i < arguments.length; i++) {
|
12 | var source = arguments[i];
|
13 |
|
14 | for (var key in source) {
|
15 | if (Object.prototype.hasOwnProperty.call(source, key)) {
|
16 | target[key] = source[key];
|
17 | }
|
18 | }
|
19 | }
|
20 |
|
21 | return target;
|
22 | };
|
23 |
|
24 | return _extends.apply(this, arguments);
|
25 | }
|
26 |
|
27 |
|
28 |
|
29 |
|
30 |
|
31 |
|
32 | const compact = o => Object.entries(o).reduce((compactedO, [k, v]) => v === undefined ? compactedO : _extends({}, compactedO, {
|
33 | [k]: v
|
34 | }), {});
|
35 |
|
36 |
|
37 |
|
38 |
|
39 |
|
40 |
|
41 |
|
42 | const entity = (props = {}) => _extends({}, compact(props), {
|
43 | type: 'Entity'
|
44 | });
|
45 |
|
46 |
|
47 |
|
48 |
|
49 |
|
50 |
|
51 | const arrayValidator = (props = {}) => _extends({}, compact(props), {
|
52 | type: 'ArrayValidator'
|
53 | });
|
54 |
|
55 |
|
56 |
|
57 |
|
58 |
|
59 |
|
60 | const booleanValidator = (props = {}) => _extends({}, compact(props), {
|
61 | type: 'BooleanValidator'
|
62 | });
|
63 |
|
64 |
|
65 |
|
66 |
|
67 |
|
68 |
|
69 | const cite = props => _extends({}, compact(props), {
|
70 | type: 'Cite'
|
71 | });
|
72 |
|
73 |
|
74 |
|
75 |
|
76 |
|
77 |
|
78 | const citeGroup = props => _extends({}, compact(props), {
|
79 | type: 'CiteGroup'
|
80 | });
|
81 |
|
82 |
|
83 |
|
84 |
|
85 |
|
86 |
|
87 | const code = props => _extends({}, compact(props), {
|
88 | type: 'Code'
|
89 | });
|
90 |
|
91 |
|
92 |
|
93 |
|
94 |
|
95 |
|
96 | const codeBlock = props => _extends({}, compact(props), {
|
97 | type: 'CodeBlock'
|
98 | });
|
99 |
|
100 |
|
101 |
|
102 |
|
103 |
|
104 |
|
105 | const codeChunk = props => _extends({}, compact(props), {
|
106 | type: 'CodeChunk'
|
107 | });
|
108 |
|
109 |
|
110 |
|
111 |
|
112 |
|
113 |
|
114 | const codeFragment = props => _extends({}, compact(props), {
|
115 | type: 'CodeFragment'
|
116 | });
|
117 |
|
118 |
|
119 |
|
120 |
|
121 |
|
122 |
|
123 | const codeExpression = props => _extends({}, compact(props), {
|
124 | type: 'CodeExpression'
|
125 | });
|
126 |
|
127 |
|
128 |
|
129 |
|
130 |
|
131 |
|
132 | const codeError = props => _extends({}, compact(props), {
|
133 | type: 'CodeError'
|
134 | });
|
135 |
|
136 |
|
137 |
|
138 |
|
139 |
|
140 |
|
141 | const constantValidator = (props = {}) => _extends({}, compact(props), {
|
142 | type: 'ConstantValidator'
|
143 | });
|
144 |
|
145 |
|
146 |
|
147 |
|
148 |
|
149 |
|
150 | const date = props => _extends({}, compact(props), {
|
151 | type: 'Date'
|
152 | });
|
153 |
|
154 |
|
155 |
|
156 |
|
157 |
|
158 |
|
159 | const mark = props => _extends({}, compact(props), {
|
160 | type: 'Mark'
|
161 | });
|
162 |
|
163 |
|
164 |
|
165 |
|
166 |
|
167 |
|
168 | const del = props => _extends({}, compact(props), {
|
169 | type: 'Delete'
|
170 | });
|
171 |
|
172 |
|
173 |
|
174 |
|
175 |
|
176 |
|
177 | const emphasis = props => _extends({}, compact(props), {
|
178 | type: 'Emphasis'
|
179 | });
|
180 |
|
181 |
|
182 |
|
183 |
|
184 |
|
185 |
|
186 | const thing = (props = {}) => _extends({}, compact(props), {
|
187 | type: 'Thing'
|
188 | });
|
189 |
|
190 |
|
191 |
|
192 |
|
193 |
|
194 |
|
195 | const brand = props => _extends({}, compact(props), {
|
196 | type: 'Brand'
|
197 | });
|
198 |
|
199 |
|
200 |
|
201 |
|
202 |
|
203 |
|
204 | const contactPoint = (props = {}) => _extends({}, compact(props), {
|
205 | type: 'ContactPoint'
|
206 | });
|
207 |
|
208 |
|
209 |
|
210 |
|
211 |
|
212 |
|
213 | const creativeWork = (props = {}) => _extends({}, compact(props), {
|
214 | type: 'CreativeWork'
|
215 | });
|
216 |
|
217 |
|
218 |
|
219 |
|
220 |
|
221 |
|
222 | const article = (props = {}) => _extends({}, compact(props), {
|
223 | type: 'Article'
|
224 | });
|
225 |
|
226 |
|
227 |
|
228 |
|
229 |
|
230 |
|
231 | const collection = props => _extends({}, compact(props), {
|
232 | type: 'Collection'
|
233 | });
|
234 |
|
235 |
|
236 |
|
237 |
|
238 |
|
239 |
|
240 | const comment = (props = {}) => _extends({}, compact(props), {
|
241 | type: 'Comment'
|
242 | });
|
243 |
|
244 |
|
245 |
|
246 |
|
247 |
|
248 |
|
249 | const datatable = props => _extends({}, compact(props), {
|
250 | type: 'Datatable'
|
251 | });
|
252 |
|
253 |
|
254 |
|
255 |
|
256 |
|
257 |
|
258 | const mediaObject = props => _extends({}, compact(props), {
|
259 | type: 'MediaObject'
|
260 | });
|
261 |
|
262 |
|
263 |
|
264 |
|
265 |
|
266 |
|
267 | const audioObject = props => _extends({}, compact(props), {
|
268 | type: 'AudioObject'
|
269 | });
|
270 |
|
271 |
|
272 |
|
273 |
|
274 |
|
275 |
|
276 | const datatableColumn = props => _extends({}, compact(props), {
|
277 | type: 'DatatableColumn'
|
278 | });
|
279 |
|
280 |
|
281 |
|
282 |
|
283 |
|
284 |
|
285 | const definedTerm = props => _extends({}, compact(props), {
|
286 | type: 'DefinedTerm'
|
287 | });
|
288 |
|
289 |
|
290 |
|
291 |
|
292 |
|
293 |
|
294 | const enumValidator = (props = {}) => _extends({}, compact(props), {
|
295 | type: 'EnumValidator'
|
296 | });
|
297 |
|
298 |
|
299 |
|
300 |
|
301 |
|
302 |
|
303 | const figure = (props = {}) => _extends({}, compact(props), {
|
304 | type: 'Figure'
|
305 | });
|
306 |
|
307 |
|
308 |
|
309 |
|
310 |
|
311 |
|
312 | const function_ = (props = {}) => _extends({}, compact(props), {
|
313 | type: 'Function'
|
314 | });
|
315 |
|
316 |
|
317 |
|
318 |
|
319 |
|
320 |
|
321 | const grant = (props = {}) => _extends({}, compact(props), {
|
322 | type: 'Grant'
|
323 | });
|
324 |
|
325 |
|
326 |
|
327 |
|
328 |
|
329 |
|
330 | const heading = props => _extends({}, compact(props), {
|
331 | type: 'Heading'
|
332 | });
|
333 |
|
334 |
|
335 |
|
336 |
|
337 |
|
338 |
|
339 | const imageObject = props => _extends({}, compact(props), {
|
340 | type: 'ImageObject'
|
341 | });
|
342 |
|
343 |
|
344 |
|
345 |
|
346 |
|
347 |
|
348 | const include = props => _extends({}, compact(props), {
|
349 | type: 'Include'
|
350 | });
|
351 |
|
352 |
|
353 |
|
354 |
|
355 |
|
356 |
|
357 | const numberValidator = (props = {}) => _extends({}, compact(props), {
|
358 | type: 'NumberValidator'
|
359 | });
|
360 |
|
361 |
|
362 |
|
363 |
|
364 |
|
365 |
|
366 | const integerValidator = (props = {}) => _extends({}, compact(props), {
|
367 | type: 'IntegerValidator'
|
368 | });
|
369 |
|
370 |
|
371 |
|
372 |
|
373 |
|
374 |
|
375 | const link = props => _extends({}, compact(props), {
|
376 | type: 'Link'
|
377 | });
|
378 |
|
379 |
|
380 |
|
381 |
|
382 |
|
383 |
|
384 | const list = props => _extends({}, compact(props), {
|
385 | type: 'List'
|
386 | });
|
387 |
|
388 |
|
389 |
|
390 |
|
391 |
|
392 |
|
393 | const listItem = (props = {}) => _extends({}, compact(props), {
|
394 | type: 'ListItem'
|
395 | });
|
396 |
|
397 |
|
398 |
|
399 |
|
400 |
|
401 |
|
402 | const math = props => _extends({}, compact(props), {
|
403 | type: 'Math'
|
404 | });
|
405 |
|
406 |
|
407 |
|
408 |
|
409 |
|
410 |
|
411 | const mathBlock = props => _extends({}, compact(props), {
|
412 | type: 'MathBlock'
|
413 | });
|
414 |
|
415 |
|
416 |
|
417 |
|
418 |
|
419 |
|
420 | const mathFragment = props => _extends({}, compact(props), {
|
421 | type: 'MathFragment'
|
422 | });
|
423 |
|
424 |
|
425 |
|
426 |
|
427 |
|
428 |
|
429 | const monetaryGrant = (props = {}) => _extends({}, compact(props), {
|
430 | type: 'MonetaryGrant'
|
431 | });
|
432 |
|
433 |
|
434 |
|
435 |
|
436 |
|
437 |
|
438 | const nontextualAnnotation = props => _extends({}, compact(props), {
|
439 | type: 'NontextualAnnotation'
|
440 | });
|
441 |
|
442 |
|
443 |
|
444 |
|
445 |
|
446 |
|
447 | const organization = (props = {}) => _extends({}, compact(props), {
|
448 | type: 'Organization'
|
449 | });
|
450 |
|
451 |
|
452 |
|
453 |
|
454 |
|
455 |
|
456 | const paragraph = props => _extends({}, compact(props), {
|
457 | type: 'Paragraph'
|
458 | });
|
459 |
|
460 |
|
461 |
|
462 |
|
463 |
|
464 |
|
465 | const variable = props => _extends({}, compact(props), {
|
466 | type: 'Variable'
|
467 | });
|
468 |
|
469 |
|
470 |
|
471 |
|
472 |
|
473 |
|
474 | const parameter = props => _extends({}, compact(props), {
|
475 | type: 'Parameter'
|
476 | });
|
477 |
|
478 |
|
479 |
|
480 |
|
481 |
|
482 |
|
483 | const periodical = (props = {}) => _extends({}, compact(props), {
|
484 | type: 'Periodical'
|
485 | });
|
486 |
|
487 |
|
488 |
|
489 |
|
490 |
|
491 |
|
492 | const person = (props = {}) => _extends({}, compact(props), {
|
493 | type: 'Person'
|
494 | });
|
495 |
|
496 |
|
497 |
|
498 |
|
499 |
|
500 |
|
501 | const postalAddress = (props = {}) => _extends({}, compact(props), {
|
502 | type: 'PostalAddress'
|
503 | });
|
504 |
|
505 |
|
506 |
|
507 |
|
508 |
|
509 |
|
510 | const product = (props = {}) => _extends({}, compact(props), {
|
511 | type: 'Product'
|
512 | });
|
513 |
|
514 |
|
515 |
|
516 |
|
517 |
|
518 |
|
519 | const propertyValue = props => _extends({}, compact(props), {
|
520 | type: 'PropertyValue'
|
521 | });
|
522 |
|
523 |
|
524 |
|
525 |
|
526 |
|
527 |
|
528 | const publicationIssue = (props = {}) => _extends({}, compact(props), {
|
529 | type: 'PublicationIssue'
|
530 | });
|
531 |
|
532 |
|
533 |
|
534 |
|
535 |
|
536 |
|
537 | const publicationVolume = (props = {}) => _extends({}, compact(props), {
|
538 | type: 'PublicationVolume'
|
539 | });
|
540 |
|
541 |
|
542 |
|
543 |
|
544 |
|
545 |
|
546 | const quote = props => _extends({}, compact(props), {
|
547 | type: 'Quote'
|
548 | });
|
549 |
|
550 |
|
551 |
|
552 |
|
553 |
|
554 |
|
555 | const quoteBlock = props => _extends({}, compact(props), {
|
556 | type: 'QuoteBlock'
|
557 | });
|
558 |
|
559 |
|
560 |
|
561 |
|
562 |
|
563 |
|
564 | const review = (props = {}) => _extends({}, compact(props), {
|
565 | type: 'Review'
|
566 | });
|
567 |
|
568 |
|
569 |
|
570 |
|
571 |
|
572 |
|
573 | const softwareApplication = (props = {}) => _extends({}, compact(props), {
|
574 | type: 'SoftwareApplication'
|
575 | });
|
576 |
|
577 |
|
578 |
|
579 |
|
580 |
|
581 |
|
582 | const softwareEnvironment = props => _extends({}, compact(props), {
|
583 | type: 'SoftwareEnvironment'
|
584 | });
|
585 |
|
586 |
|
587 |
|
588 |
|
589 |
|
590 |
|
591 | const softwareSession = (props = {}) => _extends({}, compact(props), {
|
592 | type: 'SoftwareSession'
|
593 | });
|
594 |
|
595 |
|
596 |
|
597 |
|
598 |
|
599 |
|
600 | const softwareSourceCode = (props = {}) => _extends({}, compact(props), {
|
601 | type: 'SoftwareSourceCode'
|
602 | });
|
603 |
|
604 |
|
605 |
|
606 |
|
607 |
|
608 |
|
609 | const stringValidator = (props = {}) => _extends({}, compact(props), {
|
610 | type: 'StringValidator'
|
611 | });
|
612 |
|
613 |
|
614 |
|
615 |
|
616 |
|
617 |
|
618 | const strong = props => _extends({}, compact(props), {
|
619 | type: 'Strong'
|
620 | });
|
621 |
|
622 |
|
623 |
|
624 |
|
625 |
|
626 |
|
627 | const subscript = props => _extends({}, compact(props), {
|
628 | type: 'Subscript'
|
629 | });
|
630 |
|
631 |
|
632 |
|
633 |
|
634 |
|
635 |
|
636 | const superscript = props => _extends({}, compact(props), {
|
637 | type: 'Superscript'
|
638 | });
|
639 |
|
640 |
|
641 |
|
642 |
|
643 |
|
644 |
|
645 | const table = props => _extends({}, compact(props), {
|
646 | type: 'Table'
|
647 | });
|
648 |
|
649 |
|
650 |
|
651 |
|
652 |
|
653 |
|
654 | const tableCell = props => _extends({}, compact(props), {
|
655 | type: 'TableCell'
|
656 | });
|
657 |
|
658 |
|
659 |
|
660 |
|
661 |
|
662 |
|
663 | const tableRow = props => _extends({}, compact(props), {
|
664 | type: 'TableRow'
|
665 | });
|
666 |
|
667 |
|
668 |
|
669 |
|
670 |
|
671 |
|
672 | const thematicBreak = (props = {}) => _extends({}, compact(props), {
|
673 | type: 'ThematicBreak'
|
674 | });
|
675 |
|
676 |
|
677 |
|
678 |
|
679 |
|
680 |
|
681 | const tupleValidator = (props = {}) => _extends({}, compact(props), {
|
682 | type: 'TupleValidator'
|
683 | });
|
684 |
|
685 |
|
686 |
|
687 |
|
688 |
|
689 |
|
690 | const videoObject = props => _extends({}, compact(props), {
|
691 | type: 'VideoObject'
|
692 | });
|
693 |
|
694 |
|
695 |
|
696 |
|
697 |
|
698 |
|
699 | const volumeMount = props => _extends({}, compact(props), {
|
700 | type: 'VolumeMount'
|
701 | });
|
702 | const codeBlockTypes = {
|
703 | CodeBlock: 'CodeBlock',
|
704 | CodeChunk: 'CodeChunk'
|
705 | };
|
706 | const codeFragmentTypes = {
|
707 | CodeFragment: 'CodeFragment',
|
708 | CodeExpression: 'CodeExpression'
|
709 | };
|
710 | const codeTypes = {
|
711 | Code: 'Code',
|
712 | CodeBlock: 'CodeBlock',
|
713 | CodeChunk: 'CodeChunk',
|
714 | CodeExpression: 'CodeExpression',
|
715 | CodeFragment: 'CodeFragment'
|
716 | };
|
717 | const contactPointTypes = {
|
718 | ContactPoint: 'ContactPoint',
|
719 | PostalAddress: 'PostalAddress'
|
720 | };
|
721 | const creativeWorkTypes = {
|
722 | CreativeWork: 'CreativeWork',
|
723 | Article: 'Article',
|
724 | AudioObject: 'AudioObject',
|
725 | Collection: 'Collection',
|
726 | Comment: 'Comment',
|
727 | Datatable: 'Datatable',
|
728 | Figure: 'Figure',
|
729 | ImageObject: 'ImageObject',
|
730 | MediaObject: 'MediaObject',
|
731 | Periodical: 'Periodical',
|
732 | PublicationIssue: 'PublicationIssue',
|
733 | PublicationVolume: 'PublicationVolume',
|
734 | Review: 'Review',
|
735 | SoftwareApplication: 'SoftwareApplication',
|
736 | SoftwareSourceCode: 'SoftwareSourceCode',
|
737 | Table: 'Table',
|
738 | VideoObject: 'VideoObject'
|
739 | };
|
740 | const entityTypes = {
|
741 | Entity: 'Entity',
|
742 | ArrayValidator: 'ArrayValidator',
|
743 | Article: 'Article',
|
744 | AudioObject: 'AudioObject',
|
745 | BooleanValidator: 'BooleanValidator',
|
746 | Brand: 'Brand',
|
747 | Cite: 'Cite',
|
748 | CiteGroup: 'CiteGroup',
|
749 | Code: 'Code',
|
750 | CodeBlock: 'CodeBlock',
|
751 | CodeChunk: 'CodeChunk',
|
752 | CodeError: 'CodeError',
|
753 | CodeExpression: 'CodeExpression',
|
754 | CodeFragment: 'CodeFragment',
|
755 | Collection: 'Collection',
|
756 | Comment: 'Comment',
|
757 | ConstantValidator: 'ConstantValidator',
|
758 | ContactPoint: 'ContactPoint',
|
759 | CreativeWork: 'CreativeWork',
|
760 | Datatable: 'Datatable',
|
761 | DatatableColumn: 'DatatableColumn',
|
762 | Date: 'Date',
|
763 | DefinedTerm: 'DefinedTerm',
|
764 | Delete: 'Delete',
|
765 | Emphasis: 'Emphasis',
|
766 | EnumValidator: 'EnumValidator',
|
767 | Figure: 'Figure',
|
768 | Function: 'Function',
|
769 | Grant: 'Grant',
|
770 | Heading: 'Heading',
|
771 | ImageObject: 'ImageObject',
|
772 | Include: 'Include',
|
773 | IntegerValidator: 'IntegerValidator',
|
774 | Link: 'Link',
|
775 | List: 'List',
|
776 | ListItem: 'ListItem',
|
777 | Mark: 'Mark',
|
778 | Math: 'Math',
|
779 | MathBlock: 'MathBlock',
|
780 | MathFragment: 'MathFragment',
|
781 | MediaObject: 'MediaObject',
|
782 | MonetaryGrant: 'MonetaryGrant',
|
783 | NontextualAnnotation: 'NontextualAnnotation',
|
784 | NumberValidator: 'NumberValidator',
|
785 | Organization: 'Organization',
|
786 | Paragraph: 'Paragraph',
|
787 | Parameter: 'Parameter',
|
788 | Periodical: 'Periodical',
|
789 | Person: 'Person',
|
790 | PostalAddress: 'PostalAddress',
|
791 | Product: 'Product',
|
792 | PropertyValue: 'PropertyValue',
|
793 | PublicationIssue: 'PublicationIssue',
|
794 | PublicationVolume: 'PublicationVolume',
|
795 | Quote: 'Quote',
|
796 | QuoteBlock: 'QuoteBlock',
|
797 | Review: 'Review',
|
798 | SoftwareApplication: 'SoftwareApplication',
|
799 | SoftwareEnvironment: 'SoftwareEnvironment',
|
800 | SoftwareSession: 'SoftwareSession',
|
801 | SoftwareSourceCode: 'SoftwareSourceCode',
|
802 | StringValidator: 'StringValidator',
|
803 | Strong: 'Strong',
|
804 | Subscript: 'Subscript',
|
805 | Superscript: 'Superscript',
|
806 | Table: 'Table',
|
807 | TableCell: 'TableCell',
|
808 | TableRow: 'TableRow',
|
809 | ThematicBreak: 'ThematicBreak',
|
810 | Thing: 'Thing',
|
811 | TupleValidator: 'TupleValidator',
|
812 | Variable: 'Variable',
|
813 | VideoObject: 'VideoObject',
|
814 | VolumeMount: 'VolumeMount'
|
815 | };
|
816 | const grantTypes = {
|
817 | Grant: 'Grant',
|
818 | MonetaryGrant: 'MonetaryGrant'
|
819 | };
|
820 | const markTypes = {
|
821 | Mark: 'Mark',
|
822 | Delete: 'Delete',
|
823 | Emphasis: 'Emphasis',
|
824 | NontextualAnnotation: 'NontextualAnnotation',
|
825 | Quote: 'Quote',
|
826 | Strong: 'Strong',
|
827 | Subscript: 'Subscript',
|
828 | Superscript: 'Superscript'
|
829 | };
|
830 | const mathTypes = {
|
831 | Math: 'Math',
|
832 | MathBlock: 'MathBlock',
|
833 | MathFragment: 'MathFragment'
|
834 | };
|
835 | const mediaObjectTypes = {
|
836 | MediaObject: 'MediaObject',
|
837 | AudioObject: 'AudioObject',
|
838 | ImageObject: 'ImageObject',
|
839 | VideoObject: 'VideoObject'
|
840 | };
|
841 | const numberValidatorTypes = {
|
842 | NumberValidator: 'NumberValidator',
|
843 | IntegerValidator: 'IntegerValidator'
|
844 | };
|
845 | const thingTypes = {
|
846 | Thing: 'Thing',
|
847 | Article: 'Article',
|
848 | AudioObject: 'AudioObject',
|
849 | Brand: 'Brand',
|
850 | Collection: 'Collection',
|
851 | Comment: 'Comment',
|
852 | ContactPoint: 'ContactPoint',
|
853 | CreativeWork: 'CreativeWork',
|
854 | Datatable: 'Datatable',
|
855 | DatatableColumn: 'DatatableColumn',
|
856 | DefinedTerm: 'DefinedTerm',
|
857 | Figure: 'Figure',
|
858 | Grant: 'Grant',
|
859 | ImageObject: 'ImageObject',
|
860 | ListItem: 'ListItem',
|
861 | MediaObject: 'MediaObject',
|
862 | MonetaryGrant: 'MonetaryGrant',
|
863 | Organization: 'Organization',
|
864 | Periodical: 'Periodical',
|
865 | Person: 'Person',
|
866 | PostalAddress: 'PostalAddress',
|
867 | Product: 'Product',
|
868 | PropertyValue: 'PropertyValue',
|
869 | PublicationIssue: 'PublicationIssue',
|
870 | PublicationVolume: 'PublicationVolume',
|
871 | Review: 'Review',
|
872 | SoftwareApplication: 'SoftwareApplication',
|
873 | SoftwareEnvironment: 'SoftwareEnvironment',
|
874 | SoftwareSession: 'SoftwareSession',
|
875 | SoftwareSourceCode: 'SoftwareSourceCode',
|
876 | Table: 'Table',
|
877 | VideoObject: 'VideoObject',
|
878 | VolumeMount: 'VolumeMount'
|
879 | };
|
880 | const validatorTypes = {
|
881 | ConstantValidator: 'ConstantValidator',
|
882 | EnumValidator: 'EnumValidator',
|
883 | BooleanValidator: 'BooleanValidator',
|
884 | NumberValidator: 'NumberValidator',
|
885 | IntegerValidator: 'IntegerValidator',
|
886 | StringValidator: 'StringValidator',
|
887 | ArrayValidator: 'ArrayValidator',
|
888 | TupleValidator: 'TupleValidator'
|
889 | };
|
890 | const variableTypes = {
|
891 | Variable: 'Variable',
|
892 | Parameter: 'Parameter'
|
893 | };
|
894 | const blockContentTypes = {
|
895 | CodeBlock: 'CodeBlock',
|
896 | CodeChunk: 'CodeChunk',
|
897 | Collection: 'Collection',
|
898 | Figure: 'Figure',
|
899 | Heading: 'Heading',
|
900 | List: 'List',
|
901 | ListItem: 'ListItem',
|
902 | MathBlock: 'MathBlock',
|
903 | Paragraph: 'Paragraph',
|
904 | QuoteBlock: 'QuoteBlock',
|
905 | Table: 'Table',
|
906 | ThematicBreak: 'ThematicBreak'
|
907 | };
|
908 | const inlineContentTypes = {
|
909 | CodeFragment: 'CodeFragment',
|
910 | CodeExpression: 'CodeExpression',
|
911 | Delete: 'Delete',
|
912 | Emphasis: 'Emphasis',
|
913 | ImageObject: 'ImageObject',
|
914 | Link: 'Link',
|
915 | MathFragment: 'MathFragment',
|
916 | NontextualAnnotation: 'NontextualAnnotation',
|
917 | Quote: 'Quote',
|
918 | Strong: 'Strong',
|
919 | Subscript: 'Subscript',
|
920 | Superscript: 'Superscript',
|
921 | Cite: 'Cite',
|
922 | CiteGroup: 'CiteGroup'
|
923 | };
|
924 |
|
925 |
|
926 |
|
927 |
|
928 |
|
929 |
|
930 |
|
931 |
|
932 | const typeIs = typeMap => type => Object.keys(typeMap).includes(type);
|
933 |
|
934 |
|
935 |
|
936 |
|
937 |
|
938 |
|
939 |
|
940 |
|
941 |
|
942 |
|
943 |
|
944 | const nodeIs = typeMap => node => {
|
945 | return isEntity(node) ? typeIs(typeMap)(node.type) : false;
|
946 | };
|
947 |
|
948 |
|
949 |
|
950 |
|
951 |
|
952 |
|
953 |
|
954 |
|
955 |
|
956 | const is = type => {
|
957 |
|
958 |
|
959 | const typeMap = {
|
960 | [type]: type
|
961 | };
|
962 | return nodeIs(typeMap);
|
963 | };
|
964 |
|
965 |
|
966 |
|
967 |
|
968 |
|
969 |
|
970 |
|
971 |
|
972 |
|
973 |
|
974 |
|
975 | const isA = (type, node) => {
|
976 | return isEntity(node) && node.type === type;
|
977 | };
|
978 | const isInstanceOf = (typeMap, node) => {
|
979 | return isEntity(node) && Object.keys(typeMap).includes(node.type);
|
980 | };
|
981 |
|
982 |
|
983 |
|
984 |
|
985 |
|
986 |
|
987 |
|
988 |
|
989 |
|
990 |
|
991 | const isType = type => node => {
|
992 | return node !== undefined && isA(type, node);
|
993 | };
|
994 |
|
995 |
|
996 |
|
997 |
|
998 |
|
999 |
|
1000 |
|
1001 |
|
1002 | const isPrimitive = node => {
|
1003 | const type = typeof node;
|
1004 | if (node === null) return true;
|
1005 | if (type === 'boolean') return true;
|
1006 | if (type === 'number') return true;
|
1007 | if (type === 'string') return true;
|
1008 | return false;
|
1009 | };
|
1010 |
|
1011 |
|
1012 |
|
1013 |
|
1014 |
|
1015 |
|
1016 |
|
1017 | const isEntity = node => {
|
1018 | if (node === null || node === undefined) return false;
|
1019 | return Object.prototype.hasOwnProperty.call(node, 'type');
|
1020 | };
|
1021 |
|
1022 |
|
1023 |
|
1024 |
|
1025 |
|
1026 |
|
1027 |
|
1028 |
|
1029 | const isInlineEntity = node => {
|
1030 | return typeof node === 'object' && isEntity(node) ? typeIs(inlineContentTypes)(node.type) : false;
|
1031 | };
|
1032 |
|
1033 |
|
1034 |
|
1035 |
|
1036 |
|
1037 |
|
1038 |
|
1039 | const isInlineContent = node => {
|
1040 | return isPrimitive(node) || isInlineEntity(node);
|
1041 | };
|
1042 |
|
1043 |
|
1044 |
|
1045 |
|
1046 |
|
1047 |
|
1048 |
|
1049 | const isBlockContent = nodeIs(blockContentTypes);
|
1050 |
|
1051 |
|
1052 |
|
1053 |
|
1054 |
|
1055 |
|
1056 |
|
1057 | const isCreativeWork = nodeIs(creativeWorkTypes);
|
1058 |
|
1059 |
|
1060 |
|
1061 |
|
1062 |
|
1063 |
|
1064 |
|
1065 | const isCode = nodeIs(codeTypes);
|
1066 |
|
1067 |
|
1068 |
|
1069 |
|
1070 |
|
1071 |
|
1072 |
|
1073 | const isArticle = is('Article');
|
1074 |
|
1075 |
|
1076 |
|
1077 |
|
1078 |
|
1079 |
|
1080 |
|
1081 | const isParagraph = is('Paragraph');
|
1082 |
|
1083 |
|
1084 |
|
1085 |
|
1086 |
|
1087 |
|
1088 |
|
1089 | const isListItem = is('ListItem');
|
1090 |
|
1091 | var version = "0.47.2";
|
1092 |
|
1093 |
|
1094 |
|
1095 |
|
1096 |
|
1097 | const version$1 = version;
|
1098 |
|
1099 |
|
1100 |
|
1101 |
|
1102 | const versionMajor = version$1.split('.')[0];
|
1103 |
|
1104 |
|
1105 |
|
1106 |
|
1107 | const versionMinor = version$1.split('.').slice(0, 2).join('.');
|
1108 |
|
1109 |
|
1110 |
|
1111 |
|
1112 | let CONTEXT;
|
1113 |
|
1114 |
|
1115 | const termToId = {};
|
1116 | const idToTerm = {};
|
1117 |
|
1118 | function initMaps() {
|
1119 | const context = jsonLdContext();
|
1120 |
|
1121 | for (const [term, value] of Object.entries(context)) {
|
1122 | if (typeof value === 'string' && !term.startsWith('@')) {
|
1123 | termToId[term] = value;
|
1124 | idToTerm[value] = term;
|
1125 | } else if (typeof value === 'object') {
|
1126 | const id = value['@id'];
|
1127 | termToId[term] = id;
|
1128 | idToTerm[id] = term;
|
1129 | }
|
1130 | }
|
1131 | }
|
1132 |
|
1133 |
|
1134 |
|
1135 |
|
1136 |
|
1137 |
|
1138 |
|
1139 |
|
1140 |
|
1141 |
|
1142 |
|
1143 |
|
1144 |
|
1145 |
|
1146 | function jsonLdUrl(term = '') {
|
1147 | return `http://schema.stenci.la/v${versionMajor}/jsonld/${term}`;
|
1148 | }
|
1149 |
|
1150 |
|
1151 |
|
1152 |
|
1153 | function jsonLdContext() {
|
1154 | if (CONTEXT === undefined) {
|
1155 | const json = fs__default['default'].readFileSync(path__default['default'].join(__dirname, ...(__filename.endsWith('.ts') ? ['..', '..', 'public'] : []), 'stencila.jsonld'), 'utf8');
|
1156 | CONTEXT = JSON.parse(json)['@context'];
|
1157 | }
|
1158 |
|
1159 | return CONTEXT;
|
1160 | }
|
1161 |
|
1162 |
|
1163 |
|
1164 |
|
1165 |
|
1166 |
|
1167 |
|
1168 |
|
1169 |
|
1170 |
|
1171 |
|
1172 |
|
1173 |
|
1174 |
|
1175 |
|
1176 |
|
1177 | function jsonLdTermUrl(term) {
|
1178 | if (Object.keys(termToId).length === 0) initMaps();
|
1179 | const id = termToId[term];
|
1180 | if (id === undefined) return undefined;
|
1181 | const [prefix, name] = id.split(':');
|
1182 | const context = jsonLdContext();
|
1183 | const base = context[prefix];
|
1184 | if (base === undefined) return undefined;
|
1185 | return `${base}${name}`;
|
1186 | }
|
1187 |
|
1188 |
|
1189 |
|
1190 |
|
1191 |
|
1192 |
|
1193 |
|
1194 |
|
1195 |
|
1196 | function jsonLdTermName(url) {
|
1197 | if (Object.keys(idToTerm).length === 0) initMaps();
|
1198 |
|
1199 | const {
|
1200 | hash,
|
1201 | pathname
|
1202 | } = new URL(url);
|
1203 | const term = hash !== '' ? hash.slice(1) : pathname.split('/').pop();
|
1204 | const baseUrl = url.replace(new RegExp(`${term}$`), '');
|
1205 |
|
1206 | const prefix = idToTerm[baseUrl];
|
1207 | if (prefix === undefined) return undefined;
|
1208 |
|
1209 | return idToTerm[`${prefix}:${term}`];
|
1210 | }
|
1211 |
|
1212 | let SCHEMAS = {};
|
1213 |
|
1214 | let PROPERTIES = {};
|
1215 |
|
1216 |
|
1217 |
|
1218 |
|
1219 | async function jsonSchemas() {
|
1220 | if (Object.keys(SCHEMAS).length === 0) {
|
1221 | const dir = path__default['default'].join(__dirname, ...(__filename.endsWith('.ts') ? ['..', '..', 'public'] : []));
|
1222 | const files = await new Promise((resolve, reject) => fs__default['default'].readdir(dir, 'utf8', (error, files) => error !== null ? reject(error) : resolve(files)));
|
1223 | const schemaFiles = files.filter(filename => filename.endsWith('.schema.json'));
|
1224 | const promises = schemaFiles.map(async file => {
|
1225 | const json = await new Promise((resolve, reject) => fs__default['default'].readFile(path__default['default'].join(dir, file), 'utf8', (error, content) => error !== null ? reject(error) : resolve(content)));
|
1226 | return JSON.parse(json);
|
1227 | });
|
1228 | const schemas = await Promise.all(promises);
|
1229 | SCHEMAS = schemas.reduce((prev, schema) => {
|
1230 | const {
|
1231 | title
|
1232 | } = schema;
|
1233 | return title === undefined ? prev : _extends({}, prev, {
|
1234 | [title]: schema
|
1235 | });
|
1236 | }, {});
|
1237 | }
|
1238 |
|
1239 | return SCHEMAS;
|
1240 | }
|
1241 |
|
1242 |
|
1243 |
|
1244 |
|
1245 | async function jsonSchemaTypes() {
|
1246 | const schemas = await jsonSchemas();
|
1247 | return Object.keys(schemas);
|
1248 | }
|
1249 |
|
1250 |
|
1251 |
|
1252 |
|
1253 |
|
1254 |
|
1255 |
|
1256 |
|
1257 | async function jsonSchemaProperties() {
|
1258 | if (Object.keys(PROPERTIES).length === 0) {
|
1259 | const schemas = await jsonSchemas();
|
1260 |
|
1261 | const props = Object.values(schemas).reduce((prev, type) => {
|
1262 | const {
|
1263 | title = '',
|
1264 | properties = {}
|
1265 | } = type;
|
1266 | Object.entries(properties).forEach(([name, prop]) => {
|
1267 | const {
|
1268 | '@id': id = '',
|
1269 | isArray = false,
|
1270 | isPlural = false
|
1271 | } = prop;
|
1272 | const existing = prev[name];
|
1273 |
|
1274 | if (existing === undefined) {
|
1275 | prev[name] = {
|
1276 | name,
|
1277 | id,
|
1278 | domainIncludes: [title],
|
1279 | isArray,
|
1280 | isPlural
|
1281 | };
|
1282 | } else {
|
1283 |
|
1284 |
|
1285 |
|
1286 |
|
1287 | const message = `${title}.${name} differs to that on ${existing.domainIncludes}`;
|
1288 | if (id !== existing.id) throw new Error(`${message}: @id ${id}`);
|
1289 | if (isArray !== existing.isArray) throw new Error(`${message}: isArray ${isArray}`);
|
1290 | if (isPlural !== existing.isPlural) throw new Error(`${message}: isPlural ${isPlural}`);
|
1291 |
|
1292 | existing.domainIncludes.push(title);
|
1293 | }
|
1294 | });
|
1295 | return prev;
|
1296 | }, {});
|
1297 |
|
1298 | PROPERTIES = Object.keys(props).sort().reduce((prev, key) => _extends({}, prev, {
|
1299 | [key]: props[key]
|
1300 | }), {});
|
1301 | }
|
1302 |
|
1303 | return PROPERTIES;
|
1304 | }
|
1305 |
|
1306 |
|
1307 |
|
1308 |
|
1309 |
|
1310 |
|
1311 |
|
1312 | const nodeType = node => {
|
1313 | if (node === null) return 'Null';
|
1314 | if (typeof node === 'boolean') return 'Boolean';
|
1315 | if (typeof node === 'number') return 'Number';
|
1316 | if (typeof node === 'string') return 'Text';
|
1317 | if (Array.isArray(node)) return 'Array';
|
1318 | if (isEntity(node)) return node.type;
|
1319 | return 'Object';
|
1320 | };
|
1321 |
|
1322 |
|
1323 |
|
1324 |
|
1325 |
|
1326 |
|
1327 |
|
1328 |
|
1329 | function microdataUrl(type = '') {
|
1330 | return `http://schema.stenci.la/${type}`;
|
1331 | }
|
1332 |
|
1333 |
|
1334 |
|
1335 |
|
1336 |
|
1337 |
|
1338 |
|
1339 |
|
1340 |
|
1341 |
|
1342 |
|
1343 |
|
1344 | function microdataItem(node, id) {
|
1345 | const itemtype = microdataItemtype(nodeType(node));
|
1346 | const itemidAttr = id !== undefined ? {
|
1347 | itemid: `#${id}`
|
1348 | } : {};
|
1349 | if (itemtype !== undefined && !isPrimitive(node)) return _extends({
|
1350 | itemscope: '',
|
1351 | itemtype
|
1352 | }, itemidAttr);else if (typeof node !== 'string') return _extends({
|
1353 | 'data-itemtype': itemtype
|
1354 | }, itemidAttr);else return itemidAttr;
|
1355 | }
|
1356 |
|
1357 |
|
1358 |
|
1359 |
|
1360 |
|
1361 |
|
1362 | function microdataItemtype(type) {
|
1363 | var _jsonLdTermUrl;
|
1364 |
|
1365 | return (_jsonLdTermUrl = jsonLdTermUrl(type)) == null ? void 0 : _jsonLdTermUrl.replace(jsonLdUrl(), microdataUrl());
|
1366 | }
|
1367 |
|
1368 |
|
1369 |
|
1370 |
|
1371 |
|
1372 |
|
1373 | function microdataType(itemtype) {
|
1374 | return jsonLdTermName(itemtype.replace(microdataUrl(), jsonLdUrl()));
|
1375 | }
|
1376 |
|
1377 |
|
1378 |
|
1379 |
|
1380 |
|
1381 |
|
1382 |
|
1383 |
|
1384 |
|
1385 | function microdataProperty(property, role, id) {
|
1386 | const [prefix, name = ''] = microdataItemprop(property, role);
|
1387 | const key = prefix === 'schema' ? 'itemprop' : 'data-itemprop';
|
1388 | const itemrefAttr = id !== undefined ? {
|
1389 | itemref: id
|
1390 | } : {};
|
1391 | return _extends({
|
1392 | [key]: name
|
1393 | }, itemrefAttr);
|
1394 | }
|
1395 |
|
1396 |
|
1397 |
|
1398 |
|
1399 |
|
1400 |
|
1401 |
|
1402 |
|
1403 |
|
1404 |
|
1405 |
|
1406 |
|
1407 |
|
1408 |
|
1409 |
|
1410 |
|
1411 | function microdataItemprop(property, role) {
|
1412 | if (role === 'array') return ['stencila', property];
|
1413 | const context = jsonLdContext();
|
1414 | const mapping = context[property];
|
1415 | if (mapping === undefined) return [undefined, undefined];
|
1416 | if (typeof mapping === 'string') return [undefined, mapping];
|
1417 | const id = mapping['@id'];
|
1418 | let [prefix, name] = id.split(':');
|
1419 |
|
1420 |
|
1421 |
|
1422 |
|
1423 |
|
1424 | if (role === 'item' && prefix === 'stencila' && name.endsWith('s')) name = name.slice(0, -1);
|
1425 | return [prefix, name];
|
1426 | }
|
1427 |
|
1428 |
|
1429 |
|
1430 |
|
1431 |
|
1432 |
|
1433 |
|
1434 |
|
1435 |
|
1436 | function microdata(node, property, role, id) {
|
1437 | return _extends({}, role !== 'array' ? microdataItem(node, property === undefined ? id : undefined) : {}, property !== undefined ? microdataProperty(property, role, id) : {});
|
1438 | }
|
1439 |
|
1440 |
|
1441 |
|
1442 |
|
1443 |
|
1444 |
|
1445 |
|
1446 |
|
1447 |
|
1448 |
|
1449 |
|
1450 |
|
1451 | function microdataRoot() {
|
1452 | return {
|
1453 | 'data-itemscope': 'root'
|
1454 | };
|
1455 | }
|
1456 |
|
1457 | exports.arrayValidator = arrayValidator;
|
1458 | exports.article = article;
|
1459 | exports.audioObject = audioObject;
|
1460 | exports.blockContentTypes = blockContentTypes;
|
1461 | exports.booleanValidator = booleanValidator;
|
1462 | exports.brand = brand;
|
1463 | exports.cite = cite;
|
1464 | exports.citeGroup = citeGroup;
|
1465 | exports.code = code;
|
1466 | exports.codeBlock = codeBlock;
|
1467 | exports.codeBlockTypes = codeBlockTypes;
|
1468 | exports.codeChunk = codeChunk;
|
1469 | exports.codeError = codeError;
|
1470 | exports.codeExpression = codeExpression;
|
1471 | exports.codeFragment = codeFragment;
|
1472 | exports.codeFragmentTypes = codeFragmentTypes;
|
1473 | exports.codeTypes = codeTypes;
|
1474 | exports.collection = collection;
|
1475 | exports.comment = comment;
|
1476 | exports.constantValidator = constantValidator;
|
1477 | exports.contactPoint = contactPoint;
|
1478 | exports.contactPointTypes = contactPointTypes;
|
1479 | exports.creativeWork = creativeWork;
|
1480 | exports.creativeWorkTypes = creativeWorkTypes;
|
1481 | exports.datatable = datatable;
|
1482 | exports.datatableColumn = datatableColumn;
|
1483 | exports.date = date;
|
1484 | exports.definedTerm = definedTerm;
|
1485 | exports.del = del;
|
1486 | exports.emphasis = emphasis;
|
1487 | exports.entity = entity;
|
1488 | exports.entityTypes = entityTypes;
|
1489 | exports.enumValidator = enumValidator;
|
1490 | exports.figure = figure;
|
1491 | exports.function_ = function_;
|
1492 | exports.grant = grant;
|
1493 | exports.grantTypes = grantTypes;
|
1494 | exports.heading = heading;
|
1495 | exports.imageObject = imageObject;
|
1496 | exports.include = include;
|
1497 | exports.inlineContentTypes = inlineContentTypes;
|
1498 | exports.integerValidator = integerValidator;
|
1499 | exports.is = is;
|
1500 | exports.isA = isA;
|
1501 | exports.isArticle = isArticle;
|
1502 | exports.isBlockContent = isBlockContent;
|
1503 | exports.isCode = isCode;
|
1504 | exports.isCreativeWork = isCreativeWork;
|
1505 | exports.isEntity = isEntity;
|
1506 | exports.isInlineContent = isInlineContent;
|
1507 | exports.isInlineEntity = isInlineEntity;
|
1508 | exports.isInstanceOf = isInstanceOf;
|
1509 | exports.isListItem = isListItem;
|
1510 | exports.isParagraph = isParagraph;
|
1511 | exports.isPrimitive = isPrimitive;
|
1512 | exports.isType = isType;
|
1513 | exports.jsonLdContext = jsonLdContext;
|
1514 | exports.jsonLdTermName = jsonLdTermName;
|
1515 | exports.jsonLdTermUrl = jsonLdTermUrl;
|
1516 | exports.jsonLdUrl = jsonLdUrl;
|
1517 | exports.jsonSchemaProperties = jsonSchemaProperties;
|
1518 | exports.jsonSchemaTypes = jsonSchemaTypes;
|
1519 | exports.jsonSchemas = jsonSchemas;
|
1520 | exports.link = link;
|
1521 | exports.list = list;
|
1522 | exports.listItem = listItem;
|
1523 | exports.mark = mark;
|
1524 | exports.markTypes = markTypes;
|
1525 | exports.math = math;
|
1526 | exports.mathBlock = mathBlock;
|
1527 | exports.mathFragment = mathFragment;
|
1528 | exports.mathTypes = mathTypes;
|
1529 | exports.mediaObject = mediaObject;
|
1530 | exports.mediaObjectTypes = mediaObjectTypes;
|
1531 | exports.microdata = microdata;
|
1532 | exports.microdataItem = microdataItem;
|
1533 | exports.microdataItemprop = microdataItemprop;
|
1534 | exports.microdataItemtype = microdataItemtype;
|
1535 | exports.microdataProperty = microdataProperty;
|
1536 | exports.microdataRoot = microdataRoot;
|
1537 | exports.microdataType = microdataType;
|
1538 | exports.microdataUrl = microdataUrl;
|
1539 | exports.monetaryGrant = monetaryGrant;
|
1540 | exports.nodeIs = nodeIs;
|
1541 | exports.nodeType = nodeType;
|
1542 | exports.nontextualAnnotation = nontextualAnnotation;
|
1543 | exports.numberValidator = numberValidator;
|
1544 | exports.numberValidatorTypes = numberValidatorTypes;
|
1545 | exports.organization = organization;
|
1546 | exports.paragraph = paragraph;
|
1547 | exports.parameter = parameter;
|
1548 | exports.periodical = periodical;
|
1549 | exports.person = person;
|
1550 | exports.postalAddress = postalAddress;
|
1551 | exports.product = product;
|
1552 | exports.propertyValue = propertyValue;
|
1553 | exports.publicationIssue = publicationIssue;
|
1554 | exports.publicationVolume = publicationVolume;
|
1555 | exports.quote = quote;
|
1556 | exports.quoteBlock = quoteBlock;
|
1557 | exports.review = review;
|
1558 | exports.softwareApplication = softwareApplication;
|
1559 | exports.softwareEnvironment = softwareEnvironment;
|
1560 | exports.softwareSession = softwareSession;
|
1561 | exports.softwareSourceCode = softwareSourceCode;
|
1562 | exports.stringValidator = stringValidator;
|
1563 | exports.strong = strong;
|
1564 | exports.subscript = subscript;
|
1565 | exports.superscript = superscript;
|
1566 | exports.table = table;
|
1567 | exports.tableCell = tableCell;
|
1568 | exports.tableRow = tableRow;
|
1569 | exports.thematicBreak = thematicBreak;
|
1570 | exports.thing = thing;
|
1571 | exports.thingTypes = thingTypes;
|
1572 | exports.tupleValidator = tupleValidator;
|
1573 | exports.typeIs = typeIs;
|
1574 | exports.validatorTypes = validatorTypes;
|
1575 | exports.variable = variable;
|
1576 | exports.variableTypes = variableTypes;
|
1577 | exports.version = version$1;
|
1578 | exports.versionMajor = versionMajor;
|
1579 | exports.versionMinor = versionMinor;
|
1580 | exports.videoObject = videoObject;
|
1581 | exports.volumeMount = volumeMount;
|
1582 |
|