@vitessce/vit-s 2.0.0-beta.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/LICENSE +21 -0
- package/dist/CallbackPublisher.js +68 -0
- package/dist/LoadingIndicator.js +27 -0
- package/dist/TitleInfo.js +151 -0
- package/dist/VitS.js +113 -0
- package/dist/Vitessce.integration.test.js +36 -0
- package/dist/Vitessce.js +101 -0
- package/dist/VitessceGrid.js +55 -0
- package/dist/VitessceGrid.test.js +36 -0
- package/dist/Warning.js +45 -0
- package/dist/classNames.js +8 -0
- package/dist/component-registry.js +16 -0
- package/dist/data/AbstractLoader.js +35 -0
- package/dist/data/AbstractTwoStepLoader.js +7 -0
- package/dist/data/LoaderResult.js +7 -0
- package/dist/data/index.js +3 -0
- package/dist/data/loader-registry.js +15 -0
- package/dist/data-hook-utils.js +175 -0
- package/dist/data-hooks.js +241 -0
- package/dist/errors/AbstractLoaderError.js +13 -0
- package/dist/errors/DataSourceFetchError.js +13 -0
- package/dist/errors/DatasetNotFoundError.js +17 -0
- package/dist/errors/LoaderNotFoundError.js +17 -0
- package/dist/errors/LoaderValidationError.js +15 -0
- package/dist/errors/OptionsValidationError.js +15 -0
- package/dist/errors/index.js +6 -0
- package/dist/export-utils.js +70 -0
- package/dist/export-utils.test.js +66 -0
- package/dist/file-options-schemas-legacy.js +136 -0
- package/dist/file-options-schemas-legacy.test.js +126 -0
- package/dist/file-options-schemas.js +322 -0
- package/dist/file-options-schemas.test.js +23 -0
- package/dist/hooks.js +215 -0
- package/dist/index.js +18 -0
- package/dist/joint-file-types-legacy.js +278 -0
- package/dist/joint-file-types-legacy.test.js +400 -0
- package/dist/joint-file-types.js +148 -0
- package/dist/joint-file-types.test.js +139 -0
- package/dist/loader-registry.js +98 -0
- package/dist/plugins.js +154 -0
- package/dist/plugins.test.fixtures.js +76 -0
- package/dist/plugins.test.js +30 -0
- package/dist/schemas/PrettyJsonSchema.js +34 -0
- package/dist/schemas/config-0.1.0.schema.json +84 -0
- package/dist/schemas/config-1.0.0.schema.json +733 -0
- package/dist/schemas/config-1.0.1.schema.json +909 -0
- package/dist/schemas/config-1.0.10.schema.json +969 -0
- package/dist/schemas/config-1.0.11.schema.json +990 -0
- package/dist/schemas/config-1.0.12.schema.json +997 -0
- package/dist/schemas/config-1.0.13.schema.json +1013 -0
- package/dist/schemas/config-1.0.14.schema.json +1048 -0
- package/dist/schemas/config-1.0.15.schema.json +1048 -0
- package/dist/schemas/config-1.0.15.schema.test.js +22 -0
- package/dist/schemas/config-1.0.2.schema.json +910 -0
- package/dist/schemas/config-1.0.3.schema.json +910 -0
- package/dist/schemas/config-1.0.4.schema.json +949 -0
- package/dist/schemas/config-1.0.5.schema.json +949 -0
- package/dist/schemas/config-1.0.6.schema.json +949 -0
- package/dist/schemas/config-1.0.7.schema.json +949 -0
- package/dist/schemas/config-1.0.8.schema.json +965 -0
- package/dist/schemas/config-1.0.9.schema.json +965 -0
- package/dist/schemas/obsSets.schema.js +195 -0
- package/dist/schemas/obsSets.schema.json +194 -0
- package/dist/schemas/obsSetsTabular.schema.js +38 -0
- package/dist/schemas/obsSetsTabular.schema.json +37 -0
- package/dist/schemas/raster.schema.js +120 -0
- package/dist/schemas/raster.schema.json +119 -0
- package/dist/schemas/schema.test-old.js +50 -0
- package/dist/schemas/schema.test.js +46 -0
- package/dist/schemas.js +4 -0
- package/dist/shared-mui/components.js +35 -0
- package/dist/shared-mui/container.js +211 -0
- package/dist/shared-mui/styles.js +63 -0
- package/dist/shared-plot-options/CellColorEncodingOption.js +18 -0
- package/dist/shared-plot-options/OptionSelect.js +12 -0
- package/dist/shared-plot-options/OptionsContainer.js +12 -0
- package/dist/shared-plot-options/index.js +4 -0
- package/dist/shared-plot-options/styles.js +48 -0
- package/dist/state/hooks.js +550 -0
- package/dist/view-config-upgraders.js +525 -0
- package/dist/view-config-utils.js +286 -0
- package/dist/view-config-utils.test.fixtures.js +765 -0
- package/dist/view-config-utils.test.js +66 -0
- package/dist/view-config-versions.js +47 -0
- package/dist/vitessce-grid-layout/VitessceGridLayout.js +96 -0
- package/dist/vitessce-grid-layout/VitessceGridLayout.test.js +40 -0
- package/dist/vitessce-grid-layout/index.js +1 -0
- package/dist/vitessce-grid-layout/layout-utils.js +61 -0
- package/dist/vitessce-grid-layout/layout-utils.test.js +146 -0
- package/dist/vitessce-grid-utils.js +140 -0
- package/package.json +43 -0
|
@@ -0,0 +1,148 @@
|
|
|
1
|
+
import { FileType } from '@vitessce/constants-internal';
|
|
2
|
+
import { validateOptions, anndataZarrSchema, } from './file-options-schemas';
|
|
3
|
+
import { expandMoleculesJson, expandExpressionMatrixZarr, expandRasterJson, expandRasterOmeZarr, expandCellSetsJson, expandCellsJson, expandClustersJson, expandGenesJson, expandAnndataCellsZarr, expandAnndataCellSetsZarr, expandAnndataExpressionMatrixZarr, } from './joint-file-types-legacy';
|
|
4
|
+
export function expandAnndataZarr(fileDef) {
|
|
5
|
+
validateOptions(anndataZarrSchema, fileDef.options);
|
|
6
|
+
const baseFileDef = {
|
|
7
|
+
url: fileDef.url,
|
|
8
|
+
requestInit: fileDef.requestInit,
|
|
9
|
+
coordinationValues: {
|
|
10
|
+
...fileDef.coordinationValues,
|
|
11
|
+
obsType: fileDef.coordinationValues?.obsType || 'cell',
|
|
12
|
+
featureType: fileDef.coordinationValues?.featureType || 'gene',
|
|
13
|
+
featureValueType: fileDef.coordinationValues?.featureValueType || 'expression',
|
|
14
|
+
},
|
|
15
|
+
};
|
|
16
|
+
const { options = {} } = fileDef;
|
|
17
|
+
return [
|
|
18
|
+
// obsFeatureMatrix
|
|
19
|
+
...(options.obsFeatureMatrix ? [{
|
|
20
|
+
...baseFileDef,
|
|
21
|
+
fileType: FileType.OBS_FEATURE_MATRIX_ANNDATA_ZARR,
|
|
22
|
+
options: options.obsFeatureMatrix,
|
|
23
|
+
coordinationValues: {
|
|
24
|
+
obsType: baseFileDef.coordinationValues.obsType,
|
|
25
|
+
featureType: baseFileDef.coordinationValues.featureType,
|
|
26
|
+
featureValueType: baseFileDef.coordinationValues.featureValueType,
|
|
27
|
+
},
|
|
28
|
+
}] : []),
|
|
29
|
+
// obsSets
|
|
30
|
+
...(options.obsSets ? [{
|
|
31
|
+
...baseFileDef,
|
|
32
|
+
fileType: FileType.OBS_SETS_ANNDATA_ZARR,
|
|
33
|
+
options: options.obsSets,
|
|
34
|
+
coordinationValues: {
|
|
35
|
+
obsType: baseFileDef.coordinationValues.obsType,
|
|
36
|
+
},
|
|
37
|
+
}] : []),
|
|
38
|
+
// obsLocations
|
|
39
|
+
...(options.obsLocations ? [{
|
|
40
|
+
...baseFileDef,
|
|
41
|
+
fileType: FileType.OBS_LOCATIONS_ANNDATA_ZARR,
|
|
42
|
+
options: options.obsLocations,
|
|
43
|
+
coordinationValues: {
|
|
44
|
+
obsType: baseFileDef.coordinationValues.obsType,
|
|
45
|
+
},
|
|
46
|
+
}] : []),
|
|
47
|
+
// obsSegmentations
|
|
48
|
+
...(options.obsSegmentations ? [{
|
|
49
|
+
...baseFileDef,
|
|
50
|
+
fileType: FileType.OBS_SEGMENTATIONS_ANNDATA_ZARR,
|
|
51
|
+
options: options.obsSegmentations,
|
|
52
|
+
coordinationValues: {
|
|
53
|
+
obsType: baseFileDef.coordinationValues.obsType,
|
|
54
|
+
},
|
|
55
|
+
}] : []),
|
|
56
|
+
// obsEmbedding
|
|
57
|
+
// eslint-disable-next-line no-nested-ternary
|
|
58
|
+
...(options.obsEmbedding ? (Array.isArray(options.obsEmbedding) ? options.obsEmbedding.map(oe => ({
|
|
59
|
+
// obsEmbedding was an array, process each element.
|
|
60
|
+
...baseFileDef,
|
|
61
|
+
fileType: FileType.OBS_EMBEDDING_ANNDATA_ZARR,
|
|
62
|
+
options: {
|
|
63
|
+
path: oe.path,
|
|
64
|
+
dims: oe.dims,
|
|
65
|
+
},
|
|
66
|
+
coordinationValues: {
|
|
67
|
+
obsType: baseFileDef.coordinationValues.obsType,
|
|
68
|
+
// Move embedding type property out of options and into coordinationValues.
|
|
69
|
+
embeddingType: oe.embeddingType,
|
|
70
|
+
},
|
|
71
|
+
})) : [{
|
|
72
|
+
// obsEmbedding was an object.
|
|
73
|
+
...baseFileDef,
|
|
74
|
+
fileType: FileType.OBS_EMBEDDING_ANNDATA_ZARR,
|
|
75
|
+
options: options.obsEmbedding,
|
|
76
|
+
coordinationValues: {
|
|
77
|
+
obsType: baseFileDef.coordinationValues.obsType,
|
|
78
|
+
embeddingType: baseFileDef.coordinationValues.embeddingType,
|
|
79
|
+
},
|
|
80
|
+
}]) : []),
|
|
81
|
+
// obsLabels
|
|
82
|
+
// eslint-disable-next-line no-nested-ternary
|
|
83
|
+
...(options.obsLabels ? (Array.isArray(options.obsLabels) ? options.obsLabels.map(ol => ({
|
|
84
|
+
// obsLabels was an array, process each element.
|
|
85
|
+
...baseFileDef,
|
|
86
|
+
fileType: FileType.OBS_LABELS_ANNDATA_ZARR,
|
|
87
|
+
options: {
|
|
88
|
+
path: ol.path,
|
|
89
|
+
},
|
|
90
|
+
coordinationValues: {
|
|
91
|
+
obsType: baseFileDef.coordinationValues.obsType,
|
|
92
|
+
// Move obsLabels type property out of options and into coordinationValues.
|
|
93
|
+
obsLabelsType: ol.obsLabelsType,
|
|
94
|
+
},
|
|
95
|
+
})) : [{
|
|
96
|
+
// obsLabels was an object.
|
|
97
|
+
...baseFileDef,
|
|
98
|
+
fileType: FileType.OBS_LABELS_ANNDATA_ZARR,
|
|
99
|
+
options: options.obsLabels,
|
|
100
|
+
coordinationValues: {
|
|
101
|
+
obsType: baseFileDef.coordinationValues.obsType,
|
|
102
|
+
obsLabelsType: baseFileDef.coordinationValues.obsLabelsType,
|
|
103
|
+
},
|
|
104
|
+
}]) : []),
|
|
105
|
+
// featureLabels
|
|
106
|
+
// eslint-disable-next-line no-nested-ternary
|
|
107
|
+
...(options.featureLabels ? (Array.isArray(options.featureLabels) ? options.featureLabels.map(fl => ({
|
|
108
|
+
// featureLabels was an array, process each element.
|
|
109
|
+
...baseFileDef,
|
|
110
|
+
fileType: FileType.FEATURE_LABELS_ANNDATA_ZARR,
|
|
111
|
+
options: {
|
|
112
|
+
path: fl.path,
|
|
113
|
+
},
|
|
114
|
+
coordinationValues: {
|
|
115
|
+
featureType: baseFileDef.coordinationValues.featureType,
|
|
116
|
+
// Move featureLabels type property out of options and into coordinationValues.
|
|
117
|
+
featureLabelsType: fl.featureLabelsType,
|
|
118
|
+
},
|
|
119
|
+
})) : [{
|
|
120
|
+
// featureLabels was an object.
|
|
121
|
+
...baseFileDef,
|
|
122
|
+
fileType: FileType.FEATURE_LABELS_ANNDATA_ZARR,
|
|
123
|
+
options: options.featureLabels,
|
|
124
|
+
coordinationValues: {
|
|
125
|
+
featureType: baseFileDef.coordinationValues.featureType,
|
|
126
|
+
featureLabelsType: baseFileDef.coordinationValues.featureLabelsType,
|
|
127
|
+
},
|
|
128
|
+
}]) : []),
|
|
129
|
+
];
|
|
130
|
+
}
|
|
131
|
+
/**
|
|
132
|
+
* Built-in joint file type
|
|
133
|
+
* expansion functions.
|
|
134
|
+
*/
|
|
135
|
+
export const JOINT_FILE_TYPES = {
|
|
136
|
+
[FileType.ANNDATA_ZARR]: expandAnndataZarr,
|
|
137
|
+
[FileType.ANNDATA_CELLS_ZARR]: expandAnndataCellsZarr,
|
|
138
|
+
[FileType.ANNDATA_CELL_SETS_ZARR]: expandAnndataCellSetsZarr,
|
|
139
|
+
[FileType.ANNDATA_EXPRESSION_MATRIX_ZARR]: expandAnndataExpressionMatrixZarr,
|
|
140
|
+
[FileType.EXPRESSION_MATRIX_ZARR]: expandExpressionMatrixZarr,
|
|
141
|
+
[FileType.RASTER_JSON]: expandRasterJson,
|
|
142
|
+
[FileType.RASTER_OME_ZARR]: expandRasterOmeZarr,
|
|
143
|
+
[FileType.CELL_SETS_JSON]: expandCellSetsJson,
|
|
144
|
+
[FileType.CLUSTERS_JSON]: expandClustersJson,
|
|
145
|
+
[FileType.GENES_JSON]: expandGenesJson,
|
|
146
|
+
[FileType.CELLS_JSON]: expandCellsJson,
|
|
147
|
+
[FileType.MOLECULES_JSON]: expandMoleculesJson,
|
|
148
|
+
};
|
|
@@ -0,0 +1,139 @@
|
|
|
1
|
+
import { FileType, FILE_TYPE_DATA_TYPE_MAPPING } from '@vitessce/constants-internal';
|
|
2
|
+
import { JOINT_FILE_TYPES, expandAnndataZarr, } from './joint-file-types';
|
|
3
|
+
describe('src/app/joint-file-types.js', () => {
|
|
4
|
+
describe('FileType-to-DataType mappings', () => {
|
|
5
|
+
it('every file type is mapped to either a data type or a joint file type expansion function', () => {
|
|
6
|
+
const fileTypes = Object.values(FileType).sort();
|
|
7
|
+
const mappedFileTypes = [
|
|
8
|
+
...Object.keys(FILE_TYPE_DATA_TYPE_MAPPING),
|
|
9
|
+
...Object.keys(JOINT_FILE_TYPES),
|
|
10
|
+
].sort();
|
|
11
|
+
expect(fileTypes.length).toEqual(mappedFileTypes.length);
|
|
12
|
+
expect(fileTypes).toEqual(mappedFileTypes);
|
|
13
|
+
});
|
|
14
|
+
});
|
|
15
|
+
describe('expandAnndataZarr', () => {
|
|
16
|
+
it('fails to expand when there are no options', () => {
|
|
17
|
+
expect(() => expandAnndataZarr({
|
|
18
|
+
fileType: 'anndata.zarr',
|
|
19
|
+
url: 'http://localhost:8000/anndata.zarr',
|
|
20
|
+
})).toThrow();
|
|
21
|
+
});
|
|
22
|
+
it('expands when there is an obsEmbedding object', () => {
|
|
23
|
+
expect(expandAnndataZarr({
|
|
24
|
+
fileType: 'anndata.zarr',
|
|
25
|
+
url: 'http://localhost:8000/anndata.zarr',
|
|
26
|
+
options: {
|
|
27
|
+
obsLabels: {
|
|
28
|
+
path: 'obs/spot_name',
|
|
29
|
+
},
|
|
30
|
+
featureLabels: {
|
|
31
|
+
path: 'var/gene_symbol',
|
|
32
|
+
},
|
|
33
|
+
obsEmbedding: {
|
|
34
|
+
path: 'obsm/pca',
|
|
35
|
+
dims: [2, 4],
|
|
36
|
+
},
|
|
37
|
+
},
|
|
38
|
+
coordinationValues: {
|
|
39
|
+
obsType: 'spot',
|
|
40
|
+
featureType: 'transcript',
|
|
41
|
+
obsLabelsType: 'spotName',
|
|
42
|
+
featureLabelsType: 'geneSymbol',
|
|
43
|
+
embeddingType: 'PCA',
|
|
44
|
+
},
|
|
45
|
+
})).toEqual([
|
|
46
|
+
{
|
|
47
|
+
fileType: 'obsEmbedding.anndata.zarr',
|
|
48
|
+
url: 'http://localhost:8000/anndata.zarr',
|
|
49
|
+
options: {
|
|
50
|
+
path: 'obsm/pca',
|
|
51
|
+
dims: [2, 4],
|
|
52
|
+
},
|
|
53
|
+
coordinationValues: {
|
|
54
|
+
obsType: 'spot',
|
|
55
|
+
embeddingType: 'PCA',
|
|
56
|
+
},
|
|
57
|
+
},
|
|
58
|
+
{
|
|
59
|
+
fileType: 'obsLabels.anndata.zarr',
|
|
60
|
+
url: 'http://localhost:8000/anndata.zarr',
|
|
61
|
+
options: {
|
|
62
|
+
path: 'obs/spot_name',
|
|
63
|
+
},
|
|
64
|
+
coordinationValues: {
|
|
65
|
+
obsType: 'spot',
|
|
66
|
+
obsLabelsType: 'spotName',
|
|
67
|
+
},
|
|
68
|
+
},
|
|
69
|
+
{
|
|
70
|
+
fileType: 'featureLabels.anndata.zarr',
|
|
71
|
+
url: 'http://localhost:8000/anndata.zarr',
|
|
72
|
+
options: {
|
|
73
|
+
path: 'var/gene_symbol',
|
|
74
|
+
},
|
|
75
|
+
coordinationValues: {
|
|
76
|
+
featureType: 'transcript',
|
|
77
|
+
featureLabelsType: 'geneSymbol',
|
|
78
|
+
},
|
|
79
|
+
},
|
|
80
|
+
]);
|
|
81
|
+
});
|
|
82
|
+
it('expands when there is an obsEmbedding array of objects', () => {
|
|
83
|
+
expect(expandAnndataZarr({
|
|
84
|
+
fileType: 'anndata.zarr',
|
|
85
|
+
url: 'http://localhost:8000/anndata.zarr',
|
|
86
|
+
options: {
|
|
87
|
+
obsLocations: {
|
|
88
|
+
path: 'obsm/xy',
|
|
89
|
+
},
|
|
90
|
+
obsEmbedding: [
|
|
91
|
+
{
|
|
92
|
+
path: 'obsm/pca',
|
|
93
|
+
dims: [2, 4],
|
|
94
|
+
embeddingType: 'PCA',
|
|
95
|
+
},
|
|
96
|
+
{
|
|
97
|
+
path: 'obsm/umap',
|
|
98
|
+
embeddingType: 'UMAP',
|
|
99
|
+
},
|
|
100
|
+
],
|
|
101
|
+
},
|
|
102
|
+
})).toEqual([
|
|
103
|
+
{
|
|
104
|
+
fileType: 'obsLocations.anndata.zarr',
|
|
105
|
+
url: 'http://localhost:8000/anndata.zarr',
|
|
106
|
+
options: {
|
|
107
|
+
path: 'obsm/xy',
|
|
108
|
+
},
|
|
109
|
+
coordinationValues: {
|
|
110
|
+
obsType: 'cell',
|
|
111
|
+
},
|
|
112
|
+
},
|
|
113
|
+
{
|
|
114
|
+
fileType: 'obsEmbedding.anndata.zarr',
|
|
115
|
+
url: 'http://localhost:8000/anndata.zarr',
|
|
116
|
+
options: {
|
|
117
|
+
path: 'obsm/pca',
|
|
118
|
+
dims: [2, 4],
|
|
119
|
+
},
|
|
120
|
+
coordinationValues: {
|
|
121
|
+
obsType: 'cell',
|
|
122
|
+
embeddingType: 'PCA',
|
|
123
|
+
},
|
|
124
|
+
},
|
|
125
|
+
{
|
|
126
|
+
fileType: 'obsEmbedding.anndata.zarr',
|
|
127
|
+
url: 'http://localhost:8000/anndata.zarr',
|
|
128
|
+
options: {
|
|
129
|
+
path: 'obsm/umap',
|
|
130
|
+
},
|
|
131
|
+
coordinationValues: {
|
|
132
|
+
obsType: 'cell',
|
|
133
|
+
embeddingType: 'UMAP',
|
|
134
|
+
},
|
|
135
|
+
},
|
|
136
|
+
]);
|
|
137
|
+
});
|
|
138
|
+
});
|
|
139
|
+
});
|
|
@@ -0,0 +1,98 @@
|
|
|
1
|
+
import { getLoaderClassesForPluginFileType, } from './plugins';
|
|
2
|
+
// TODO(monorepo)
|
|
3
|
+
/*
|
|
4
|
+
import {
|
|
5
|
+
AnnDataSource,
|
|
6
|
+
ZarrDataSource,
|
|
7
|
+
JsonSource,
|
|
8
|
+
CsvSource,
|
|
9
|
+
} from './data-sources';
|
|
10
|
+
import JsonLoader from './json-loaders/JsonLoader';
|
|
11
|
+
import ObsSetsJsonLoader from './json-loaders/ObsSetsJson';
|
|
12
|
+
import ObsSegmentationsJsonLoader from './json-loaders/ObsSegmentationsJson';
|
|
13
|
+
import OmeZarrLoader from './OmeZarrLoader';
|
|
14
|
+
import AnnDataLoaders from './anndata-loaders';
|
|
15
|
+
import GenomicProfilesZarrLoader from './GenomicProfilesZarrLoader';
|
|
16
|
+
import CellsJsonAsObsLabelsLoader from './legacy-loaders/CellsJsonAsObsLabels';
|
|
17
|
+
import CellsJsonAsObsEmbeddingLoader from './legacy-loaders/CellsJsonAsObsEmbedding';
|
|
18
|
+
import CellsJsonAsObsSegmentationsLoader from './legacy-loaders/CellsJsonAsObsSegmentations';
|
|
19
|
+
import ClustersJsonAsObsFeatureMatrixLoader from './legacy-loaders/ClustersJsonAsObsFeatureMatrix';
|
|
20
|
+
import GenesJsonAsObsFeatureMatrixLoader from './legacy-loaders/GenesJsonAsObsFeatureMatrix';
|
|
21
|
+
import RasterJsonAsImageLoader from './raster-json-loaders/RasterJsonAsImageLoader';
|
|
22
|
+
import RasterJsonAsObsSegmentationsLoader from './raster-json-loaders/RasterJsonAsObsSegmentationsLoader';
|
|
23
|
+
import MatrixZarrAsObsFeatureMatrixLoader from './matrix-loaders/MatrixZarrAsObsFeatureMatrix';
|
|
24
|
+
import MoleculesJsonAsObsLocationsLoader from './legacy-loaders/MoleculesJsonAsObsLocations';
|
|
25
|
+
import MoleculesJsonAsObsLabelsLoader from './legacy-loaders/MoleculesJsonAsObsLabels';
|
|
26
|
+
import CellsJsonAsObsLocationsLoader from './legacy-loaders/CellsJsonAsObsLocations';
|
|
27
|
+
import ObsEmbeddingCsvLoader from './csv-loaders/ObsEmbeddingCsv';
|
|
28
|
+
import ObsLocationsCsvLoader from './csv-loaders/ObsLocationsCsv';
|
|
29
|
+
import ObsLabelsCsvLoader from './csv-loaders/ObsLabelsCsv';
|
|
30
|
+
import FeatureLabelsCsvLoader from './csv-loaders/FeatureLabelsCsv';
|
|
31
|
+
import ObsFeatureMatrixCsvLoader from './csv-loaders/ObsFeatureMatrixCsv';
|
|
32
|
+
import ObsSetsCsvLoader from './csv-loaders/ObsSetsCsv';
|
|
33
|
+
*/
|
|
34
|
+
export const fileTypeToLoaderAndSource = {
|
|
35
|
+
// TODO(monorepo)
|
|
36
|
+
/*
|
|
37
|
+
[FileType.OBS_EMBEDDING_CSV]: [CsvSource, ObsEmbeddingCsvLoader],
|
|
38
|
+
[FileType.OBS_LOCATIONS_CSV]: [CsvSource, ObsLocationsCsvLoader],
|
|
39
|
+
[FileType.OBS_LABELS_CSV]: [CsvSource, ObsLabelsCsvLoader],
|
|
40
|
+
[FileType.FEATURE_LABELS_CSV]: [CsvSource, FeatureLabelsCsvLoader],
|
|
41
|
+
[FileType.OBS_FEATURE_MATRIX_CSV]: [CsvSource, ObsFeatureMatrixCsvLoader],
|
|
42
|
+
[FileType.OBS_SEGMENTATIONS_JSON]: [JsonSource, ObsSegmentationsJsonLoader],
|
|
43
|
+
[FileType.OBS_SETS_CSV]: [CsvSource, ObsSetsCsvLoader],
|
|
44
|
+
[FileType.OBS_FEATURE_MATRIX_ANNDATA_ZARR]: [
|
|
45
|
+
AnnDataSource, AnnDataLoaders.ObsFeatureMatrixAnndataLoader,
|
|
46
|
+
],
|
|
47
|
+
[FileType.OBS_SETS_ANNDATA_ZARR]: [
|
|
48
|
+
AnnDataSource, AnnDataLoaders.ObsSetsAnndataLoader,
|
|
49
|
+
],
|
|
50
|
+
[FileType.OBS_EMBEDDING_ANNDATA_ZARR]: [
|
|
51
|
+
AnnDataSource, AnnDataLoaders.ObsEmbeddingAnndataLoader,
|
|
52
|
+
],
|
|
53
|
+
[FileType.OBS_LOCATIONS_ANNDATA_ZARR]: [
|
|
54
|
+
AnnDataSource, AnnDataLoaders.ObsLocationsAnndataLoader,
|
|
55
|
+
],
|
|
56
|
+
[FileType.OBS_SEGMENTATIONS_ANNDATA_ZARR]: [
|
|
57
|
+
AnnDataSource, AnnDataLoaders.ObsSegmentationsAnndataLoader,
|
|
58
|
+
],
|
|
59
|
+
[FileType.OBS_LABELS_ANNDATA_ZARR]: [
|
|
60
|
+
AnnDataSource, AnnDataLoaders.ObsLabelsAnndataLoader,
|
|
61
|
+
],
|
|
62
|
+
[FileType.OBS_FEATURE_MATRIX_EXPRESSION_MATRIX_ZARR]: [
|
|
63
|
+
ZarrDataSource, MatrixZarrAsObsFeatureMatrixLoader,
|
|
64
|
+
],
|
|
65
|
+
[FileType.FEATURE_LABELS_ANNDATA_ZARR]: [
|
|
66
|
+
AnnDataSource, AnnDataLoaders.FeatureLabelsAnndataLoader,
|
|
67
|
+
],
|
|
68
|
+
[FileType.IMAGE_OME_ZARR]: [ZarrDataSource, OmeZarrLoader],
|
|
69
|
+
[FileType.IMAGE_RASTER_JSON]: [JsonSource, RasterJsonAsImageLoader],
|
|
70
|
+
[FileType.OBS_SEGMENTATIONS_RASTER_JSON]: [JsonSource, RasterJsonAsObsSegmentationsLoader],
|
|
71
|
+
[FileType.OBS_SETS_JSON]: [JsonSource, ObsSetsJsonLoader],
|
|
72
|
+
[FileType.OBS_SETS_CELL_SETS_JSON]: [JsonSource, ObsSetsJsonLoader],
|
|
73
|
+
[FileType.OBS_FEATURE_MATRIX_CLUSTERS_JSON]: [JsonSource, ClustersJsonAsObsFeatureMatrixLoader],
|
|
74
|
+
[FileType.OBS_FEATURE_MATRIX_GENES_JSON]: [JsonSource, GenesJsonAsObsFeatureMatrixLoader],
|
|
75
|
+
[FileType.OBS_LABELS_CELLS_JSON]: [JsonSource, CellsJsonAsObsLabelsLoader],
|
|
76
|
+
[FileType.OBS_EMBEDDING_CELLS_JSON]: [JsonSource, CellsJsonAsObsEmbeddingLoader],
|
|
77
|
+
[FileType.OBS_LOCATIONS_CELLS_JSON]: [JsonSource, CellsJsonAsObsLocationsLoader],
|
|
78
|
+
[FileType.OBS_SEGMENTATIONS_CELLS_JSON]: [JsonSource, CellsJsonAsObsSegmentationsLoader],
|
|
79
|
+
[FileType.OBS_LOCATIONS_MOLECULES_JSON]: [JsonSource, MoleculesJsonAsObsLocationsLoader],
|
|
80
|
+
[FileType.OBS_LABELS_MOLECULES_JSON]: [JsonSource, MoleculesJsonAsObsLabelsLoader],
|
|
81
|
+
// Old mappings:
|
|
82
|
+
[FileType.NEIGHBORHOODS_JSON]: [JsonSource, JsonLoader],
|
|
83
|
+
[FileType.GENOMIC_PROFILES_ZARR]: [ZarrDataSource, GenomicProfilesZarrLoader],
|
|
84
|
+
*/
|
|
85
|
+
};
|
|
86
|
+
export function getSourceAndLoaderFromFileType(type) {
|
|
87
|
+
if (fileTypeToLoaderAndSource[type]) {
|
|
88
|
+
return fileTypeToLoaderAndSource[type];
|
|
89
|
+
}
|
|
90
|
+
const pluginFileType = getLoaderClassesForPluginFileType(type);
|
|
91
|
+
if (pluginFileType) {
|
|
92
|
+
return pluginFileType;
|
|
93
|
+
}
|
|
94
|
+
// Fallback to JSON.
|
|
95
|
+
// TODO(monorepo)
|
|
96
|
+
// return [JsonSource, JsonLoader];
|
|
97
|
+
return [null, null];
|
|
98
|
+
}
|
package/dist/plugins.js
ADDED
|
@@ -0,0 +1,154 @@
|
|
|
1
|
+
import { fromEntries } from '@vitessce/utils';
|
|
2
|
+
import { FileType, CoordinationType, FILE_TYPE_DATA_TYPE_MAPPING, COMPONENT_COORDINATION_TYPES, DEFAULT_COORDINATION_VALUES, } from '@vitessce/constants-internal';
|
|
3
|
+
import { JOINT_FILE_TYPES } from './joint-file-types';
|
|
4
|
+
const PLUGINS_KEY = '__VITESSCE_PLUGINS__';
|
|
5
|
+
const PLUGIN_VIEW_TYPES_KEY = 'viewTypes';
|
|
6
|
+
const PLUGIN_COORDINATION_TYPES_KEY = 'coordinationTypes';
|
|
7
|
+
const PLUGIN_COORDINATION_TYPES_PER_VIEW_KEY = 'coordinationTypesPerView';
|
|
8
|
+
const PLUGIN_FILE_TYPES_KEY = 'fileTypes';
|
|
9
|
+
const PLUGIN_FILE_TYPE_DATA_TYPE_MAPPING_KEY = 'fileTypeDataTypeMapping';
|
|
10
|
+
const PLUGIN_JOINT_FILE_TYPES_KEY = 'jointFileTypes';
|
|
11
|
+
window[PLUGINS_KEY] = {};
|
|
12
|
+
const PLUGINS = window[PLUGINS_KEY];
|
|
13
|
+
// Reference: https://github.com/higlass/higlass-register/blob/master/src/index.js
|
|
14
|
+
PLUGINS[PLUGIN_VIEW_TYPES_KEY] = PLUGINS[PLUGIN_VIEW_TYPES_KEY] || {};
|
|
15
|
+
PLUGINS[PLUGIN_COORDINATION_TYPES_KEY] = PLUGINS[PLUGIN_COORDINATION_TYPES_KEY] || {};
|
|
16
|
+
PLUGINS[PLUGIN_COORDINATION_TYPES_PER_VIEW_KEY] = (PLUGINS[PLUGIN_COORDINATION_TYPES_PER_VIEW_KEY] || {});
|
|
17
|
+
PLUGINS[PLUGIN_FILE_TYPES_KEY] = PLUGINS[PLUGIN_FILE_TYPES_KEY] || {};
|
|
18
|
+
PLUGINS[PLUGIN_FILE_TYPE_DATA_TYPE_MAPPING_KEY] = (PLUGINS[PLUGIN_FILE_TYPE_DATA_TYPE_MAPPING_KEY] || {});
|
|
19
|
+
PLUGINS[PLUGIN_JOINT_FILE_TYPES_KEY] = PLUGINS[PLUGIN_JOINT_FILE_TYPES_KEY] || {};
|
|
20
|
+
/**
|
|
21
|
+
* Register a new coordination type.
|
|
22
|
+
* @param {string} typeName Name for the new coordination type.
|
|
23
|
+
* @param {*} defaultValue A default value for the coordination type.
|
|
24
|
+
*/
|
|
25
|
+
export function registerPluginCoordinationType(typeName, defaultValue) {
|
|
26
|
+
PLUGINS[PLUGIN_COORDINATION_TYPES_KEY][typeName] = defaultValue;
|
|
27
|
+
}
|
|
28
|
+
/**
|
|
29
|
+
* Register a new view type.
|
|
30
|
+
* @param {string} viewType A name
|
|
31
|
+
* @param {function} viewSubscriberReactComponent A react component.
|
|
32
|
+
* @param {string[]} coordinationTypes A list of coordination types that this view supports.
|
|
33
|
+
*/
|
|
34
|
+
export function registerPluginViewType(viewType, viewSubscriberReactComponent, coordinationTypes) {
|
|
35
|
+
PLUGINS[PLUGIN_VIEW_TYPES_KEY][viewType] = viewSubscriberReactComponent;
|
|
36
|
+
// Register the supported coordination types.
|
|
37
|
+
const pluginTypesPerView = PLUGINS[PLUGIN_COORDINATION_TYPES_PER_VIEW_KEY];
|
|
38
|
+
if (Array.isArray(pluginTypesPerView[viewType])) {
|
|
39
|
+
coordinationTypes.forEach((coordinationType) => {
|
|
40
|
+
if (!pluginTypesPerView[viewType].includes(coordinationType)) {
|
|
41
|
+
pluginTypesPerView[viewType].push(coordinationType);
|
|
42
|
+
}
|
|
43
|
+
});
|
|
44
|
+
}
|
|
45
|
+
else {
|
|
46
|
+
pluginTypesPerView[viewType] = coordinationTypes;
|
|
47
|
+
}
|
|
48
|
+
}
|
|
49
|
+
/**
|
|
50
|
+
* Register a new file type.
|
|
51
|
+
* @param {string} fileTypeName Name for the new file type.
|
|
52
|
+
* @param {string} dataTypeName Name for the data type associated with the file type.
|
|
53
|
+
* @param {class} dataSourceClass Data source class definition.
|
|
54
|
+
* @param {class} dataLoaderClass Data loader class definition.
|
|
55
|
+
*/
|
|
56
|
+
export function registerPluginFileType(
|
|
57
|
+
// eslint-disable-next-line no-unused-vars
|
|
58
|
+
fileTypeName, dataTypeName, dataLoaderClass, dataSourceClass) {
|
|
59
|
+
PLUGINS[PLUGIN_FILE_TYPES_KEY][fileTypeName] = [dataSourceClass, dataLoaderClass];
|
|
60
|
+
PLUGINS[PLUGIN_FILE_TYPE_DATA_TYPE_MAPPING_KEY][fileTypeName] = dataTypeName;
|
|
61
|
+
}
|
|
62
|
+
/**
|
|
63
|
+
* Register a new joint file type.
|
|
64
|
+
* @param {string} fileTypeName Name for the new file type.
|
|
65
|
+
* @param {function} expansionFunction The joint file type expansion function.
|
|
66
|
+
* Should take in a single file definition and return an array of
|
|
67
|
+
* file definitions with valid atomic fileType values.
|
|
68
|
+
*/
|
|
69
|
+
export function registerPluginJointFileType(
|
|
70
|
+
// eslint-disable-next-line no-unused-vars
|
|
71
|
+
fileTypeName, expansionFunction) {
|
|
72
|
+
PLUGINS[PLUGIN_JOINT_FILE_TYPES_KEY][fileTypeName] = expansionFunction;
|
|
73
|
+
}
|
|
74
|
+
// Plugin getter functions.
|
|
75
|
+
export function getPluginViewTypes() {
|
|
76
|
+
return Object.keys(PLUGINS[PLUGIN_VIEW_TYPES_KEY]);
|
|
77
|
+
}
|
|
78
|
+
export function getPluginViewType(viewType) {
|
|
79
|
+
return PLUGINS[PLUGIN_VIEW_TYPES_KEY][viewType];
|
|
80
|
+
}
|
|
81
|
+
export function getPluginCoordinationTypes() {
|
|
82
|
+
return Object.keys(PLUGINS[PLUGIN_COORDINATION_TYPES_KEY]);
|
|
83
|
+
}
|
|
84
|
+
export function getPluginCoordinationTypeDefaults() {
|
|
85
|
+
return PLUGINS[PLUGIN_COORDINATION_TYPES_KEY];
|
|
86
|
+
}
|
|
87
|
+
export function getPluginCoordinationTypesForViewType(viewType) {
|
|
88
|
+
if (Array.isArray(PLUGINS[PLUGIN_COORDINATION_TYPES_PER_VIEW_KEY][viewType])) {
|
|
89
|
+
return PLUGINS[PLUGIN_COORDINATION_TYPES_PER_VIEW_KEY][viewType];
|
|
90
|
+
}
|
|
91
|
+
return [];
|
|
92
|
+
}
|
|
93
|
+
export function getPluginFileTypes() {
|
|
94
|
+
return Object.keys(PLUGINS[PLUGIN_FILE_TYPES_KEY]);
|
|
95
|
+
}
|
|
96
|
+
export function getPluginConvenienceFileTypes() {
|
|
97
|
+
return Object.keys(PLUGINS[PLUGIN_JOINT_FILE_TYPES_KEY]);
|
|
98
|
+
}
|
|
99
|
+
export function getDataTypeForPluginFileType(fileType) {
|
|
100
|
+
return PLUGINS[PLUGIN_FILE_TYPE_DATA_TYPE_MAPPING_KEY][fileType];
|
|
101
|
+
}
|
|
102
|
+
export function getLoaderClassesForPluginFileType(fileType) {
|
|
103
|
+
return PLUGINS[PLUGIN_FILE_TYPES_KEY][fileType];
|
|
104
|
+
}
|
|
105
|
+
export function getExpansionFunctionForPluginConvenienceFileType(fileType) {
|
|
106
|
+
return PLUGINS[PLUGIN_JOINT_FILE_TYPES_KEY][fileType];
|
|
107
|
+
}
|
|
108
|
+
// Getters that depend on plugins.
|
|
109
|
+
export function getFileTypes() {
|
|
110
|
+
return [
|
|
111
|
+
...Object.values(FileType),
|
|
112
|
+
...getPluginFileTypes(),
|
|
113
|
+
];
|
|
114
|
+
}
|
|
115
|
+
export function getCoordinationTypes() {
|
|
116
|
+
return [
|
|
117
|
+
...Object.values(CoordinationType),
|
|
118
|
+
...getPluginCoordinationTypes(),
|
|
119
|
+
];
|
|
120
|
+
}
|
|
121
|
+
// Need to do this in a function since the plugin coordination
|
|
122
|
+
// types are dynamic.
|
|
123
|
+
export function getDefaultCoordinationValues() {
|
|
124
|
+
return {
|
|
125
|
+
...DEFAULT_COORDINATION_VALUES,
|
|
126
|
+
...getPluginCoordinationTypeDefaults(),
|
|
127
|
+
};
|
|
128
|
+
}
|
|
129
|
+
// Need to do this in a function since the plugin coordination
|
|
130
|
+
// types are dynamic.
|
|
131
|
+
export function getComponentCoordinationTypes() {
|
|
132
|
+
return {
|
|
133
|
+
...COMPONENT_COORDINATION_TYPES,
|
|
134
|
+
...fromEntries(getPluginViewTypes().map(viewType => ([
|
|
135
|
+
viewType,
|
|
136
|
+
getPluginCoordinationTypesForViewType(viewType),
|
|
137
|
+
]))),
|
|
138
|
+
};
|
|
139
|
+
}
|
|
140
|
+
export function getFileTypeDataTypeMapping() {
|
|
141
|
+
return {
|
|
142
|
+
...FILE_TYPE_DATA_TYPE_MAPPING,
|
|
143
|
+
...fromEntries(getPluginFileTypes().map(fileType => ([
|
|
144
|
+
fileType,
|
|
145
|
+
getDataTypeForPluginFileType(fileType),
|
|
146
|
+
]))),
|
|
147
|
+
};
|
|
148
|
+
}
|
|
149
|
+
export function getJointFileTypes() {
|
|
150
|
+
return {
|
|
151
|
+
...JOINT_FILE_TYPES,
|
|
152
|
+
...PLUGINS[PLUGIN_JOINT_FILE_TYPES_KEY],
|
|
153
|
+
};
|
|
154
|
+
}
|
|
@@ -0,0 +1,76 @@
|
|
|
1
|
+
export const convenienceFileDefsCollapsed = {
|
|
2
|
+
version: '1.0.15',
|
|
3
|
+
name: 'My config name',
|
|
4
|
+
description: 'My config description',
|
|
5
|
+
initStrategy: 'auto',
|
|
6
|
+
datasets: [
|
|
7
|
+
{
|
|
8
|
+
files: [
|
|
9
|
+
{
|
|
10
|
+
fileType: 'anndata.convenience.zarr',
|
|
11
|
+
url: 'http://localhost:8000/my_anndata.zarr',
|
|
12
|
+
options: {
|
|
13
|
+
cells: {
|
|
14
|
+
xy: 'obsm/centroids',
|
|
15
|
+
},
|
|
16
|
+
cellSets: [
|
|
17
|
+
{
|
|
18
|
+
groupName: 'Leiden',
|
|
19
|
+
setName: 'obs/leiden',
|
|
20
|
+
},
|
|
21
|
+
],
|
|
22
|
+
},
|
|
23
|
+
},
|
|
24
|
+
],
|
|
25
|
+
name: 'A',
|
|
26
|
+
uid: 'A',
|
|
27
|
+
},
|
|
28
|
+
],
|
|
29
|
+
layout: [],
|
|
30
|
+
};
|
|
31
|
+
export function pluginExpandAnnDataConvenience(fileDef) {
|
|
32
|
+
return [
|
|
33
|
+
{
|
|
34
|
+
fileType: 'anndata-cells.zarr',
|
|
35
|
+
url: fileDef.url,
|
|
36
|
+
options: fileDef.options.cells,
|
|
37
|
+
},
|
|
38
|
+
{
|
|
39
|
+
fileType: 'anndata-cell-sets.zarr',
|
|
40
|
+
url: fileDef.url,
|
|
41
|
+
options: fileDef.options.cellSets,
|
|
42
|
+
},
|
|
43
|
+
];
|
|
44
|
+
}
|
|
45
|
+
export const convenienceFileDefsExpanded = {
|
|
46
|
+
version: '1.0.15',
|
|
47
|
+
name: 'My config name',
|
|
48
|
+
description: 'My config description',
|
|
49
|
+
initStrategy: 'auto',
|
|
50
|
+
datasets: [
|
|
51
|
+
{
|
|
52
|
+
files: [
|
|
53
|
+
{
|
|
54
|
+
fileType: 'anndata-cells.zarr',
|
|
55
|
+
url: 'http://localhost:8000/my_anndata.zarr',
|
|
56
|
+
options: {
|
|
57
|
+
xy: 'obsm/centroids',
|
|
58
|
+
},
|
|
59
|
+
},
|
|
60
|
+
{
|
|
61
|
+
fileType: 'anndata-cell-sets.zarr',
|
|
62
|
+
url: 'http://localhost:8000/my_anndata.zarr',
|
|
63
|
+
options: [
|
|
64
|
+
{
|
|
65
|
+
groupName: 'Leiden',
|
|
66
|
+
setName: 'obs/leiden',
|
|
67
|
+
},
|
|
68
|
+
],
|
|
69
|
+
},
|
|
70
|
+
],
|
|
71
|
+
name: 'A',
|
|
72
|
+
uid: 'A',
|
|
73
|
+
},
|
|
74
|
+
],
|
|
75
|
+
layout: [],
|
|
76
|
+
};
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
/* eslint-disable camelcase */
|
|
2
|
+
import { registerPluginFileType, registerPluginJointFileType, getFileTypeDataTypeMapping, getJointFileTypes, } from './plugins';
|
|
3
|
+
import { convenienceFileDefsCollapsed, convenienceFileDefsExpanded, pluginExpandAnnDataConvenience, } from './plugins.test.fixtures';
|
|
4
|
+
import { initialize, } from './view-config-utils';
|
|
5
|
+
describe('src/app/plugins.js', () => {
|
|
6
|
+
describe('getFileTypeDataTypeMapping', () => {
|
|
7
|
+
it('returns the correct data type for built-in file types', () => {
|
|
8
|
+
const dataType = getFileTypeDataTypeMapping()['image.raster.json'];
|
|
9
|
+
expect(dataType).toEqual('image');
|
|
10
|
+
});
|
|
11
|
+
it('returns the correct data type for plugin file types', () => {
|
|
12
|
+
registerPluginFileType('plugin-cells.json', 'cells', null, null);
|
|
13
|
+
const dataType = getFileTypeDataTypeMapping()['plugin-cells.json'];
|
|
14
|
+
expect(dataType).toEqual('cells');
|
|
15
|
+
});
|
|
16
|
+
});
|
|
17
|
+
describe('convenience file types', () => {
|
|
18
|
+
it('registers plugin convenience file types', () => {
|
|
19
|
+
registerPluginJointFileType('anndata.convenience.zarr', pluginExpandAnnDataConvenience);
|
|
20
|
+
const expansionFuncs = getJointFileTypes();
|
|
21
|
+
expect(Object.keys(expansionFuncs).includes('anndata.convenience.zarr')).toBeTruthy();
|
|
22
|
+
expect(typeof expansionFuncs['anndata.convenience.zarr']).toEqual('function');
|
|
23
|
+
});
|
|
24
|
+
it('uses plugin convenience file types in view config initialization', () => {
|
|
25
|
+
registerPluginJointFileType('anndata.convenience.zarr', pluginExpandAnnDataConvenience);
|
|
26
|
+
expect(initialize(convenienceFileDefsCollapsed).datasets)
|
|
27
|
+
.toEqual(convenienceFileDefsExpanded.datasets);
|
|
28
|
+
});
|
|
29
|
+
});
|
|
30
|
+
});
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
import { jsx as _jsx, Fragment as _Fragment, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
+
import React from 'react';
|
|
3
|
+
import yaml from 'js-yaml'; // eslint-disable-line import/no-extraneous-dependencies
|
|
4
|
+
// This should only be used by docz, and should not be part of the app build.
|
|
5
|
+
function abbreviateType(yamlString) {
|
|
6
|
+
return yamlString.replace(/:\s+type: (\w+)/g, ' ($1):');
|
|
7
|
+
}
|
|
8
|
+
function abbreviateRef(yamlString) {
|
|
9
|
+
return yamlString.replace(/:\s+\$ref: '#\/definitions\/(\w+)'/g, ' ($1)');
|
|
10
|
+
}
|
|
11
|
+
function stripAddProps(yamlString) {
|
|
12
|
+
// This should be the default in our schemas, but we don't need it in the docs.
|
|
13
|
+
return yamlString.replace(/\s+additionalProperties: false/g, '');
|
|
14
|
+
}
|
|
15
|
+
function valuesAre(yamlString) {
|
|
16
|
+
return yamlString.replace(/patternProperties:\s+\./g, 'Object values are');
|
|
17
|
+
}
|
|
18
|
+
function hasProperties(yamlString) {
|
|
19
|
+
return yamlString.replace(/\.:\s+properties:/g, 'Each value has these properties:');
|
|
20
|
+
}
|
|
21
|
+
function pretty(title, obj) {
|
|
22
|
+
// This is entirely ad-hoc:
|
|
23
|
+
// It woks well for our schema, but no assertion that it should work for anyone else.
|
|
24
|
+
if (!obj)
|
|
25
|
+
return '';
|
|
26
|
+
return (_jsxs(_Fragment, { children: [_jsx("h3", { children: title }), _jsx("pre", { children: hasProperties(valuesAre(stripAddProps(abbreviateRef(abbreviateType(yaml.safeDump(obj)))))) })] }));
|
|
27
|
+
}
|
|
28
|
+
export default function PrettyJsonSchema(props) {
|
|
29
|
+
const { children } = props;
|
|
30
|
+
const { definitions, patternProperties, properties } = children;
|
|
31
|
+
// We could grab the title as well, but when we output an <h2> it is not anchored;
|
|
32
|
+
// better to put the section headers in MD.
|
|
33
|
+
return (_jsxs("blockquote", { children: [pretty('Definitions', definitions), pretty('Properties', patternProperties), pretty('Properties', properties)] }));
|
|
34
|
+
}
|