@datagouv/components-next 1.0.2-dev.3 → 1.0.2-dev.31

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-BzyuQrsK.js +30 -0
  2. package/dist/{Event--kp8kMdJ.js → Event-B0pbfyAo.js} +1 -1
  3. package/dist/JsonPreview.client-CsFH4_pc.js +78 -0
  4. package/dist/{Map-BjUnLyj8.js → Map-ByzoJvTf.js} +2 -2
  5. package/dist/MapContainer.client-PxTb3GFB.js +102 -0
  6. package/dist/{OSM-s40W6sQ2.js → OSM-FSBCBM2l.js} +1 -1
  7. package/dist/{PdfPreview.client-C-w6-w44.js → PdfPreview.client-F9riTFzW.js} +693 -699
  8. package/dist/{Pmtiles.client-BR7_ldHY.js → Pmtiles.client-BdN6D_o3.js} +575 -580
  9. package/dist/Swagger.client-DRsUsdkD.js +4 -0
  10. package/dist/{Tile-DbNFNPfU.js → Tile-nykTnQlb.js} +4 -4
  11. package/dist/{TileImage-BsXBxMtq.js → TileImage-RLU-wMoy.js} +1 -1
  12. package/dist/{View-BR92hTWP.js → View-SHblmfOT.js} +1 -1
  13. package/dist/XmlPreview.client-CLDalkuE.js +70 -0
  14. package/dist/components-next.css +4 -4
  15. package/dist/components-next.js +47 -46
  16. package/dist/components.css +1 -1
  17. package/dist/{index-SrYZwgCT.js → index-DwQ7YeNi.js} +1164 -1164
  18. package/dist/{leaflet-src-7m1mB8LI.js → leaflet-src-DKk3Q492.js} +185 -183
  19. package/dist/{main-B2kXxWRG.js → main-BLApSdTQ.js} +34789 -34016
  20. package/dist/{text-clamp.esm-B5kW_XMt.js → text-clamp.esm-DVseBqZZ.js} +4 -4
  21. package/dist/{tilecoord-Db24Px13.js → tilecoord-BgTy1qJO.js} +5 -5
  22. package/dist/{vue3-json-viewer-BXwup7nO.js → vue3-json-viewer-BgCuOAH6.js} +10 -10
  23. package/dist/{vue3-xml-viewer.common-BRxsqI9j.js → vue3-xml-viewer.common-DkEC3fSC.js} +16 -16
  24. package/package.json +9 -5
  25. package/src/components/Form/SearchableSelect.vue +2 -1
  26. package/src/components/ReadMore.vue +1 -1
  27. package/src/components/ResourceAccordion/Datafair.client.vue +4 -10
  28. package/src/components/ResourceAccordion/JsonPreview.client.vue +34 -47
  29. package/src/components/ResourceAccordion/MapContainer.client.vue +7 -11
  30. package/src/components/ResourceAccordion/Metadata.vue +1 -2
  31. package/src/components/ResourceAccordion/PdfPreview.client.vue +28 -32
  32. package/src/components/ResourceAccordion/Pmtiles.client.vue +5 -10
  33. package/src/components/ResourceAccordion/Preview.vue +5 -10
  34. package/src/components/ResourceAccordion/PreviewLoader.vue +1 -2
  35. package/src/components/ResourceAccordion/PreviewUnavailable.vue +22 -0
  36. package/src/components/ResourceAccordion/ResourceAccordion.vue +1 -2
  37. package/src/components/ResourceAccordion/XmlPreview.client.vue +34 -47
  38. package/src/components/ResourceExplorer/ResourceExplorer.vue +21 -10
  39. package/src/components/ResourceExplorer/ResourceExplorerViewer.vue +13 -3
  40. package/src/composables/useResourceCapabilities.ts +1 -1
  41. package/src/config.ts +2 -0
  42. package/src/functions/datasets.ts +0 -17
  43. package/src/functions/resources.ts +56 -1
  44. package/src/types/dataservices.ts +2 -0
  45. package/src/types/organizations.ts +1 -1
  46. package/src/types/users.ts +0 -1
  47. package/dist/Datafair.client-E5D6ePRC.js +0 -35
  48. package/dist/JsonPreview.client-C-6eBbPw.js +0 -87
  49. package/dist/MapContainer.client-DRkAmdOc.js +0 -105
  50. package/dist/Swagger.client-D4-F6yEf.js +0 -4
  51. package/dist/XmlPreview.client-Dl2VCgXF.js +0 -79
  52. /package/assets/illustrations/{_microscope.svg → microscope.svg} +0 -0
@@ -1,13 +1,8 @@
1
1
  <template>
2
2
  <div>
3
- <SimpleBanner
4
- v-if="hasError"
5
- type="warning"
6
- class="flex items-center space-x-2"
7
- >
8
- <RiErrorWarningLine class="shrink-0 size-6" />
9
- <span>{{ t("L'aperçu cartographique de ce fichier n'a pas pu être chargé.") }}</span>
10
- </SimpleBanner>
3
+ <PreviewUnavailable v-if="hasError">
4
+ {{ t("L'aperçu cartographique de ce fichier n'a pas pu être chargé.") }}
5
+ </PreviewUnavailable>
11
6
  <div
12
7
  v-else
13
8
  class="-mx-4"
@@ -53,7 +48,7 @@
53
48
 
54
49
  <script setup lang="ts">
55
50
  import { computed, onMounted, ref, useTemplateRef } from 'vue'
56
- import { RiErrorWarningLine, RiExternalLinkFill } from '@remixicon/vue'
51
+ import { RiExternalLinkFill } from '@remixicon/vue'
57
52
  import { Protocol, PMTiles } from 'pmtiles'
58
53
  import maplibregl from 'maplibre-gl'
59
54
  import DOMPurify from 'dompurify'
@@ -64,7 +59,7 @@ import type { Resource } from '../../types/resources'
64
59
  import type { Dataset, DatasetV2 } from '../../types/datasets'
65
60
  import BrandedButton from '../BrandedButton.vue'
66
61
  import styleVector from '../../../assets/json/vector.json'
67
- import SimpleBanner from '../SimpleBanner.vue'
62
+ import PreviewUnavailable from './PreviewUnavailable.vue'
68
63
  import { useTranslation } from '../../composables/useTranslation'
69
64
  import franceSvg from './france.svg?raw'
70
65
  import { getOwnerName, getOwnerPage } from '../../functions/owned'
@@ -1,13 +1,8 @@
1
1
  <template>
2
2
  <div>
3
- <SimpleBanner
4
- v-if="hasError"
5
- type="warning"
6
- class="flex items-center space-x-2"
7
- >
8
- <RiErrorWarningLine class="shrink-0 size-6" />
9
- <span>{{ t("L'aperçu de ce fichier n'a pas pu être chargé.") }}</span>
10
- </SimpleBanner>
3
+ <PreviewUnavailable v-if="hasError">
4
+ {{ t("L'aperçu de ce fichier n'a pas pu être chargé. Téléchargez-le depuis l'onglet Téléchargements.") }}
5
+ </PreviewUnavailable>
11
6
  <PreviewLoader v-else-if="loading" />
12
7
  <div
13
8
  v-else
@@ -105,7 +100,7 @@
105
100
 
106
101
  <script setup lang="ts">
107
102
  import { computed, onMounted, ref } from 'vue'
108
- import { RiArrowDownLine, RiArrowUpLine, RiErrorWarningLine, RiExternalLinkFill } from '@remixicon/vue'
103
+ import { RiArrowDownLine, RiArrowUpLine, RiExternalLinkFill } from '@remixicon/vue'
109
104
  import Pagination from '../Pagination.vue'
110
105
  import { getData, type SortConfig } from '../../functions/tabularApi'
111
106
  import { useFormatDate } from '../../functions/dates'
@@ -113,7 +108,7 @@ import { trackEvent } from '../../functions/matomo'
113
108
  import type { Resource } from '../../types/resources'
114
109
  import { useComponentsConfig } from '../../config'
115
110
  import BrandedButton from '../BrandedButton.vue'
116
- import SimpleBanner from '../SimpleBanner.vue'
111
+ import PreviewUnavailable from './PreviewUnavailable.vue'
117
112
  import { useTranslation } from '../../composables/useTranslation'
118
113
  import franceSvg from './france.svg?raw'
119
114
  import PreviewLoader from './PreviewLoader.vue'
@@ -1,7 +1,6 @@
1
1
  <template>
2
2
  <ContentLoader
3
- :width="1124"
4
- :height="300"
3
+ viewBox="0 0 1124 300"
5
4
  :speed="2"
6
5
  primary-color="#f3f3f3"
7
6
  secondary-color="#ecebeb"
@@ -0,0 +1,22 @@
1
+ <template>
2
+ <div class="flex flex-col items-center py-12">
3
+ <img
4
+ :src="microscopeSrc"
5
+ class="h-20 mb-3"
6
+ alt=""
7
+ >
8
+ <p class="fr-text--bold mb-1">
9
+ {{ t("Aucun aperçu disponible") }}
10
+ </p>
11
+ <p class="text-sm text-gray-medium mb-0 text-center max-w-lg">
12
+ <slot />
13
+ </p>
14
+ </div>
15
+ </template>
16
+
17
+ <script setup lang="ts">
18
+ import { useTranslation } from '../../composables/useTranslation'
19
+ import microscopeSrc from '../../../assets/illustrations/microscope.svg?url'
20
+
21
+ const { t } = useTranslation()
22
+ </script>
@@ -387,9 +387,8 @@ import { trackEvent } from '../../functions/matomo'
387
387
  import CopyButton from '../CopyButton.vue'
388
388
  import { useComponentsConfig } from '../../config'
389
389
  import { getOwnerName } from '../../functions/owned'
390
- import { getResourceFormatIcon, getResourceTitleId, detectOgcService } from '../../functions/resources'
390
+ import { getResourceFormatIcon, getResourceTitleId, detectOgcService, getResourceExternalUrl, getResourceFilesize } from '../../functions/resources'
391
391
  import BrandedButton from '../BrandedButton.vue'
392
- import { getResourceExternalUrl, getResourceFilesize } from '../../functions/datasets'
393
392
  import { useTranslation } from '../../composables/useTranslation'
394
393
  import { useHasTabularData } from '../../composables/useHasTabularData'
395
394
  import Metadata from './Metadata.vue'
@@ -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,12 @@
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
+ {{ t("Ce fichier ne peut pas être prévisualisé. Téléchargez-le depuis l'onglet Téléchargements.") }}
147
+ </PreviewUnavailable>
139
148
  </div>
140
149
  <div v-if="tab.key === 'description'">
141
150
  <MarkdownViewer
@@ -298,6 +307,7 @@
298
307
  <script setup lang="ts">
299
308
  import { computed, defineAsyncComponent } from 'vue'
300
309
  import { RiDownloadLine, RiFileCopyLine, RiFileWarningLine, RiInformationLine, RiSubtractLine } from '@remixicon/vue'
310
+ import PreviewUnavailable from '../ResourceAccordion/PreviewUnavailable.vue'
301
311
  import { toast } from 'vue-sonner'
302
312
  import BrandedButton from '../BrandedButton.vue'
303
313
  import CopyButton from '../CopyButton.vue'
@@ -313,9 +323,9 @@ import Tooltip from '../Tooltip.vue'
313
323
  import Preview from '../ResourceAccordion/Preview.vue'
314
324
  import DataStructure from '../ResourceAccordion/DataStructure.vue'
315
325
  import Metadata from '../ResourceAccordion/Metadata.vue'
326
+ import SchemaBadge from '../ResourceAccordion/SchemaBadge.vue'
316
327
  import { filesize, summarize } from '../../functions/helpers'
317
- import { getResourceFormatIcon } from '../../functions/resources'
318
- import { getResourceExternalUrl, getResourceFilesize } from '../../functions/datasets'
328
+ import { getResourceFormatIcon, getResourceExternalUrl, getResourceFilesize } from '../../functions/resources'
319
329
  import { trackEvent } from '../../functions/matomo'
320
330
  import { useComponentsConfig } from '../../config'
321
331
  import { useFormatDate } from '../../functions/dates'
@@ -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
+ }
@@ -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
@@ -21,7 +21,6 @@ export type User = {
21
21
  page: UserReference['page']
22
22
  avatar: UserReference['avatar']
23
23
  avatar_thumbnail: UserReference['avatar_thumbnail']
24
- apikey?: string
25
24
  email?: string
26
25
  about: string
27
26
  website?: string
@@ -1,35 +0,0 @@
1
- import { defineComponent as f, computed as a, createElementBlock as o, openBlock as t, createBlock as p, createElementVNode as i, withCtx as m, createVNode as _, unref as c, toDisplayString as x } from "vue";
2
- import { a as h, _ as v, F as g } from "./main-B2kXxWRG.js";
3
- const k = { class: "fr-text--xs" }, b = { key: 0 }, y = ["src"], B = /* @__PURE__ */ f({
4
- __name: "Datafair.client",
5
- props: {
6
- resource: {},
7
- dataset: {}
8
- },
9
- setup(d) {
10
- const e = d, { t: l } = h(), r = a(() => e.resource.extras.datafairOrigin || e.dataset.extras.datafairOrigin), s = a(() => e.resource.extras.datafairDatasetId || e.dataset.extras.datafairDatasetId), u = a(() => e.resource.extras.datafairEmbed), n = a(() => !r.value || !s.value ? null : `${r.value}/embed/dataset/${s.value}/${u.value}`);
11
- return (D, E) => (t(), o("div", k, [
12
- n.value ? (t(), o("div", b, [
13
- i("iframe", {
14
- src: n.value,
15
- width: "100%",
16
- height: "500px",
17
- style: { "background-color": "transparent", border: "none" }
18
- }, null, 8, y)
19
- ])) : (t(), p(v, {
20
- key: 1,
21
- type: "warning",
22
- class: "flex items-center space-x-2"
23
- }, {
24
- default: m(() => [
25
- _(c(g), { class: "shrink-0 size-6" }),
26
- i("span", null, x(c(l)("Erreur lors de l'affichage de l'aperçu.")), 1)
27
- ]),
28
- _: 1
29
- }))
30
- ]));
31
- }
32
- });
33
- export {
34
- B as default
35
- };
@@ -1,87 +0,0 @@
1
- import { defineComponent as S, defineAsyncComponent as b, ref as o, computed as w, onMounted as N, createElementBlock as p, openBlock as r, createBlock as f, createCommentVNode as T, createVNode as u, unref as t, toDisplayString as i, withCtx as d, createElementVNode as h } from "vue";
2
- import { u as P, a as E, g as q, _ as m, F as v } from "./main-B2kXxWRG.js";
3
- const B = { class: "fr-text--xs" }, O = { key: 0 }, V = {
4
- key: 1,
5
- class: "text-gray-medium"
6
- }, L = /* @__PURE__ */ S({
7
- __name: "JsonPreview.client",
8
- props: {
9
- resource: {}
10
- },
11
- setup(k) {
12
- const z = b(
13
- () => import("./vue3-json-viewer-BXwup7nO.js").then((e) => (Promise.resolve({ }), e.JsonViewer))
14
- ), g = k, x = P(), { t: s } = E(), l = o(null), c = o(!1), n = o(null), _ = o(!1), y = w(() => q(g.resource)), J = w(() => {
15
- const e = y.value;
16
- if (!e || !x.maxJsonPreviewCharSize)
17
- return !1;
18
- const a = x.maxJsonPreviewCharSize;
19
- return e <= a;
20
- }), C = async () => {
21
- if (!J.value) {
22
- _.value = !0;
23
- return;
24
- }
25
- c.value = !0, n.value = null;
26
- try {
27
- const e = await fetch(g.resource.url);
28
- if (!e.ok)
29
- throw new Error(`HTTP error! status: ${e.status}`);
30
- const a = await e.json();
31
- l.value = a;
32
- } catch (e) {
33
- console.error("Error loading JSON:", e), e instanceof TypeError ? n.value = "network" : n.value = "generic", l.value = null;
34
- } finally {
35
- c.value = !1;
36
- }
37
- };
38
- return N(() => {
39
- C();
40
- }), (e, a) => (r(), p("div", B, [
41
- l.value ? (r(), p("div", O, [
42
- u(t(z), {
43
- value: l.value,
44
- boxed: "",
45
- sort: "",
46
- theme: "light",
47
- "max-depth": 3,
48
- "expand-depth": 2,
49
- "indent-width": 2
50
- }, null, 8, ["value"])
51
- ])) : c.value ? (r(), p("div", V, i(t(s)("Chargement de l'aperçu JSON...")), 1)) : _.value ? (r(), f(m, {
52
- key: 2,
53
- type: "warning",
54
- class: "flex items-center space-x-2"
55
- }, {
56
- default: d(() => [
57
- u(t(v), { class: "shrink-0 size-6" }),
58
- h("span", null, i(y.value ? t(s)("Fichier JSON 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.") : t(s)("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.")), 1)
59
- ]),
60
- _: 1
61
- })) : n.value === "network" ? (r(), f(m, {
62
- key: 3,
63
- type: "warning",
64
- class: "flex items-center space-x-2"
65
- }, {
66
- default: d(() => [
67
- u(t(v), { class: "shrink-0 size-6" }),
68
- h("span", null, i(t(s)("Ce fichier JSON 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.")), 1)
69
- ]),
70
- _: 1
71
- })) : n.value ? (r(), f(m, {
72
- key: 4,
73
- type: "warning",
74
- class: "flex items-center space-x-2"
75
- }, {
76
- default: d(() => [
77
- u(t(v), { class: "shrink-0 size-6" }),
78
- h("span", null, i(t(s)("Erreur lors du chargement de l'aperçu JSON.")), 1)
79
- ]),
80
- _: 1
81
- })) : T("", !0)
82
- ]));
83
- }
84
- });
85
- export {
86
- L as default
87
- };