@datagouv/components-next 1.0.2-dev.4 → 1.0.2-dev.40

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 (52) hide show
  1. package/dist/Datafair.client-CYO9vwx6.js +30 -0
  2. package/dist/JsonPreview.client-B6aU3vl4.js +78 -0
  3. package/dist/{MapContainer.client-DjjvdKBp.js → MapContainer.client-BZsKgRUh.js} +35 -38
  4. package/dist/{PdfPreview.client-CsvKU0Aq.js → PdfPreview.client-ClkseuKU.js} +694 -700
  5. package/dist/{Pmtiles.client-uqg1fwOl.js → Pmtiles.client-CUaeaV-O.js} +574 -579
  6. package/dist/Swagger.client-FpYXdDuX.js +4 -0
  7. package/dist/XmlPreview.client-BNGHvVnU.js +70 -0
  8. package/dist/components-next.css +3 -3
  9. package/dist/components-next.js +83 -86
  10. package/dist/components.css +1 -1
  11. package/dist/{index-PMeuFwWj.js → index-B0fPq7-b.js} +1 -1
  12. package/dist/{main-ByqZlhiZ.js → main-ifX24DGW.js} +31224 -30474
  13. package/dist/{vue3-xml-viewer.common-DFrGHXJC.js → vue3-xml-viewer.common-Bkgr-tAS.js} +1 -1
  14. package/package.json +10 -8
  15. package/src/components/ActivityList/ActivityList.vue +0 -2
  16. package/src/components/Form/SearchableSelect.vue +2 -1
  17. package/src/components/Pagination.vue +8 -5
  18. package/src/components/ReadMore.vue +1 -1
  19. package/src/components/ResourceAccordion/Datafair.client.vue +4 -10
  20. package/src/components/ResourceAccordion/JsonPreview.client.vue +34 -47
  21. package/src/components/ResourceAccordion/MapContainer.client.vue +7 -11
  22. package/src/components/ResourceAccordion/Metadata.vue +1 -2
  23. package/src/components/ResourceAccordion/PdfPreview.client.vue +28 -32
  24. package/src/components/ResourceAccordion/Pmtiles.client.vue +5 -10
  25. package/src/components/ResourceAccordion/Preview.vue +6 -11
  26. package/src/components/ResourceAccordion/PreviewLoader.vue +1 -2
  27. package/src/components/ResourceAccordion/PreviewUnavailable.vue +22 -0
  28. package/src/components/ResourceAccordion/ResourceAccordion.vue +1 -2
  29. package/src/components/ResourceAccordion/XmlPreview.client.vue +34 -47
  30. package/src/components/ResourceExplorer/ResourceExplorer.vue +21 -10
  31. package/src/components/ResourceExplorer/ResourceExplorerViewer.vue +24 -3
  32. package/src/components/Search/GlobalSearch.vue +29 -4
  33. package/src/composables/useResourceCapabilities.ts +1 -1
  34. package/src/config.ts +2 -0
  35. package/src/functions/datasets.ts +0 -17
  36. package/src/functions/resources.ts +56 -1
  37. package/src/functions/tabularApi.ts +7 -84
  38. package/src/main.ts +2 -22
  39. package/src/types/dataservices.ts +2 -0
  40. package/src/types/organizations.ts +1 -1
  41. package/src/types/reports.ts +3 -0
  42. package/src/types/search.ts +26 -1
  43. package/src/types/users.ts +0 -1
  44. package/dist/Datafair.client-c1cUKkQR.js +0 -35
  45. package/dist/JsonPreview.client-CAs9XTCX.js +0 -87
  46. package/dist/Swagger.client-BGrkka3l.js +0 -4
  47. package/dist/XmlPreview.client-BWbKzLte.js +0 -79
  48. package/src/components/Chart/ChartViewer.vue +0 -152
  49. package/src/components/Chart/ChartViewerWrapper.vue +0 -194
  50. package/src/functions/pagination.ts +0 -9
  51. package/src/types/visualizations.ts +0 -84
  52. /package/assets/illustrations/{_microscope.svg → microscope.svg} +0 -0
@@ -9,46 +9,32 @@
9
9
  >
10
10
  {{ t("Chargement de l'aperçu XML...") }}
11
11
  </div>
12
- <SimpleBanner
13
- v-else-if="fileTooLarge"
14
- type="warning"
15
- class="flex items-center space-x-2"
16
- >
17
- <RiErrorWarningLine class="shrink-0 size-6" />
18
- <span>{{ fileSizeBytes
19
- ? t("Fichier XML trop volumineux pour l'aperçu. Pour consulter le fichier complet, téléchargez-le en cliquant sur le bouton bleu ou depuis l'onglet Téléchargements.")
20
- : t("L'aperçu n'est pas disponible car la taille du fichier est inconnue. Pour consulter le fichier complet, téléchargez-le en cliquant sur le bouton bleu ou depuis l'onglet Téléchargements.")
21
- }}</span>
22
- </SimpleBanner>
23
- <SimpleBanner
24
- v-else-if="error === 'network'"
25
- type="warning"
26
- class="flex items-center space-x-2"
27
- >
28
- <RiErrorWarningLine class="shrink-0 size-6" />
29
- <span>{{ t("Ce fichier XML ne peut pas être prévisualisé, peut-être parce qu'il est hébergé sur un autre site qui ne l'autorise pas. Pour le consulter, téléchargez-le en cliquant sur le bouton bleu ou depuis l'onglet Téléchargements.") }}</span>
30
- </SimpleBanner>
31
- <SimpleBanner
32
- v-else-if="error"
33
- type="warning"
34
- class="flex items-center space-x-2"
35
- >
36
- <RiErrorWarningLine class="shrink-0 size-6" />
37
- <span>{{ t("Erreur lors du chargement de l'aperçu XML.") }}</span>
38
- </SimpleBanner>
12
+ <PreviewUnavailable v-else-if="fileTooLarge">
13
+ {{ fileSizeBytes
14
+ ? t("Le fichier XML est trop volumineux pour être prévisualisé. Téléchargez-le depuis l'onglet Téléchargements.")
15
+ : t("La taille du fichier est inconnue, l'aperçu n'est pas disponible. Téléchargez-le depuis l'onglet Téléchargements.")
16
+ }}
17
+ </PreviewUnavailable>
18
+ <PreviewUnavailable v-else-if="error === 'cors'">
19
+ {{ t("Ce fichier XML ne peut pas être prévisualisé car il est hébergé sur un site distant qui restreint l'accès (CORS). Téléchargez-le depuis l'onglet Téléchargements.") }}
20
+ </PreviewUnavailable>
21
+ <PreviewUnavailable v-else-if="error === 'network'">
22
+ {{ t("Ce fichier est hébergé sur un site externe qui ne permet pas la prévisualisation. Téléchargez-le depuis l'onglet Téléchargements.") }}
23
+ </PreviewUnavailable>
24
+ <PreviewUnavailable v-else-if="error">
25
+ {{ t("L'aperçu de ce fichier n'a pas pu être chargé. Téléchargez-le depuis l'onglet Téléchargements.") }}
26
+ </PreviewUnavailable>
39
27
  </div>
40
28
  </template>
41
29
 
42
30
  <script setup lang="ts">
43
31
  import { computed, defineAsyncComponent, onMounted, ref } from 'vue'
44
- import { RiErrorWarningLine } from '@remixicon/vue'
45
-
46
32
  import { useComponentsConfig } from '../../config'
47
- import SimpleBanner from '../SimpleBanner.vue'
33
+ import PreviewUnavailable from './PreviewUnavailable.vue'
48
34
  import type { Resource } from '../../types/resources'
35
+ import { getResourceFilesize, getResourceCorsStatus } from '../../functions/resources'
49
36
  import { useTranslation } from '../../composables/useTranslation'
50
37
  import '../../types/vue3-xml-viewer.d'
51
- import { getResourceFilesize } from '../../main'
52
38
 
53
39
  const XmlViewer = defineAsyncComponent(() =>
54
40
  import('vue3-xml-viewer').then((module) => {
@@ -70,36 +56,37 @@ const fileTooLarge = ref(false)
70
56
 
71
57
  const fileSizeBytes = computed(() => getResourceFilesize(props.resource))
72
58
 
73
- const shouldLoadXml = computed(() => {
74
- const size = fileSizeBytes.value
75
- if (!size) {
76
- // If we don't know the size, don't risk loading a potentially huge file
77
- return false
78
- }
79
-
80
- // Check if maxXmlPreviewCharSize is configured
81
- if (!config.maxXmlPreviewCharSize) {
82
- // If no limit is set, don't load unknown files
83
- return false
84
- }
59
+ const corsStatus = computed(() => getResourceCorsStatus(props.resource))
85
60
 
61
+ const isSizeAllowed = computed(() => {
62
+ const size = fileSizeBytes.value
86
63
  // Convert maxXmlPreviewCharSize from characters to bytes (rough estimate)
87
64
  // Assuming average 1 byte per character for XML
88
65
  const maxByteSize = config.maxXmlPreviewCharSize
89
66
 
67
+ // If we don't know the size or the max size, don't risk loading a potentially huge file
68
+ if (!size || !maxByteSize) return false
69
+
90
70
  return size <= maxByteSize
91
71
  })
92
72
 
93
73
  const fetchXmlData = async () => {
94
- // Check if file is too large or size is unknown before making the request
95
- if (!shouldLoadXml.value) {
74
+ error.value = null
75
+ fileTooLarge.value = false
76
+
77
+ // Check if file is too large or size is unknown
78
+ if (!isSizeAllowed.value) {
96
79
  fileTooLarge.value = true
97
80
  return
98
81
  }
99
82
 
100
- loading.value = true
101
- error.value = null
83
+ // Check if CORS is allowed
84
+ if (corsStatus.value === 'blocked') {
85
+ error.value = 'cors'
86
+ return
87
+ }
102
88
 
89
+ loading.value = true
103
90
  try {
104
91
  const response = await fetch(props.resource.url)
105
92
  // const response = await fetch('/test-data.xml') // For testing locally without CORS issues
@@ -159,6 +159,22 @@ watch(searchDebounced, () => {
159
159
  }
160
160
  })
161
161
 
162
+ // Separate useFetch for loadMore, initialized at setup time with immediate: false
163
+ // so that it doesn't fetch until execute() is called from the event handler.
164
+ const loadMoreType = ref<ResourceType>('main')
165
+ const loadMorePage = ref(1)
166
+ const loadMoreParams = computed(() => ({
167
+ type: loadMoreType.value,
168
+ page_size: PAGE_SIZE,
169
+ page: loadMorePage.value,
170
+ q: searchDebounced.value || undefined,
171
+ }))
172
+ const { data: loadMoreData, execute: executeLoadMore } = await useFetch<PaginatedArray<Resource>>(url, {
173
+ params: loadMoreParams,
174
+ immediate: false,
175
+ watch: false,
176
+ })
177
+
162
178
  const loadMore = async (type: ResourceType) => {
163
179
  const index = RESOURCE_TYPE.indexOf(type)
164
180
  if (index === -1) return
@@ -166,17 +182,12 @@ const loadMore = async (type: ResourceType) => {
166
182
  const extraRef = extraResourcesByType[index]!
167
183
  pageRef.value++
168
184
 
169
- const { data } = await useFetch<PaginatedArray<Resource>>(url, {
170
- params: {
171
- type,
172
- page_size: PAGE_SIZE,
173
- page: pageRef.value,
174
- q: searchDebounced.value || undefined,
175
- },
176
- })
185
+ loadMoreType.value = type
186
+ loadMorePage.value = pageRef.value
187
+ await executeLoadMore()
177
188
 
178
- if (data.value) {
179
- extraRef.value = [...extraRef.value, ...data.value.data]
189
+ if (loadMoreData.value) {
190
+ extraRef.value = [...extraRef.value, ...loadMoreData.value.data]
180
191
  }
181
192
  }
182
193
 
@@ -17,6 +17,12 @@
17
17
  />
18
18
  </div>
19
19
  <div class="text-gray-medium text-xs flex items-center gap-1">
20
+ <SchemaBadge :resource />
21
+ <RiSubtractLine
22
+ v-if="resource.schema"
23
+ aria-hidden="true"
24
+ class="size-3 fill-gray-medium"
25
+ />
20
26
  <span>{{ t('mis à jour {date}', { date: formatRelativeIfRecentDate(resource.last_modified) }) }}</span>
21
27
  <RiSubtractLine
22
28
  aria-hidden="true"
@@ -133,9 +139,23 @@
133
139
  :url="resource.extras['apidocUrl'] as string"
134
140
  />
135
141
  <Preview
136
- v-else
142
+ v-else-if="hasTabularData"
137
143
  :resource="resource"
138
144
  />
145
+ <PreviewUnavailable v-else>
146
+ <!-- "File too large to download" is the only analysis:error value from hydra for now -->
147
+ <template v-if="resource.extras['analysis:error'] === 'File too large to download'">
148
+ {{ t("Ce fichier est trop volumineux pour être analysé et prévisualisé. Téléchargez-le depuis l'onglet Téléchargements.") }}
149
+ </template>
150
+ <template v-else-if="resource.extras['analysis:parsing:error']">
151
+ {{ t("L'analyse de ce fichier a rencontré une erreur, l'aperçu n'est pas disponible. Téléchargez-le depuis l'onglet Téléchargements.") }}
152
+ <br>
153
+ <span class="text-gray-medium text-xs">{{ resource.extras['analysis:parsing:error'] }}</span>
154
+ </template>
155
+ <template v-else>
156
+ {{ t("Ce fichier ne peut pas être prévisualisé. Téléchargez-le depuis l'onglet Téléchargements.") }}
157
+ </template>
158
+ </PreviewUnavailable>
139
159
  </div>
140
160
  <div v-if="tab.key === 'description'">
141
161
  <MarkdownViewer
@@ -298,6 +318,7 @@
298
318
  <script setup lang="ts">
299
319
  import { computed, defineAsyncComponent } from 'vue'
300
320
  import { RiDownloadLine, RiFileCopyLine, RiFileWarningLine, RiInformationLine, RiSubtractLine } from '@remixicon/vue'
321
+ import PreviewUnavailable from '../ResourceAccordion/PreviewUnavailable.vue'
301
322
  import { toast } from 'vue-sonner'
302
323
  import BrandedButton from '../BrandedButton.vue'
303
324
  import CopyButton from '../CopyButton.vue'
@@ -313,9 +334,9 @@ import Tooltip from '../Tooltip.vue'
313
334
  import Preview from '../ResourceAccordion/Preview.vue'
314
335
  import DataStructure from '../ResourceAccordion/DataStructure.vue'
315
336
  import Metadata from '../ResourceAccordion/Metadata.vue'
337
+ import SchemaBadge from '../ResourceAccordion/SchemaBadge.vue'
316
338
  import { filesize, summarize } from '../../functions/helpers'
317
- import { getResourceFormatIcon } from '../../functions/resources'
318
- import { getResourceExternalUrl, getResourceFilesize } from '../../functions/datasets'
339
+ import { getResourceFormatIcon, getResourceExternalUrl, getResourceFilesize } from '../../functions/resources'
319
340
  import { trackEvent } from '../../functions/matomo'
320
341
  import { useComponentsConfig } from '../../config'
321
342
  import { useFormatDate } from '../../functions/dates'
@@ -263,6 +263,14 @@
263
263
  <OrganizationHorizontalCard :organization="(result as Organization)" />
264
264
  </slot>
265
265
  </template>
266
+ <template v-else-if="currentType === 'topics'">
267
+ <slot
268
+ name="topic"
269
+ :topic="result"
270
+ >
271
+ <TopicCard :topic="(result as TopicV2)" />
272
+ </slot>
273
+ </template>
266
274
  </li>
267
275
  </ul>
268
276
  <Pagination
@@ -271,7 +279,6 @@
271
279
  :page-size
272
280
  :total-results="results.total"
273
281
  class="mt-4"
274
- :link="getLink"
275
282
  @change="changePage"
276
283
  />
277
284
  </div>
@@ -335,19 +342,19 @@
335
342
  <script setup lang="ts">
336
343
  import { computed, watch, useTemplateRef, type Ref } from 'vue'
337
344
  import { useRouteQuery } from '@vueuse/router'
338
- import { RiBuilding2Line, RiCloseCircleLine, RiDatabase2Line, RiLightbulbLine, RiLineChartLine, RiRssLine, RiTerminalLine } from '@remixicon/vue'
345
+ import { RiBookShelfLine, RiBuilding2Line, RiCloseCircleLine, RiDatabase2Line, RiLightbulbLine, RiLineChartLine, RiRssLine, RiTerminalLine } from '@remixicon/vue'
339
346
  import magnifyingGlassSrc from '../../../assets/illustrations/magnifying_glass.svg?url'
340
347
  import { useTranslation } from '../../composables/useTranslation'
341
348
  import { useDebouncedRef } from '../../composables/useDebouncedRef'
342
349
  import { useStableQueryParams } from '../../composables/useStableQueryParams'
343
350
  import { useComponentsConfig } from '../../config'
344
351
  import { useFetch } from '../../functions/api'
345
- import { getLink } from '../../functions/pagination'
346
352
  import type { Dataset } from '../../types/datasets'
347
353
  import type { Dataservice } from '../../types/dataservices'
348
354
  import type { Organization } from '../../types/organizations'
349
355
  import type { Reuse } from '../../types/reuses'
350
- import type { GlobalSearchConfig, SearchType, SortOption, DatasetSearchResponse, DataserviceSearchResponse, ReuseSearchResponse, OrganizationSearchResponse, FacetItem } from '../../types/search'
356
+ import type { TopicV2 } from '../../types/topics'
357
+ import type { GlobalSearchConfig, SearchType, SortOption, DatasetSearchResponse, DataserviceSearchResponse, ReuseSearchResponse, OrganizationSearchResponse, TopicSearchResponse, FacetItem } from '../../types/search'
351
358
  import { getDefaultGlobalSearchConfig } from '../../types/search'
352
359
  import BrandedButton from '../BrandedButton.vue'
353
360
  import LoadingBlock from '../LoadingBlock.vue'
@@ -358,6 +365,7 @@ import DatasetCard from '../DatasetCard.vue'
358
365
  import DataserviceCard from '../DataserviceCard.vue'
359
366
  import OrganizationHorizontalCard from '../OrganizationHorizontalCard.vue'
360
367
  import ReuseHorizontalCard from '../ReuseHorizontalCard.vue'
368
+ import TopicCard from '../TopicCard.vue'
361
369
  import SearchInput from './SearchInput.vue'
362
370
  import Sidemenu from './Sidemenu.vue'
363
371
  import BasicAndAdvancedFilters from './BasicAndAdvancedFilters.vue'
@@ -500,6 +508,7 @@ const datasetsEnabled = computed(() => props.config.some(c => c.class === 'datas
500
508
  const dataservicesEnabled = computed(() => props.config.some(c => c.class === 'dataservices'))
501
509
  const reusesEnabled = computed(() => props.config.some(c => c.class === 'reuses'))
502
510
  const organizationsEnabled = computed(() => props.config.some(c => c.class === 'organizations'))
511
+ const topicsEnabled = computed(() => props.config.some(c => c.class === 'topics'))
503
512
 
504
513
  // Create stable params for each type
505
514
  const stableParamsOptions = {
@@ -526,12 +535,17 @@ const organizationsParams = useStableQueryParams({
526
535
  ...stableParamsOptions,
527
536
  typeConfig: props.config.find(c => c.class === 'organizations'),
528
537
  })
538
+ const topicsParams = useStableQueryParams({
539
+ ...stableParamsOptions,
540
+ typeConfig: props.config.find(c => c.class === 'topics'),
541
+ })
529
542
 
530
543
  // URLs that return null when type is not enabled
531
544
  const datasetsUrl = computed(() => datasetsEnabled.value ? '/api/2/datasets/search/' : null)
532
545
  const dataservicesUrl = computed(() => dataservicesEnabled.value ? '/api/2/dataservices/search/' : null)
533
546
  const reusesUrl = computed(() => reusesEnabled.value ? '/api/2/reuses/search/' : null)
534
547
  const organizationsUrl = computed(() => organizationsEnabled.value ? '/api/2/organizations/search/' : null)
548
+ const topicsUrl = computed(() => topicsEnabled.value ? '/api/2/topics/search/' : null)
535
549
 
536
550
  // Reset page on filter/sort change
537
551
  const filtersForReset = computed(() => ({
@@ -615,6 +629,10 @@ const { data: organizationsResults, status: organizationsStatus } = await useFet
615
629
  organizationsUrl,
616
630
  { params: organizationsParams, lazy: true, server: initialType === 'organizations' },
617
631
  )
632
+ const { data: topicsResults, status: topicsStatus } = await useFetch<TopicSearchResponse<TopicV2>>(
633
+ topicsUrl,
634
+ { params: topicsParams, lazy: true, server: initialType === 'topics' },
635
+ )
618
636
 
619
637
  const typesMeta = {
620
638
  datasets: {
@@ -645,6 +663,13 @@ const typesMeta = {
645
663
  results: organizationsResults,
646
664
  status: organizationsStatus,
647
665
  },
666
+ topics: {
667
+ icon: RiBookShelfLine,
668
+ name: t('Thématiques'),
669
+ placeholder: t('Rechercher une thématique'),
670
+ results: topicsResults,
671
+ status: topicsStatus,
672
+ },
648
673
  } as const
649
674
 
650
675
  const searchResults = computed(() => typesMeta[currentType.value].results.value)
@@ -88,7 +88,7 @@ export function useResourceCapabilities(
88
88
  if (hasTabularData.value) {
89
89
  options.push({ key: 'data', label: t('Données') })
90
90
  }
91
- else if (hasPreview.value || hasDatafairPreview.value || hasOpenAPIPreview.value) {
91
+ else {
92
92
  options.push({ key: 'data', label: t('Aperçu') })
93
93
  }
94
94
 
package/src/config.ts CHANGED
@@ -5,6 +5,8 @@ import type { FetchOptions } from 'ofetch'
5
5
  export type PluginConfig = {
6
6
  name: string // Name of the application (ex: data.gouv.fr)
7
7
  baseUrl: string
8
+ /** Hostnames allowed in Access-Control-Allow-Origin for resource preview CORS checks (e.g. data.gouv.fr). */
9
+ trustedDomains?: string[]
8
10
  apiBase: string
9
11
  devApiKey?: string | null
10
12
  datasetQualityGuideUrl?: string
@@ -1,6 +1,4 @@
1
1
  import { useComponentsConfig } from '../config'
2
- import type { Dataset, DatasetV2 } from '../types/datasets'
3
- import type { CommunityResource, Resource } from '../types/resources'
4
2
 
5
3
  function constructUrl(baseUrl: string, path: string): string {
6
4
  const url = new URL(baseUrl)
@@ -14,18 +12,3 @@ export function getDatasetOEmbedHtml(type: string, id: string): string {
14
12
  const staticUrl = constructUrl(config.baseUrl, 'oembed.js')
15
13
  return `<div data-udata-${type}="${id}"></div><script data-udata="${config.baseUrl}" src="${staticUrl}" async defer></script>`
16
14
  }
17
-
18
- export function isCommunityResource(resource: Resource | CommunityResource): boolean {
19
- return 'organization' in resource || 'owner' in resource
20
- }
21
-
22
- export function getResourceExternalUrl(dataset: Dataset | DatasetV2 | Omit<Dataset, 'resources' | 'community_resources'>, resource: Resource | CommunityResource): string {
23
- return `${dataset.page}${isCommunityResource(resource) ? '/community-resources' : ''}?resource_id=${resource.id}`
24
- }
25
-
26
- export function getResourceFilesize(resource: Resource): null | number {
27
- if (resource.filesize) return resource.filesize
28
- if ('analysis:content-length' in resource.extras) return resource.extras['analysis:content-length'] as number
29
-
30
- return null
31
- }
@@ -1,13 +1,15 @@
1
1
  import { readonly, type Component } from 'vue'
2
2
 
3
3
  import { RiEarthLine, RiMap2Line } from '@remixicon/vue'
4
+ import { useComponentsConfig } from '../config'
4
5
  import Archive from '../components/Icons/Archive.vue'
5
6
  import Code from '../components/Icons/Code.vue'
7
+ import type { Dataset, DatasetV2 } from '../types/datasets'
6
8
  import Documentation from '../components/Icons/Documentation.vue'
7
9
  import Image from '../components/Icons/Image.vue'
8
10
  import Link from '../components/Icons/Link.vue'
9
11
  import Table from '../components/Icons/Table.vue'
10
- import type { Resource } from '../types/resources'
12
+ import type { CommunityResource, Resource } from '../types/resources'
11
13
  import { useTranslation } from '../composables/useTranslation'
12
14
 
13
15
  export function getResourceFormatIcon(format: string): Component | null {
@@ -129,3 +131,56 @@ export const detectOgcService = (resource: Resource) => {
129
131
  }
130
132
  return false
131
133
  }
134
+
135
+ export function isCommunityResource(resource: Resource | CommunityResource): boolean {
136
+ return 'organization' in resource || 'owner' in resource
137
+ }
138
+
139
+ export function getResourceExternalUrl(dataset: Dataset | DatasetV2 | Omit<Dataset, 'resources' | 'community_resources'>, resource: Resource | CommunityResource): string {
140
+ return `${dataset.page}${isCommunityResource(resource) ? '/community-resources' : ''}?resource_id=${resource.id}`
141
+ }
142
+
143
+ export function getResourceFilesize(resource: Resource): null | number {
144
+ if (resource.filesize) return resource.filesize
145
+ if ('analysis:content-length' in resource.extras) return resource.extras['analysis:content-length'] as number
146
+
147
+ return null
148
+ }
149
+
150
+ type CorsStatus = 'allowed' | 'blocked' | 'unknown'
151
+
152
+ export const getResourceCorsStatus = (resource: Resource): CorsStatus => {
153
+ const extras = resource.extras
154
+ if (!extras || !('check:cors:allow-origin' in extras)) {
155
+ return 'unknown'
156
+ }
157
+
158
+ const allowOrigin = extras['check:cors:allow-origin'] as string | undefined
159
+ const rawMethods = extras['check:cors:allow-methods'] as string | undefined
160
+
161
+ // Check if allow-origin is '*' or contains one of our trusted domains
162
+ const config = useComponentsConfig()
163
+ const trustedDomains = config.trustedDomains ?? []
164
+ const hasPublicCors = allowOrigin === '*'
165
+ const hasSpecificCors = allowOrigin
166
+ ? trustedDomains.some((domain) => {
167
+ try {
168
+ const hostname = new URL(allowOrigin).hostname
169
+ return hostname === domain || hostname.endsWith(`.${domain}`)
170
+ }
171
+ catch {
172
+ return false
173
+ }
174
+ })
175
+ : false
176
+
177
+ const isOriginAllowed = hasPublicCors || hasSpecificCors
178
+
179
+ // Ensure GET method is allowed
180
+ const allowedMethods = rawMethods
181
+ ? rawMethods.split(',').map(m => m.trim().toUpperCase())
182
+ : []
183
+ const supportsGet = allowedMethods.length === 0 || allowedMethods.includes('GET')
184
+
185
+ return isOriginAllowed && supportsGet ? 'allowed' : 'blocked'
186
+ }
@@ -6,92 +6,15 @@ export type SortConfig = {
6
6
  type: string
7
7
  } | null
8
8
 
9
- export type TabularDataResponse = {
10
- data: Array<Record<string, unknown>>
11
- meta: { total: number }
12
- }
13
-
14
- export type TabularAggregateType = 'avg' | 'sum' | 'count' | 'min' | 'max'
15
-
16
- export type FetchTabularDataOptions = {
17
- resourceId: string
18
- page?: number
19
- pageSize?: number
20
- columns?: Array<string> | undefined
21
- sort?: SortConfig
22
- groupBy?: string | undefined
23
- aggregation?: {
24
- column: string
25
- type: TabularAggregateType
26
- } | undefined
27
- }
28
-
29
- export type TabularProfileResponse = {
30
- profile: {
31
- header: Array<string>
32
- columns: Record<string, {
33
- score: number
34
- format: string
35
- python_type: string
36
- }>
37
- formats: Record<string, Array<string>>
38
- profile: Record<string, {
39
- tops: Array<{ count: number, value: string }>
40
- nb_distinct: number
41
- nb_missing_values: number
42
- min?: number
43
- max?: number
44
- std?: number
45
- mean?: number
46
- }>
47
- encoding: string
48
- separator: string
49
- categorical: Array<string>
50
- total_lines: number
51
- nb_duplicates: number
52
- columns_fields: Record<string, {
53
- score: number
54
- format: string
55
- python_type: string
56
- }>
57
- columns_labels: Record<string, {
58
- score: number
59
- format: string
60
- python_type: string
61
- }>
62
- header_row_idx: number
63
- heading_columns: number
64
- trailing_columns: number
65
- }
66
- deleted_at: string | null
67
- dataset_id: string
68
- indexes: null
69
- }
70
-
71
- /**
72
- * Call Tabular-api to get table content with options object
73
- */
74
- export async function fetchTabularData(config: PluginConfig, options: FetchTabularDataOptions): Promise<TabularDataResponse> {
75
- const page = options.page ?? 1
76
- const pageSize = options.pageSize ?? config.tabularApiPageSize ?? 15
77
- let url = `${config.tabularApiUrl}/api/resources/${options.resourceId}/data/?page=${page}&page_size=${pageSize}`
78
- if (options.columns) {
79
- url += `&columns=${options.columns.join(',')}`
80
- }
81
- if (options.sort) {
82
- url += `&${options.sort.column}__sort=${options.sort.type}`
83
- }
84
- if (options.groupBy && options.aggregation?.type) {
85
- url += `&${options.groupBy}__groupby&${options.aggregation.column}__${options.aggregation.type}`
86
- }
87
- return await ofetch<TabularDataResponse>(url)
88
- }
89
-
90
9
  /**
91
10
  * Call Tabular-api to get table content
92
11
  */
93
- export function getData(config: PluginConfig, id: string, page: number, sortConfig?: SortConfig) {
94
- return fetchTabularData(config, { resourceId: id, page, sort: sortConfig })
12
+ export async function getData(config: PluginConfig, id: string, page: number, sortConfig?: SortConfig) {
13
+ let url = `${config.tabularApiUrl}/api/resources/${id}/data/?page=${page}&page_size=${config.tabularApiPageSize || 15}`
14
+ if (sortConfig) {
15
+ url = url + `&${sortConfig.column}__sort=${sortConfig.type}`
16
+ }
17
+ return await ofetch(url)
95
18
  }
96
19
 
97
20
  /**
@@ -99,5 +22,5 @@ export function getData(config: PluginConfig, id: string, page: number, sortConf
99
22
  */
100
23
  export function useGetProfile() {
101
24
  const config = useComponentsConfig()
102
- return (id: string) => ofetch<TabularProfileResponse>(`${config.tabularApiUrl}/api/resources/${id}/profile/`)
25
+ return (id: string) => ofetch(`${config.tabularApiUrl}/api/resources/${id}/profile/`)
103
26
  }
package/src/main.ts CHANGED
@@ -23,9 +23,8 @@ import type { Site } from './types/site'
23
23
  import type { Weight, WellType } from './types/ui'
24
24
  import type { User, UserReference } from './types/users'
25
25
  import type { Report, ReportSubject, ReportReason } from './types/reports'
26
- import type { Chart, ChartForm, ChartForApi, FilterCondition, Filter, AndFilters, GenericFilter, XAxisType, XAxisSortBy, SortDirection, XAxis, XAxisForm, UnitPosition, YAxis, DataSeriesType, DataSeries, DataSeriesForm } from './types/visualizations'
27
26
  import type { GlobalSearchConfig, SearchType, SortOption } from './types/search'
28
- import { getDefaultDatasetConfig, getDefaultDataserviceConfig, getDefaultReuseConfig, getDefaultOrganizationConfig, getDefaultGlobalSearchConfig, defaultDatasetSortOptions, defaultDataserviceSortOptions, defaultReuseSortOptions, defaultOrganizationSortOptions } from './types/search'
27
+ import { getDefaultDatasetConfig, getDefaultDataserviceConfig, getDefaultReuseConfig, getDefaultOrganizationConfig, getDefaultTopicConfig, getDefaultGlobalSearchConfig, defaultDatasetSortOptions, defaultDataserviceSortOptions, defaultReuseSortOptions, defaultOrganizationSortOptions } from './types/search'
29
28
 
30
29
  import ActivityList from './components/ActivityList/ActivityList.vue'
31
30
  import UserActivityList from './components/ActivityList/UserActivityList.vue'
@@ -101,7 +100,6 @@ import { configKey, useComponentsConfig, type PluginConfig } from './config.js'
101
100
  export { Toaster, toast } from 'vue-sonner'
102
101
 
103
102
  export * from './composables/useActiveDescendant'
104
- export * from './composables/useDebouncedRef'
105
103
  export * from './composables/useMetrics'
106
104
  export * from './composables/useReuseType'
107
105
  export * from './composables/useTranslation'
@@ -118,12 +116,10 @@ export * from './functions/metrics'
118
116
  export * from './functions/never'
119
117
  export * from './functions/organizations'
120
118
  export * from './functions/owned'
121
- export * from './functions/pagination'
122
119
  export * from './functions/resources'
123
120
  export * from './functions/reuses'
124
121
  export * from './functions/schemas'
125
122
  export * from './functions/users'
126
- export * from './functions/tabularApi'
127
123
  export * from './types/access_types'
128
124
 
129
125
  export type {
@@ -221,23 +217,6 @@ export type {
221
217
  ValidataError,
222
218
  Weight,
223
219
  WellType,
224
- Chart,
225
- ChartForm,
226
- ChartForApi,
227
- FilterCondition,
228
- Filter,
229
- AndFilters,
230
- GenericFilter,
231
- XAxisType,
232
- XAxisSortBy,
233
- SortDirection,
234
- XAxis,
235
- XAxisForm,
236
- UnitPosition,
237
- YAxis,
238
- DataSeriesType,
239
- DataSeries,
240
- DataSeriesForm,
241
220
  }
242
221
 
243
222
  export {
@@ -245,6 +224,7 @@ export {
245
224
  getDefaultDataserviceConfig,
246
225
  getDefaultReuseConfig,
247
226
  getDefaultOrganizationConfig,
227
+ getDefaultTopicConfig,
248
228
  getDefaultGlobalSearchConfig,
249
229
  defaultDatasetSortOptions,
250
230
  defaultDataserviceSortOptions,
@@ -24,6 +24,7 @@ export type BaseDataservice = Owned & WithAccessType & {
24
24
  license: string | null
25
25
  private: boolean
26
26
  rate_limiting: string
27
+ rate_limiting_url: string | null
27
28
  title: DataserviceReference['title']
28
29
  contact_points: Array<ContactPoint>
29
30
  }
@@ -65,6 +66,7 @@ export type Dataservice = Owned & WithAccessType & {
65
66
  permissions: { edit: boolean, delete: boolean }
66
67
  private: boolean
67
68
  rate_limiting: string
69
+ rate_limiting_url: string | null
68
70
  self_api_url: DataserviceReference['self_api_url']
69
71
  self_web_url: DataserviceReference['self_web_url']
70
72
  slug: string
@@ -1,7 +1,7 @@
1
1
  import type { User } from './users'
2
2
  import type { Badges } from './badges'
3
3
 
4
- export type MemberRole = 'admin' | 'editor'
4
+ export type MemberRole = 'admin' | 'editor' | 'partial_editor'
5
5
 
6
6
  export type Member = {
7
7
  role: MemberRole
@@ -16,11 +16,14 @@ export type Report = {
16
16
  id: string
17
17
  by: User | null
18
18
  subject: ReportSubject | null
19
+ subject_embed_id: string | null
19
20
  reason: ReportReasonValue
20
21
  message: string
21
22
  reported_at: string
22
23
  self_api_url: string
23
24
  subject_deleted_at: string | null
25
+ subject_deleted_by: User | null
26
+ subject_label: string | null
24
27
  dismissed_at: string | null
25
28
  dismissed_by: User | null
26
29
  }