Skip to content

Commit b84ce11

Browse files
authored
chore: fix ts type issues (#4330)
- Move ContentBlock component to correct lib - add missing type info - prefere usage of generated types for catalogue - update usage of shared types
1 parent b4389a5 commit b84ce11

File tree

9 files changed

+60
-54
lines changed

9 files changed

+60
-54
lines changed

apps/tailwind-components/components/content/ContentBlockData.vue renamed to apps/nuxt3-ssr/components/content/ContentBlockData.vue

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,10 @@
11
<script setup lang="ts">
2+
import type { ICollectionEvents } from "~/interfaces/catalogue";
3+
24
const { collectionEvents } = defineProps<{
35
title: string;
46
description?: string;
5-
collectionEvents?: IResourceCollectionEvent[];
7+
collectionEvents?: ICollectionEvents[];
68
}>();
79
810
const dataCategories = collectionEvents

apps/nuxt3-ssr/composables/fetchMetadata.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import { StorageSerializers, useSessionStorage } from "@vueuse/core";
22

33
import metadataGql from "~~/gql/metadata";
4-
import { type ISchemaMetaData } from "metadata-utils";
4+
import type { ISchemaMetaData } from "../../metadata-utils/src/types";
55

66
const query = moduleToString(metadataGql);
77

apps/nuxt3-ssr/interfaces/types.ts

Lines changed: 2 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ import type {
33
IFile,
44
INode,
55
} from "../../tailwind-components/types/types";
6-
import type { ISubpopulations } from "./catalogue";
6+
import type { ICollectionEvents, ISubpopulations } from "./catalogue";
77
export interface IResource {
88
id: string;
99
pid: string;
@@ -65,7 +65,7 @@ export interface IResource {
6565
}[];
6666
inclusionCriteria?: IOntologyNode[];
6767
otherInclusionCriteria?: string;
68-
collectionEvents: ICollectionEvent[];
68+
collectionEvents: ICollectionEvents[];
6969
collectionEvents_agg: { count: number };
7070
peopleInvolved: IContributor[];
7171
networks: INetwork[];
@@ -181,23 +181,6 @@ export interface IUrlObject {
181181
url: string;
182182
}
183183

184-
export interface ICollectionEvent {
185-
name: string;
186-
description: string;
187-
startYear: INameObject;
188-
endYear: number;
189-
numberOfParticipants: number;
190-
ageGroups: INameObject[];
191-
definition: string;
192-
dataCategories: ICollectionEventCategory[];
193-
sampleCategories: ICollectionEventCategory[];
194-
areasOfInformation: ICollectionEventCategory[];
195-
standardizedTools: ICollectionEventCategory[];
196-
standardizedToolsOther: string;
197-
subpopulations: INameObject[];
198-
coreVariables: string[];
199-
}
200-
201184
export interface ICollectionEventCategory {
202185
name: string;
203186
parent?: INameObject;

apps/nuxt3-ssr/pages/[schema]/ssr-catalogue/index.vue

Lines changed: 36 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ useHead({ title: "Health Data and Samples Catalogue" });
55
//add redirect middleware for cohortOnly to skip this page
66
definePageMeta({
77
middleware: [
8-
function (to, from) {
8+
function (to) {
99
const cohortOnly =
1010
to.query["cohort-only"] === "true" ||
1111
useRuntimeConfig().public.cohortOnly;
@@ -43,13 +43,42 @@ const query = computed(() => {
4343
`;
4444
});
4545
46+
interface Catalogue {
47+
network: {
48+
id: string;
49+
name: string;
50+
acronym: string;
51+
description: string;
52+
logo: {
53+
id: string;
54+
size: number;
55+
extension: string;
56+
url: string;
57+
};
58+
};
59+
type: {
60+
name: string;
61+
};
62+
}
63+
64+
interface Catalogues_agg {
65+
count: number;
66+
}
67+
68+
interface Resp<T, U> {
69+
data: Record<string, T[]>;
70+
data_agg: Record<string, U>;
71+
}
72+
4673
let graphqlURL = computed(() => `/${route.params.schema}/graphql`);
47-
const { data, pending, error, refresh } = await useFetch(graphqlURL.value, {
48-
key: "catalogues",
49-
method: "POST",
50-
body: { query },
51-
});
52-
let activeName = ref("compact");
74+
const { data } = await useFetch<Resp<Catalogue, Catalogues_agg>>(
75+
graphqlURL.value,
76+
{
77+
key: "catalogues",
78+
method: "POST",
79+
body: { query },
80+
}
81+
);
5382
5483
const thematicCatalogues = computed(() => {
5584
let result = data?.value?.data?.Catalogues

apps/tailwind-components/pages/table/EMX2.story.vue

Lines changed: 1 addition & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,5 @@
11
<script setup lang="ts">
2-
import type { ITableSettings } from "~/types/types";
3-
4-
type Resp<T> = {
5-
data: Record<string, T[]>;
6-
};
7-
8-
interface Schema {
9-
id: string;
10-
label: string;
11-
description: string;
12-
}
2+
import type { ITableSettings, Resp, Schema } from "~/types/types";
133
144
const tableSettings = ref<ITableSettings>({
155
page: 1,

apps/tailwind-components/types/types.ts

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,14 @@
11
import type { IColumn } from "../../metadata-utils/dist";
2+
3+
export type Resp<T> = {
4+
data: Record<string, T[]>;
5+
};
6+
7+
export interface Schema {
8+
id: string;
9+
label: string;
10+
description: string;
11+
}
212
export interface INode {
313
name: string;
414
description?: string;

apps/ui/layouts/default.vue

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -11,16 +11,18 @@ const faviconHref = config.public.emx2Theme
1111
useHead({
1212
htmlAttrs: {
1313
"data-theme":
14-
(route.query.theme as string) || config.public.emx2Theme || "",
14+
(route.query.theme as string) ||
15+
(config.public.emx2Theme as string) ||
16+
"",
1517
},
1618
link: [{ rel: "icon", href: faviconHref }],
17-
titleTemplate: (titleChunk) => {
19+
titleTemplate: (titleChunk: string | undefined): string | null => {
1820
if (titleChunk && config.public.siteTitle) {
1921
return `${titleChunk} | ${config.public.siteTitle}`;
2022
} else if (titleChunk) {
2123
return titleChunk;
2224
} else if (config.public.siteTitle) {
23-
return config.public.siteTitle;
25+
return config.public.siteTitle as string;
2426
} else {
2527
return "Emx2";
2628
}

apps/ui/pages/[schema]/analytics.vue

Lines changed: 1 addition & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -9,15 +9,7 @@ interface Trigger {
99
cssSelector: string;
1010
}
1111
12-
interface Resp<T> {
13-
data: T[];
14-
error: string;
15-
status: number;
16-
}
17-
18-
const { data, error, status, refresh } = await useFetch<Trigger[]>(
19-
`/${schema}/api/trigger`
20-
);
12+
const { data, refresh } = await useFetch<Trigger[]>(`/${schema}/api/trigger`);
2113
2214
const triggers = computed(() => data?.value?.toReversed());
2315

apps/ui/pages/index.vue

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,5 @@
11
<script setup lang="ts">
2-
type Resp<T> = {
3-
data: Record<string, T[]>;
4-
};
2+
import type { Resp } from "../../tailwind-components/types/types";
53
64
interface Schema {
75
id: string;

0 commit comments

Comments
 (0)