@genspectrum/dashboard-components 1.2.0 → 1.3.1

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.
Files changed (33) hide show
  1. package/README.md +9 -0
  2. package/custom-elements.json +20 -1
  3. package/dist/assets/mutationOverTimeWorker-CQxrFo53.js.map +1 -0
  4. package/dist/components.d.ts +34 -28
  5. package/dist/components.js +48 -16
  6. package/dist/components.js.map +1 -1
  7. package/dist/util.d.ts +28 -28
  8. package/package.json +1 -1
  9. package/src/lapisApi/lapisApi.ts +29 -0
  10. package/src/lapisApi/lapisTypes.ts +35 -1
  11. package/src/preact/mutationsOverTime/__mockData__/aminoAcidMutationsByDay.ts +1 -0
  12. package/src/preact/mutationsOverTime/__mockData__/byWeek.ts +1 -0
  13. package/src/preact/mutationsOverTime/__mockData__/defaultMockData.ts +1 -0
  14. package/src/preact/mutationsOverTime/__mockData__/noDataWhenNoMutationsAreInFilter.ts +1 -0
  15. package/src/preact/mutationsOverTime/__mockData__/noDataWhenThereAreNoDatesInFilter.ts +1 -0
  16. package/src/preact/mutationsOverTime/__mockData__/showsMessageWhenTooManyMutations.ts +1 -0
  17. package/src/preact/mutationsOverTime/__mockData__/withDisplayMutations.ts +352 -0
  18. package/src/preact/mutationsOverTime/getFilteredMutationsOverTime.spec.ts +0 -24
  19. package/src/preact/mutationsOverTime/getFilteredMutationsOverTimeData.ts +0 -8
  20. package/src/preact/mutationsOverTime/mutationOverTimeWorker.mock.ts +2 -0
  21. package/src/preact/mutationsOverTime/mutations-over-time.stories.tsx +2 -0
  22. package/src/preact/mutationsOverTime/mutations-over-time.tsx +11 -6
  23. package/src/query/queryMutationsOverTime.spec.ts +98 -0
  24. package/src/query/queryMutationsOverTime.ts +172 -28
  25. package/src/query/queryMutationsOverTimeNewEndpoint.spec.ts +1057 -0
  26. package/src/web-components/visualization/gs-mutations-over-time.spec-d.ts +3 -0
  27. package/src/web-components/visualization/gs-mutations-over-time.stories.ts +3 -0
  28. package/src/web-components/visualization/gs-mutations-over-time.tsx +9 -0
  29. package/standalone-bundle/assets/mutationOverTimeWorker-CDACUs6w.js.map +1 -0
  30. package/standalone-bundle/dashboard-components.js +3628 -3594
  31. package/standalone-bundle/dashboard-components.js.map +1 -1
  32. package/dist/assets/mutationOverTimeWorker-DpW4YOGl.js.map +0 -1
  33. package/standalone-bundle/assets/mutationOverTimeWorker-CZVvQBze.js.map +0 -1
package/dist/util.d.ts CHANGED
@@ -917,7 +917,7 @@ declare global {
917
917
 
918
918
  declare global {
919
919
  interface HTMLElementTagNameMap {
920
- 'gs-wastewater-mutations-over-time': WastewaterMutationsOverTimeComponent;
920
+ 'gs-genome-data-viewer': GenomeDataViewerComponent;
921
921
  }
922
922
  }
923
923
 
@@ -925,7 +925,7 @@ declare global {
925
925
  declare global {
926
926
  namespace JSX {
927
927
  interface IntrinsicElements {
928
- 'gs-wastewater-mutations-over-time': DetailedHTMLProps<HTMLAttributes<HTMLElement>, HTMLElement>;
928
+ 'gs-genome-data-viewer': DetailedHTMLProps<HTMLAttributes<HTMLElement>, HTMLElement>;
929
929
  }
930
930
  }
931
931
  }
@@ -933,7 +933,7 @@ declare global {
933
933
 
934
934
  declare global {
935
935
  interface HTMLElementTagNameMap {
936
- 'gs-genome-data-viewer': GenomeDataViewerComponent;
936
+ 'gs-mutation-comparison-component': MutationComparisonComponent;
937
937
  }
938
938
  }
939
939
 
@@ -941,7 +941,7 @@ declare global {
941
941
  declare global {
942
942
  namespace JSX {
943
943
  interface IntrinsicElements {
944
- 'gs-genome-data-viewer': DetailedHTMLProps<HTMLAttributes<HTMLElement>, HTMLElement>;
944
+ 'gs-mutation-comparison-component': DetailedHTMLProps<HTMLAttributes<HTMLElement>, HTMLElement>;
945
945
  }
946
946
  }
947
947
  }
@@ -965,7 +965,7 @@ declare global {
965
965
 
966
966
  declare global {
967
967
  interface HTMLElementTagNameMap {
968
- 'gs-relative-growth-advantage': RelativeGrowthAdvantageComponent;
968
+ 'gs-prevalence-over-time': PrevalenceOverTimeComponent;
969
969
  }
970
970
  }
971
971
 
@@ -973,7 +973,7 @@ declare global {
973
973
  declare global {
974
974
  namespace JSX {
975
975
  interface IntrinsicElements {
976
- 'gs-relative-growth-advantage': DetailedHTMLProps<HTMLAttributes<HTMLElement>, HTMLElement>;
976
+ 'gs-prevalence-over-time': DetailedHTMLProps<HTMLAttributes<HTMLElement>, HTMLElement>;
977
977
  }
978
978
  }
979
979
  }
@@ -981,7 +981,7 @@ declare global {
981
981
 
982
982
  declare global {
983
983
  interface HTMLElementTagNameMap {
984
- 'gs-mutation-comparison-component': MutationComparisonComponent;
984
+ 'gs-relative-growth-advantage': RelativeGrowthAdvantageComponent;
985
985
  }
986
986
  }
987
987
 
@@ -989,7 +989,7 @@ declare global {
989
989
  declare global {
990
990
  namespace JSX {
991
991
  interface IntrinsicElements {
992
- 'gs-mutation-comparison-component': DetailedHTMLProps<HTMLAttributes<HTMLElement>, HTMLElement>;
992
+ 'gs-relative-growth-advantage': DetailedHTMLProps<HTMLAttributes<HTMLElement>, HTMLElement>;
993
993
  }
994
994
  }
995
995
  }
@@ -1013,7 +1013,7 @@ declare global {
1013
1013
 
1014
1014
  declare global {
1015
1015
  interface HTMLElementTagNameMap {
1016
- 'gs-prevalence-over-time': PrevalenceOverTimeComponent;
1016
+ 'gs-number-sequences-over-time': NumberSequencesOverTimeComponent;
1017
1017
  }
1018
1018
  }
1019
1019
 
@@ -1021,7 +1021,7 @@ declare global {
1021
1021
  declare global {
1022
1022
  namespace JSX {
1023
1023
  interface IntrinsicElements {
1024
- 'gs-prevalence-over-time': DetailedHTMLProps<HTMLAttributes<HTMLElement>, HTMLElement>;
1024
+ 'gs-number-sequences-over-time': DetailedHTMLProps<HTMLAttributes<HTMLElement>, HTMLElement>;
1025
1025
  }
1026
1026
  }
1027
1027
  }
@@ -1029,7 +1029,7 @@ declare global {
1029
1029
 
1030
1030
  declare global {
1031
1031
  interface HTMLElementTagNameMap {
1032
- 'gs-number-sequences-over-time': NumberSequencesOverTimeComponent;
1032
+ 'gs-mutations-over-time': MutationsOverTimeComponent;
1033
1033
  }
1034
1034
  }
1035
1035
 
@@ -1037,7 +1037,7 @@ declare global {
1037
1037
  declare global {
1038
1038
  namespace JSX {
1039
1039
  interface IntrinsicElements {
1040
- 'gs-number-sequences-over-time': DetailedHTMLProps<HTMLAttributes<HTMLElement>, HTMLElement>;
1040
+ 'gs-mutations-over-time': DetailedHTMLProps<HTMLAttributes<HTMLElement>, HTMLElement>;
1041
1041
  }
1042
1042
  }
1043
1043
  }
@@ -1045,7 +1045,7 @@ declare global {
1045
1045
 
1046
1046
  declare global {
1047
1047
  interface HTMLElementTagNameMap {
1048
- 'gs-mutations-over-time': MutationsOverTimeComponent;
1048
+ 'gs-statistics': StatisticsComponent;
1049
1049
  }
1050
1050
  }
1051
1051
 
@@ -1053,7 +1053,7 @@ declare global {
1053
1053
  declare global {
1054
1054
  namespace JSX {
1055
1055
  interface IntrinsicElements {
1056
- 'gs-mutations-over-time': DetailedHTMLProps<HTMLAttributes<HTMLElement>, HTMLElement>;
1056
+ 'gs-statistics': DetailedHTMLProps<HTMLAttributes<HTMLElement>, HTMLElement>;
1057
1057
  }
1058
1058
  }
1059
1059
  }
@@ -1077,7 +1077,11 @@ declare global {
1077
1077
 
1078
1078
  declare global {
1079
1079
  interface HTMLElementTagNameMap {
1080
- 'gs-statistics': StatisticsComponent;
1080
+ 'gs-date-range-filter': DateRangeFilterComponent;
1081
+ }
1082
+ interface HTMLElementEventMap {
1083
+ [gsEventNames.dateRangeFilterChanged]: CustomEvent<Record<string, string>>;
1084
+ [gsEventNames.dateRangeOptionChanged]: DateRangeOptionChangedEvent;
1081
1085
  }
1082
1086
  }
1083
1087
 
@@ -1085,7 +1089,7 @@ declare global {
1085
1089
  declare global {
1086
1090
  namespace JSX {
1087
1091
  interface IntrinsicElements {
1088
- 'gs-statistics': DetailedHTMLProps<HTMLAttributes<HTMLElement>, HTMLElement>;
1092
+ 'gs-date-range-filter': DetailedHTMLProps<HTMLAttributes<HTMLElement>, HTMLElement>;
1089
1093
  }
1090
1094
  }
1091
1095
  }
@@ -1093,11 +1097,7 @@ declare global {
1093
1097
 
1094
1098
  declare global {
1095
1099
  interface HTMLElementTagNameMap {
1096
- 'gs-date-range-filter': DateRangeFilterComponent;
1097
- }
1098
- interface HTMLElementEventMap {
1099
- [gsEventNames.dateRangeFilterChanged]: CustomEvent<Record<string, string>>;
1100
- [gsEventNames.dateRangeOptionChanged]: DateRangeOptionChangedEvent;
1100
+ 'gs-wastewater-mutations-over-time': WastewaterMutationsOverTimeComponent;
1101
1101
  }
1102
1102
  }
1103
1103
 
@@ -1105,7 +1105,7 @@ declare global {
1105
1105
  declare global {
1106
1106
  namespace JSX {
1107
1107
  interface IntrinsicElements {
1108
- 'gs-date-range-filter': DetailedHTMLProps<HTMLAttributes<HTMLElement>, HTMLElement>;
1108
+ 'gs-wastewater-mutations-over-time': DetailedHTMLProps<HTMLAttributes<HTMLElement>, HTMLElement>;
1109
1109
  }
1110
1110
  }
1111
1111
  }
@@ -1132,10 +1132,10 @@ declare global {
1132
1132
 
1133
1133
  declare global {
1134
1134
  interface HTMLElementTagNameMap {
1135
- 'gs-text-filter': TextFilterComponent;
1135
+ 'gs-mutation-filter': MutationFilterComponent;
1136
1136
  }
1137
1137
  interface HTMLElementEventMap {
1138
- [gsEventNames.textFilterChanged]: TextFilterChangedEvent;
1138
+ [gsEventNames.mutationFilterChanged]: CustomEvent<MutationsFilter>;
1139
1139
  }
1140
1140
  }
1141
1141
 
@@ -1143,7 +1143,7 @@ declare global {
1143
1143
  declare global {
1144
1144
  namespace JSX {
1145
1145
  interface IntrinsicElements {
1146
- 'gs-text-filter': DetailedHTMLProps<HTMLAttributes<HTMLElement>, HTMLElement>;
1146
+ 'gs-mutation-filter': DetailedHTMLProps<HTMLAttributes<HTMLElement>, HTMLElement>;
1147
1147
  }
1148
1148
  }
1149
1149
  }
@@ -1151,10 +1151,10 @@ declare global {
1151
1151
 
1152
1152
  declare global {
1153
1153
  interface HTMLElementTagNameMap {
1154
- 'gs-mutation-filter': MutationFilterComponent;
1154
+ 'gs-text-filter': TextFilterComponent;
1155
1155
  }
1156
1156
  interface HTMLElementEventMap {
1157
- [gsEventNames.mutationFilterChanged]: CustomEvent<MutationsFilter>;
1157
+ [gsEventNames.textFilterChanged]: TextFilterChangedEvent;
1158
1158
  }
1159
1159
  }
1160
1160
 
@@ -1162,7 +1162,7 @@ declare global {
1162
1162
  declare global {
1163
1163
  namespace JSX {
1164
1164
  interface IntrinsicElements {
1165
- 'gs-mutation-filter': DetailedHTMLProps<HTMLAttributes<HTMLElement>, HTMLElement>;
1165
+ 'gs-text-filter': DetailedHTMLProps<HTMLAttributes<HTMLElement>, HTMLElement>;
1166
1166
  }
1167
1167
  }
1168
1168
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@genspectrum/dashboard-components",
3
- "version": "1.2.0",
3
+ "version": "1.3.1",
4
4
  "description": "GenSpectrum web components for building dashboards",
5
5
  "type": "module",
6
6
  "license": "AGPL-3.0-only",
@@ -9,6 +9,8 @@ import {
9
9
  mutationsResponse,
10
10
  problemDetail,
11
11
  type ProblemDetail,
12
+ type MutationsOverTimeRequest,
13
+ mutationsOverTimeResponse,
12
14
  } from './lapisTypes';
13
15
  import { type SequenceType } from '../types';
14
16
  import { lineageDefinitionResponseSchema } from './LineageDefinition';
@@ -112,6 +114,28 @@ export async function fetchSubstitutionsOrDeletions(
112
114
  return mutationsResponse.parse(await response.json());
113
115
  }
114
116
 
117
+ export async function fetchMutationsOverTime(
118
+ lapisUrl: string,
119
+ body: MutationsOverTimeRequest,
120
+ sequenceType: SequenceType,
121
+ signal?: AbortSignal,
122
+ ) {
123
+ const response = await callLapis(
124
+ mutationsOverTimeEndpoint(lapisUrl, sequenceType),
125
+ {
126
+ method: 'POST',
127
+ headers: {
128
+ 'Content-Type': 'application/json',
129
+ },
130
+ body: JSON.stringify(body),
131
+ signal,
132
+ },
133
+ `${sequenceType} mutations over time`,
134
+ );
135
+
136
+ return mutationsOverTimeResponse.parse(await response.json());
137
+ }
138
+
115
139
  export async function fetchReferenceGenome(lapisUrl: string, signal?: AbortSignal) {
116
140
  const response = await callLapis(
117
141
  referenceGenomeEndpoint(lapisUrl),
@@ -215,6 +239,11 @@ export const substitutionsOrDeletionsEndpoint = (lapisUrl: string, sequenceType:
215
239
  ? `${lapisUrl}/sample/aminoAcidMutations`
216
240
  : `${lapisUrl}/sample/nucleotideMutations`;
217
241
  };
242
+ export const mutationsOverTimeEndpoint = (lapisUrl: string, sequenceType: SequenceType) => {
243
+ return sequenceType === 'amino acid'
244
+ ? `${lapisUrl}/component/aminoAcidMutationsOverTime`
245
+ : `${lapisUrl}/component/nucleotideMutationsOverTime`;
246
+ };
218
247
  export const referenceGenomeEndpoint = (lapisUrl: string) => `${lapisUrl}/sample/referenceGenome`;
219
248
  export const lineageDefinitionEndpoint = (lapisUrl: string, lapisField: string) =>
220
249
  `${lapisUrl}/sample/lineageDefinition/${lapisField}`;
@@ -7,6 +7,13 @@ export const orderBy = z.object({
7
7
  type: orderByType,
8
8
  });
9
9
 
10
+ const filterValue = z.union([z.string(), z.number(), z.boolean(), z.null(), z.undefined(), z.array(z.string())]);
11
+
12
+ const dateRange = z.object({
13
+ dateFrom: z.string(),
14
+ dateTo: z.string(),
15
+ });
16
+
10
17
  export const lapisBaseRequest = z
11
18
  .object({
12
19
  limit: z.number().optional(),
@@ -14,7 +21,7 @@ export const lapisBaseRequest = z
14
21
  fields: z.array(z.string()).optional(),
15
22
  orderBy: z.array(orderBy).optional(),
16
23
  })
17
- .catchall(z.union([z.boolean(), z.undefined(), z.string(), z.number(), z.null(), z.array(z.string())]));
24
+ .catchall(filterValue);
18
25
  export type LapisBaseRequest = z.infer<typeof lapisBaseRequest>;
19
26
 
20
27
  export const mutationsRequest = lapisBaseRequest.extend({ minProportion: z.number().optional() });
@@ -32,6 +39,33 @@ const mutationProportionCount = z.object({
32
39
  export const mutationsResponse = makeLapisResponse(z.array(mutationProportionCount));
33
40
  export type MutationsResponse = z.infer<typeof mutationsResponse>;
34
41
 
42
+ export const mutationsOverTimeRequest = z.object({
43
+ filters: z.record(filterValue),
44
+ downloadAsFile: z.boolean().optional(),
45
+ downloadFileBasename: z.string().optional(),
46
+ compression: z.enum(['gzip', 'none']).optional(),
47
+ includeMutations: z.array(z.string()).optional(),
48
+ dateRanges: z.array(dateRange).optional(),
49
+ dateField: z.string().optional(),
50
+ });
51
+ export type MutationsOverTimeRequest = z.infer<typeof mutationsOverTimeRequest>;
52
+
53
+ export const mutationsOverTimeResponse = makeLapisResponse(
54
+ z.object({
55
+ mutations: z.array(z.string()),
56
+ dateRanges: z.array(dateRange),
57
+ data: z.array(
58
+ z.array(
59
+ z.object({
60
+ count: z.number(),
61
+ coverage: z.number(),
62
+ }),
63
+ ),
64
+ ),
65
+ }),
66
+ );
67
+ export type MutationsOverTimeResponse = z.infer<typeof mutationsOverTimeResponse>;
68
+
35
69
  const insertionCount = z.object({
36
70
  insertion: z.string(),
37
71
  count: z.number(),
@@ -11,6 +11,7 @@ export const aminoAcidMutationsByDay: MutationOverTimeMockData = {
11
11
  granularity: 'day',
12
12
  lapisDateField: 'date',
13
13
  lapis: 'https://lapis.cov-spectrum.org/open/v2',
14
+ useNewEndpoint: false,
14
15
  },
15
16
  response: {
16
17
  overallMutationData: [
@@ -11,6 +11,7 @@ export const byWeek: MutationOverTimeMockData = {
11
11
  granularity: 'week',
12
12
  lapisDateField: 'date',
13
13
  lapis: 'https://lapis.cov-spectrum.org/open/v2',
14
+ useNewEndpoint: false,
14
15
  },
15
16
  response: {
16
17
  overallMutationData: [
@@ -11,6 +11,7 @@ export const defaultMockData: MutationOverTimeMockData = {
11
11
  granularity: 'month',
12
12
  lapisDateField: 'date',
13
13
  lapis: 'https://lapis.cov-spectrum.org/open/v2',
14
+ useNewEndpoint: false,
14
15
  },
15
16
  response: {
16
17
  overallMutationData: [
@@ -10,6 +10,7 @@ export const noDataWhenNoMutationsAreInFilter: MutationOverTimeMockData = {
10
10
  granularity: 'year',
11
11
  lapisDateField: 'date',
12
12
  lapis: 'https://lapis.cov-spectrum.org/open/v2',
13
+ useNewEndpoint: false,
13
14
  },
14
15
  response: {
15
16
  overallMutationData: [],
@@ -10,6 +10,7 @@ export const noDataWhenNoMutationsAreInFilter: MutationOverTimeMockData = {
10
10
  granularity: 'year',
11
11
  lapisDateField: 'date',
12
12
  lapis: 'https://lapis.cov-spectrum.org/open/v2',
13
+ useNewEndpoint: false,
13
14
  },
14
15
  response: {
15
16
  overallMutationData: [],
@@ -10,6 +10,7 @@ export const showsMessageWhenTooManyMutations: MutationOverTimeMockData = {
10
10
  granularity: 'year',
11
11
  lapisDateField: 'date',
12
12
  lapis: 'https://lapis.cov-spectrum.org/open/v2',
13
+ useNewEndpoint: false,
13
14
  },
14
15
  response: {
15
16
  overallMutationData: [