@datagouv/components-next 1.0.2-dev.9 → 1.0.2-dev.91

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 (96) hide show
  1. package/assets/main.css +4 -0
  2. package/dist/{Control-DuZJdKV_.js → Control-ZFh5ta_U.js} +1 -1
  3. package/dist/Datafair.client-CyZRNADr.js +30 -0
  4. package/dist/{Event--kp8kMdJ.js → Event-DSQcW7OF.js} +24 -24
  5. package/dist/{Image-34hvypZI.js → Image-BijNEG0p.js} +6 -6
  6. package/dist/JsonPreview.client-C9iaPSmQ.js +40 -0
  7. package/dist/{Map-BjUnLyj8.js → Map-BUtPf5GN.js} +756 -756
  8. package/dist/MapContainer.client-BuoZ69XO.js +101 -0
  9. package/dist/{OSM-s40W6sQ2.js → OSM-D4MTdBtk.js} +2 -2
  10. package/dist/{PdfPreview.client-BVjPxlPu.js → PdfPreview.client-MI0bDghc.js} +822 -865
  11. package/dist/{Pmtiles.client-CRJ56yX2.js → Pmtiles.client-CaKEYQBc.js} +574 -579
  12. package/dist/PreviewWrapper.vue_vue_type_script_setup_true_lang-BKqb6TMw.js +61 -0
  13. package/dist/{ScaleLine-KW-nXqp3.js → ScaleLine-hJQIqcZm.js} +2 -2
  14. package/dist/{Tile-DbNFNPfU.js → Tile-Dcl7oIVu.js} +35 -35
  15. package/dist/{TileImage-BsXBxMtq.js → TileImage-BJeHipMX.js} +4 -4
  16. package/dist/{View-BR92hTWP.js → View-xp_P_OHw.js} +412 -401
  17. package/dist/XmlPreview.client-BVAeNK4n.js +34 -0
  18. package/dist/{common-PJfpC179.js → common-BjQlan3k.js} +36 -36
  19. package/dist/components-next.css +6 -6
  20. package/dist/components-next.js +166 -148
  21. package/dist/components.css +1 -1
  22. package/dist/{index-BZsAZ7iw.js → index-BBdS8QKx.js} +32886 -27183
  23. package/dist/{main-qc4CO9Kn.js → main-Dk_66g-3.js} +91331 -75844
  24. package/dist/{proj-DsetBcW7.js → proj-CsNo9yH1.js} +532 -512
  25. package/dist/{tilecoord-Db24Px13.js → tilecoord-A0fLnBZr.js} +28 -28
  26. package/dist/{vue3-xml-viewer.common-CCOV_ohP.js → vue3-xml-viewer.common-B8dNNkOU.js} +1 -1
  27. package/package.json +18 -11
  28. package/src/components/ActivityList/ActivityList.vue +0 -2
  29. package/src/components/Chart/ChartViewer.vue +226 -0
  30. package/src/components/Chart/ChartViewerWrapper.vue +170 -0
  31. package/src/components/Form/Listbox.vue +101 -0
  32. package/src/components/Form/SearchableSelect.vue +2 -1
  33. package/src/components/InfiniteLoader.vue +53 -0
  34. package/src/components/OpenApiViewer/ContentTypeSelect.vue +48 -0
  35. package/src/components/OpenApiViewer/EndpointRequest.vue +164 -0
  36. package/src/components/OpenApiViewer/EndpointResponses.vue +149 -0
  37. package/src/components/OpenApiViewer/OpenApiViewer.vue +308 -0
  38. package/src/components/OpenApiViewer/SchemaPanel.vue +53 -0
  39. package/src/components/OpenApiViewer/SchemaTree.vue +77 -0
  40. package/src/components/OpenApiViewer/openapi.ts +150 -0
  41. package/src/components/OrganizationNameWithCertificate.vue +3 -2
  42. package/src/components/Pagination.vue +8 -5
  43. package/src/components/ReadMore.vue +1 -1
  44. package/src/components/ResourceAccordion/Datafair.client.vue +4 -10
  45. package/src/components/ResourceAccordion/JsonPreview.client.vue +23 -121
  46. package/src/components/ResourceAccordion/MapContainer.client.vue +5 -14
  47. package/src/components/ResourceAccordion/Metadata.vue +1 -2
  48. package/src/components/ResourceAccordion/PdfPreview.client.vue +24 -103
  49. package/src/components/ResourceAccordion/Pmtiles.client.vue +5 -10
  50. package/src/components/ResourceAccordion/Preview.vue +16 -21
  51. package/src/components/ResourceAccordion/PreviewLoader.vue +1 -2
  52. package/src/components/ResourceAccordion/PreviewUnavailable.vue +22 -0
  53. package/src/components/ResourceAccordion/PreviewWrapper.vue +82 -0
  54. package/src/components/ResourceAccordion/ResourceAccordion.vue +5 -7
  55. package/src/components/ResourceAccordion/XmlPreview.client.vue +16 -115
  56. package/src/components/ResourceExplorer/ResourceExplorer.vue +81 -13
  57. package/src/components/ResourceExplorer/ResourceExplorerSidebar.vue +2 -2
  58. package/src/components/ResourceExplorer/ResourceExplorerViewer.vue +30 -11
  59. package/src/components/Search/GlobalSearch.vue +191 -110
  60. package/src/components/Search/SearchInput.vue +5 -4
  61. package/src/components/TabularExplorer/TabularCell.vue +51 -0
  62. package/src/components/TabularExplorer/TabularCellPopover.vue +170 -0
  63. package/src/components/TabularExplorer/TabularExplorer.vue +870 -0
  64. package/src/components/TabularExplorer/TabularFilterContent.vue +351 -0
  65. package/src/components/TabularExplorer/TabularFilterPopover.vue +111 -0
  66. package/src/components/TabularExplorer/types.ts +83 -0
  67. package/src/composables/useHasTabularData.ts +6 -0
  68. package/src/composables/useResourceCapabilities.ts +1 -1
  69. package/src/composables/useSearchFilter.ts +118 -0
  70. package/src/composables/useStableQueryParams.ts +31 -3
  71. package/src/config.ts +3 -0
  72. package/src/functions/api.ts +34 -33
  73. package/src/functions/api.types.ts +1 -0
  74. package/src/functions/charts.ts +68 -0
  75. package/src/functions/datasets.ts +0 -17
  76. package/src/functions/resources.ts +56 -1
  77. package/src/functions/tabular.ts +60 -0
  78. package/src/functions/tabularApi.ts +138 -11
  79. package/src/main.ts +55 -7
  80. package/src/types/dataservices.ts +2 -0
  81. package/src/types/pages.ts +0 -5
  82. package/src/types/posts.ts +2 -2
  83. package/src/types/reports.ts +5 -1
  84. package/src/types/search.ts +52 -1
  85. package/src/types/site.ts +5 -3
  86. package/src/types/users.ts +2 -1
  87. package/src/types/visualizations.ts +89 -0
  88. package/assets/swagger-themes/newspaper.css +0 -1670
  89. package/dist/Datafair.client-0UYUu5yf.js +0 -35
  90. package/dist/JsonPreview.client-BrTMBWHZ.js +0 -87
  91. package/dist/MapContainer.client-CUmKyByc.js +0 -107
  92. package/dist/Swagger.client-2Yn7iF0A.js +0 -4
  93. package/dist/XmlPreview.client-DxqlVnKu.js +0 -79
  94. package/src/components/ResourceAccordion/Swagger.client.vue +0 -48
  95. package/src/functions/pagination.ts +0 -9
  96. /package/assets/illustrations/{_microscope.svg → microscope.svg} +0 -0
@@ -0,0 +1,308 @@
1
+ <template>
2
+ <div>
3
+ <div
4
+ v-if="loading"
5
+ class="flex items-center justify-center py-8"
6
+ >
7
+ <AnimatedLoader />
8
+ </div>
9
+ <div
10
+ v-else-if="error"
11
+ class="text-new-error text-sm py-4"
12
+ >
13
+ {{ t("Impossible de charger la documentation OpenAPI.") }}
14
+ </div>
15
+ <div
16
+ v-else-if="spec"
17
+ class="space-y-4"
18
+ >
19
+ <div class="flex flex-wrap items-center justify-between gap-x-4 gap-y-1 text-sm text-gray-medium">
20
+ <div class="flex flex-wrap gap-x-4 gap-y-1">
21
+ <span v-if="spec.info?.version">
22
+ {{ t("Version") }} <span class="font-mono">{{ spec.info.version }}</span>
23
+ </span>
24
+ <div
25
+ v-if="baseUrl"
26
+ class="flex flex-col md:flex-row md:items-center gap-0.5 md:gap-0"
27
+ >
28
+ <span>{{ t("Base URL") }}</span>
29
+ <span class="inline-flex items-center">
30
+ <span class="font-mono break-all md:ml-1">{{ baseUrl }}</span>
31
+ <CopyButton
32
+ :label="t('Copier le lien')"
33
+ :copied-label="t('Lien copié !')"
34
+ :text="baseUrl"
35
+ class="shrink-0 hidden md:inline-flex"
36
+ />
37
+ </span>
38
+ </div>
39
+ </div>
40
+ <a
41
+ :href="swaggerUiUrl"
42
+ target="_blank"
43
+ rel="noopener noreferrer"
44
+ class="text-xs text-gray-medium hover:text-gray-title"
45
+ >
46
+ {{ t("Ouvrir dans Swagger UI") }}
47
+ </a>
48
+ </div>
49
+ <div
50
+ v-for="group in groupedEndpoints"
51
+ :key="group.tag"
52
+ >
53
+ <Disclosure
54
+ v-slot="{ open }"
55
+ as="div"
56
+ default-open
57
+ >
58
+ <DisclosureButton class="flex w-full items-center justify-between py-2 border-b border-gray-default text-left">
59
+ <span class="font-bold text-gray-title">
60
+ {{ group.tag }}
61
+ <span class="ml-1 text-xs font-normal text-gray-medium">{{ group.endpoints.length }}</span>
62
+ </span>
63
+ <RiArrowDownSLine
64
+ class="size-5 text-gray-medium transition-transform"
65
+ :class="{ 'rotate-180': open }"
66
+ />
67
+ </DisclosureButton>
68
+ <DisclosurePanel class="divide-y divide-gray-100">
69
+ <Disclosure
70
+ v-for="endpoint in group.endpoints"
71
+ :key="endpoint.method + endpoint.path"
72
+ v-slot="{ open: endpointOpen }"
73
+ as="div"
74
+ >
75
+ <DisclosureButton class="flex items-baseline gap-2 md:gap-3 py-3 px-1 w-full text-left">
76
+ <span
77
+ class="shrink-0 w-12 md:w-16 inline-flex items-center justify-center rounded px-1.5 py-0.5 text-xs font-bold uppercase font-mono leading-none"
78
+ :class="methodColor(endpoint.method)"
79
+ >
80
+ {{ endpoint.method }}
81
+ </span>
82
+ <div class="min-w-0 flex-1">
83
+ <span class="inline-flex items-center gap-2">
84
+ <span class="font-mono text-sm text-gray-title break-all">{{ endpoint.path }}</span>
85
+ <CopyButton
86
+ :label="t('Copier le lien')"
87
+ :copied-label="t('Lien copié !')"
88
+ :text="endpointFullUrl(endpoint)"
89
+ class="shrink-0 hidden md:inline-flex"
90
+ @click.stop
91
+ />
92
+ </span>
93
+ <p
94
+ v-if="endpoint.summary"
95
+ class="hidden md:block text-sm text-gray-medium mt-0.5 mb-0"
96
+ >
97
+ {{ endpoint.summary }}
98
+ </p>
99
+ </div>
100
+ <RiArrowDownSLine
101
+ class="size-4 shrink-0 text-gray-medium transition-transform"
102
+ :class="{ 'rotate-180': endpointOpen }"
103
+ />
104
+ </DisclosureButton>
105
+ <DisclosurePanel class="pb-4 px-1">
106
+ <div class="grid grid-cols-1 md:grid-cols-2 gap-4">
107
+ <EndpointRequest
108
+ :endpoint="endpoint"
109
+ />
110
+ <EndpointResponses
111
+ :responses="endpoint.responses"
112
+ :spec="endpoint.spec"
113
+ />
114
+ </div>
115
+ </DisclosurePanel>
116
+ </Disclosure>
117
+ </DisclosurePanel>
118
+ </Disclosure>
119
+ </div>
120
+ <div v-if="schemas.length">
121
+ <Disclosure
122
+ v-slot="{ open }"
123
+ default-open
124
+ as="div"
125
+ >
126
+ <DisclosureButton class="flex w-full items-center justify-between py-2 border-b border-gray-default text-left">
127
+ <span class="font-bold text-gray-title">
128
+ {{ t("Modèles") }}
129
+ <span class="ml-1 text-xs font-normal text-gray-medium">{{ schemas.length }}</span>
130
+ </span>
131
+ <RiArrowDownSLine
132
+ class="size-5 text-gray-medium transition-transform"
133
+ :class="{ 'rotate-180': open }"
134
+ />
135
+ </DisclosureButton>
136
+ <DisclosurePanel class="divide-y divide-gray-100">
137
+ <Disclosure
138
+ v-for="model in schemas"
139
+ :key="model.name"
140
+ v-slot="{ open: modelOpen }"
141
+ as="div"
142
+ >
143
+ <DisclosureButton class="flex items-center gap-2 py-3 px-1 w-full text-left">
144
+ <RiArrowDownSLine
145
+ class="size-4 shrink-0 text-gray-medium transition-transform"
146
+ :class="{ 'rotate-180': modelOpen }"
147
+ />
148
+ <span class="font-mono text-sm text-gray-title">{{ model.name }}</span>
149
+ <span
150
+ v-if="model.schema.description"
151
+ class="text-xs text-gray-medium truncate"
152
+ >{{ model.schema.description }}</span>
153
+ </DisclosureButton>
154
+ <DisclosurePanel class="pb-4 px-1">
155
+ <SchemaPanel
156
+ :spec="spec!"
157
+ :schema="model.schema"
158
+ />
159
+ </DisclosurePanel>
160
+ </Disclosure>
161
+ </DisclosurePanel>
162
+ </Disclosure>
163
+ </div>
164
+ </div>
165
+ </div>
166
+ </template>
167
+
168
+ <script setup lang="ts">
169
+ import { ref, computed, watchEffect } from 'vue'
170
+ import { Disclosure, DisclosureButton, DisclosurePanel } from '@headlessui/vue'
171
+ import { RiArrowDownSLine } from '@remixicon/vue'
172
+ import { useTranslation } from '../../composables/useTranslation'
173
+ import AnimatedLoader from '../AnimatedLoader.vue'
174
+ import CopyButton from '../CopyButton.vue'
175
+ import EndpointRequest from './EndpointRequest.vue'
176
+ import EndpointResponses from './EndpointResponses.vue'
177
+ import SchemaPanel from './SchemaPanel.vue'
178
+ import { parse as parseYaml } from 'yaml'
179
+ import type { OpenAPIV3 } from 'openapi-types'
180
+ import { resolveRef, type Endpoint } from './openapi'
181
+
182
+ const props = defineProps<{
183
+ url: string
184
+ }>()
185
+
186
+ const { t } = useTranslation()
187
+
188
+ const spec = ref<OpenAPIV3.Document | null>(null)
189
+ const loading = ref(true)
190
+ const error = ref(false)
191
+
192
+ const HTTP_METHODS = ['get', 'post', 'put', 'patch', 'delete', 'options', 'head'] as const
193
+
194
+ async function parseOpenApiResponse(response: Response): Promise<OpenAPIV3.Document> {
195
+ const text = await response.text()
196
+ try {
197
+ return JSON.parse(text)
198
+ }
199
+ catch {
200
+ return parseYaml(text) as OpenAPIV3.Document
201
+ }
202
+ }
203
+
204
+ watchEffect(async () => {
205
+ if (!props.url) return
206
+ loading.value = true
207
+ error.value = false
208
+ try {
209
+ const response = await fetch(props.url)
210
+ if (!response.ok) throw new Error(response.statusText)
211
+ spec.value = await parseOpenApiResponse(response)
212
+ }
213
+ catch {
214
+ error.value = true
215
+ spec.value = null
216
+ }
217
+ finally {
218
+ loading.value = false
219
+ }
220
+ })
221
+
222
+ const baseUrl = computed(() => {
223
+ if (!spec.value?.servers?.length) return null
224
+ return spec.value.servers[0]!.url
225
+ })
226
+
227
+ const swaggerUiUrl = computed(() => {
228
+ return `https://petstore.swagger.io/?url=${encodeURIComponent(props.url)}`
229
+ })
230
+
231
+ const endpoints = computed<Endpoint[]>(() => {
232
+ if (!spec.value?.paths) return []
233
+ const result: Endpoint[] = []
234
+ for (const [path, pathItem] of Object.entries(spec.value.paths)) {
235
+ if (!pathItem) continue
236
+ for (const method of HTTP_METHODS) {
237
+ const operation = (pathItem as Record<string, OpenAPIV3.OperationObject>)[method]
238
+ if (!operation) continue
239
+
240
+ const parameters = (operation.parameters || []).map((p) => {
241
+ return resolveRef<OpenAPIV3.ParameterObject>(spec.value!, p)
242
+ }).filter((p): p is OpenAPIV3.ParameterObject => p !== null)
243
+
244
+ const requestBody = operation.requestBody
245
+ ? resolveRef<OpenAPIV3.RequestBodyObject>(spec.value!, operation.requestBody)
246
+ : null
247
+
248
+ const responses: Record<string, OpenAPIV3.ResponseObject> = {}
249
+ if (operation.responses) {
250
+ for (const [code, resp] of Object.entries(operation.responses)) {
251
+ const resolved = resolveRef<OpenAPIV3.ResponseObject>(spec.value!, resp)
252
+ if (resolved) responses[code] = resolved
253
+ }
254
+ }
255
+
256
+ result.push({
257
+ method,
258
+ path,
259
+ summary: operation.summary || operation.description || '',
260
+ tags: operation.tags || [],
261
+ parameters,
262
+ requestBody: requestBody || null,
263
+ responses,
264
+ spec: spec.value!,
265
+ })
266
+ }
267
+ }
268
+ return result
269
+ })
270
+
271
+ const groupedEndpoints = computed(() => {
272
+ const groups = new Map<string, Endpoint[]>()
273
+ for (const endpoint of endpoints.value) {
274
+ const tags = endpoint.tags.length ? endpoint.tags : [t('Endpoints')]
275
+ for (const tag of tags) {
276
+ if (!groups.has(tag)) {
277
+ groups.set(tag, [])
278
+ }
279
+ groups.get(tag)!.push(endpoint)
280
+ }
281
+ }
282
+ return Array.from(groups.entries()).map(([tag, endpoints]) => ({ tag, endpoints }))
283
+ })
284
+
285
+ const schemas = computed(() => {
286
+ const components = spec.value?.components?.schemas
287
+ if (!components) return []
288
+ return Object.entries(components).map(([name, schema]) => ({
289
+ name,
290
+ schema: schema as OpenAPIV3.SchemaObject,
291
+ }))
292
+ })
293
+
294
+ function endpointFullUrl(endpoint: Endpoint): string {
295
+ return (baseUrl.value || '') + endpoint.path
296
+ }
297
+
298
+ function methodColor(method: string): string {
299
+ switch (method) {
300
+ case 'get': return 'bg-blue-100 text-blue-800'
301
+ case 'post': return 'bg-green-100 text-green-800'
302
+ case 'put': return 'bg-orange-100 text-orange-800'
303
+ case 'patch': return 'bg-yellow-100 text-yellow-800'
304
+ case 'delete': return 'bg-red-100 text-red-800'
305
+ default: return 'bg-gray-100 text-gray-800'
306
+ }
307
+ }
308
+ </script>
@@ -0,0 +1,53 @@
1
+ <template>
2
+ <div>
3
+ <div class="flex items-center gap-2 mb-2">
4
+ <button
5
+ type="button"
6
+ class="text-xs font-medium px-2 py-0.5 rounded"
7
+ :class="view === 'schema' ? 'bg-gray-200 text-gray-title' : 'text-gray-medium hover:text-gray-title'"
8
+ @click="view = 'schema'"
9
+ >
10
+ {{ t("Schéma") }}
11
+ </button>
12
+ <button
13
+ type="button"
14
+ class="text-xs font-medium px-2 py-0.5 rounded"
15
+ :class="view === 'example' ? 'bg-gray-200 text-gray-title' : 'text-gray-medium hover:text-gray-title'"
16
+ @click="view = 'example'"
17
+ >
18
+ {{ t("Exemple") }}
19
+ </button>
20
+ </div>
21
+ <SchemaTree
22
+ v-if="view === 'schema'"
23
+ :spec="spec"
24
+ :schema="schema"
25
+ />
26
+ <pre
27
+ v-else
28
+ class="text-xs font-mono bg-gray-50 rounded p-3 overflow-x-auto m-0 text-gray-title"
29
+ >{{ exampleJson }}</pre>
30
+ </div>
31
+ </template>
32
+
33
+ <script setup lang="ts">
34
+ import { ref, computed } from 'vue'
35
+ import SchemaTree from './SchemaTree.vue'
36
+ import { useTranslation } from '../../composables/useTranslation'
37
+ import { generateExample } from './openapi'
38
+ import type { OpenAPIV3 } from 'openapi-types'
39
+
40
+ const props = defineProps<{
41
+ spec: OpenAPIV3.Document
42
+ schema: OpenAPIV3.SchemaObject | OpenAPIV3.ReferenceObject
43
+ }>()
44
+
45
+ const { t } = useTranslation()
46
+
47
+ const view = ref<'schema' | 'example'>('schema')
48
+
49
+ const exampleJson = computed(() => {
50
+ const example = generateExample(props.spec, props.schema)
51
+ return JSON.stringify(example, null, 2)
52
+ })
53
+ </script>
@@ -0,0 +1,77 @@
1
+ <template>
2
+ <div class="text-xs overflow-hidden">
3
+ <div
4
+ v-for="prop in properties"
5
+ :key="prop.name"
6
+ class="border-b border-gray-100 last:border-0"
7
+ >
8
+ <div class="flex items-baseline gap-2 py-1.5 min-w-0">
9
+ <button
10
+ v-if="hasNestedProperties(spec, prop.schema)"
11
+ type="button"
12
+ class="shrink-0 flex items-center gap-1 font-mono text-gray-title hover:text-gray-800"
13
+ @click="toggle(prop.name)"
14
+ >
15
+ <RiArrowRightSLine
16
+ class="size-3 text-gray-medium transition-transform"
17
+ :class="{ 'rotate-90': expanded.has(prop.name) }"
18
+ />
19
+ {{ prop.name }}
20
+ <span
21
+ v-if="prop.required"
22
+ class="text-red-600"
23
+ >*</span>
24
+ </button>
25
+ <span
26
+ v-else
27
+ class="font-mono text-gray-title pl-4"
28
+ >
29
+ {{ prop.name }}
30
+ <span
31
+ v-if="prop.required"
32
+ class="text-red-600"
33
+ >*</span>
34
+ </span>
35
+ <span class="font-mono text-gray-medium whitespace-nowrap">{{ prop.type }}</span>
36
+ <span
37
+ v-if="prop.description"
38
+ class="text-gray-medium truncate"
39
+ >{{ prop.description }}</span>
40
+ </div>
41
+ <div
42
+ v-if="expanded.has(prop.name) && hasNestedProperties(spec, prop.schema)"
43
+ class="pl-4 ml-1.5 border-l border-gray-200"
44
+ >
45
+ <SchemaTree
46
+ :spec="spec"
47
+ :schema="getNestedSchema(spec, prop.schema)!"
48
+ />
49
+ </div>
50
+ </div>
51
+ </div>
52
+ </template>
53
+
54
+ <script setup lang="ts">
55
+ import { computed, reactive } from 'vue'
56
+ import { RiArrowRightSLine } from '@remixicon/vue'
57
+ import { getSchemaProperties, hasNestedProperties, getNestedSchema } from './openapi'
58
+ import type { OpenAPIV3 } from 'openapi-types'
59
+
60
+ const props = defineProps<{
61
+ spec: OpenAPIV3.Document
62
+ schema: OpenAPIV3.SchemaObject | OpenAPIV3.ReferenceObject
63
+ }>()
64
+
65
+ const properties = computed(() => getSchemaProperties(props.spec, props.schema))
66
+
67
+ const expanded = reactive(new Set<string>())
68
+
69
+ function toggle(name: string) {
70
+ if (expanded.has(name)) {
71
+ expanded.delete(name)
72
+ }
73
+ else {
74
+ expanded.add(name)
75
+ }
76
+ }
77
+ </script>
@@ -0,0 +1,150 @@
1
+ import type { OpenAPIV3 } from 'openapi-types'
2
+
3
+ export interface Endpoint {
4
+ method: string
5
+ path: string
6
+ summary: string
7
+ tags: string[]
8
+ parameters: OpenAPIV3.ParameterObject[]
9
+ requestBody: OpenAPIV3.RequestBodyObject | null
10
+ responses: Record<string, OpenAPIV3.ResponseObject>
11
+ spec: OpenAPIV3.Document
12
+ }
13
+
14
+ export function resolveRef<T>(spec: OpenAPIV3.Document, obj: T | OpenAPIV3.ReferenceObject): T | null {
15
+ if (!obj || typeof obj !== 'object') return obj as T | null
16
+ if (!('$ref' in obj)) return obj as T
17
+ const path = (obj as OpenAPIV3.ReferenceObject).$ref.replace('#/', '').split('/')
18
+ let resolved: unknown = spec
19
+ for (const segment of path) {
20
+ if (resolved && typeof resolved === 'object') {
21
+ resolved = (resolved as Record<string, unknown>)[segment]
22
+ }
23
+ else {
24
+ return null
25
+ }
26
+ }
27
+ return resolved as T
28
+ }
29
+
30
+ export function getSchemaType(spec: OpenAPIV3.Document, schema?: OpenAPIV3.SchemaObject | OpenAPIV3.ReferenceObject): string {
31
+ if (!schema) return ''
32
+ const resolved = resolveRef<OpenAPIV3.SchemaObject>(spec, schema)
33
+ if (!resolved) return ''
34
+ if (resolved.type === 'array' && resolved.items) {
35
+ const itemType = getSchemaType(spec, resolved.items)
36
+ return `${itemType}[]`
37
+ }
38
+ if (resolved.format) return `${resolved.type} (${resolved.format})`
39
+ return resolved.type || ''
40
+ }
41
+
42
+ const CONTENT_TYPE_LABELS: Record<string, string> = {
43
+ 'application/json': 'JSON',
44
+ 'application/xml': 'XML',
45
+ 'application/x-www-form-urlencoded': 'Form',
46
+ 'multipart/form-data': 'Multipart',
47
+ 'text/plain': 'Text',
48
+ 'text/html': 'HTML',
49
+ 'text/csv': 'CSV',
50
+ 'application/octet-stream': 'Binary',
51
+ 'application/pdf': 'PDF',
52
+ }
53
+
54
+ export function contentTypeLabel(raw: string): string {
55
+ const base = raw.split(';')[0]!.trim()
56
+ return CONTENT_TYPE_LABELS[base] || base
57
+ }
58
+
59
+ export interface SchemaProperty {
60
+ name: string
61
+ type: string
62
+ description: string
63
+ required: boolean
64
+ schema: OpenAPIV3.SchemaObject | OpenAPIV3.ReferenceObject | undefined
65
+ }
66
+
67
+ export function getSchemaProperties(spec: OpenAPIV3.Document, schema?: OpenAPIV3.SchemaObject | OpenAPIV3.ReferenceObject): SchemaProperty[] {
68
+ if (!schema) return []
69
+ const resolved = resolveRef<OpenAPIV3.SchemaObject>(spec, schema)
70
+ if (!resolved?.properties) return []
71
+ const requiredFields = resolved.required || []
72
+ return Object.entries(resolved.properties).map(([name, propSchema]) => {
73
+ const prop = resolveRef<OpenAPIV3.SchemaObject>(spec, propSchema)
74
+ return {
75
+ name,
76
+ type: getSchemaType(spec, propSchema),
77
+ description: prop?.description || '',
78
+ required: requiredFields.includes(name),
79
+ schema: propSchema,
80
+ }
81
+ })
82
+ }
83
+
84
+ export function hasNestedProperties(spec: OpenAPIV3.Document, schema?: OpenAPIV3.SchemaObject | OpenAPIV3.ReferenceObject): boolean {
85
+ if (!schema) return false
86
+ const resolved = resolveRef<OpenAPIV3.SchemaObject>(spec, schema)
87
+ if (!resolved) return false
88
+ if (resolved.properties) return true
89
+ if (resolved.type === 'array' && resolved.items) {
90
+ return hasNestedProperties(spec, resolved.items)
91
+ }
92
+ return false
93
+ }
94
+
95
+ export function getNestedSchema(spec: OpenAPIV3.Document, schema?: OpenAPIV3.SchemaObject | OpenAPIV3.ReferenceObject): OpenAPIV3.SchemaObject | OpenAPIV3.ReferenceObject | undefined {
96
+ if (!schema) return undefined
97
+ const resolved = resolveRef<OpenAPIV3.SchemaObject>(spec, schema)
98
+ if (!resolved) return undefined
99
+ if (resolved.properties) return schema
100
+ if (resolved.type === 'array' && resolved.items) return resolved.items
101
+ return undefined
102
+ }
103
+
104
+ const MAX_EXAMPLE_DEPTH = 4
105
+
106
+ function defaultForType(type?: string, format?: string): unknown {
107
+ switch (type) {
108
+ case 'string':
109
+ if (format === 'date') return '2024-01-01'
110
+ if (format === 'date-time') return '2024-01-01T00:00:00Z'
111
+ if (format === 'email') return 'user@example.com'
112
+ if (format === 'uri' || format === 'url') return 'https://example.com'
113
+ return 'string'
114
+ case 'integer': return 0
115
+ case 'number': return 0.0
116
+ case 'boolean': return true
117
+ case 'null': return null
118
+ default: return {}
119
+ }
120
+ }
121
+
122
+ export function generateExample(spec: OpenAPIV3.Document, schema?: OpenAPIV3.SchemaObject | OpenAPIV3.ReferenceObject, depth = 0): unknown {
123
+ if (!schema || depth > MAX_EXAMPLE_DEPTH) return undefined
124
+ const resolved = resolveRef<OpenAPIV3.SchemaObject>(spec, schema)
125
+ if (!resolved) return undefined
126
+
127
+ if (resolved.example !== undefined) return resolved.example
128
+
129
+ if (resolved.type === 'array' && resolved.items) {
130
+ const item = generateExample(spec, resolved.items, depth + 1)
131
+ return item !== undefined ? [item] : []
132
+ }
133
+
134
+ if (resolved.properties) {
135
+ const obj: Record<string, unknown> = {}
136
+ for (const [name, propSchema] of Object.entries(resolved.properties)) {
137
+ const prop = resolveRef<OpenAPIV3.SchemaObject>(spec, propSchema)
138
+ if (prop?.example !== undefined) {
139
+ obj[name] = prop.example
140
+ }
141
+ else {
142
+ const val = generateExample(spec, propSchema, depth + 1)
143
+ if (val !== undefined) obj[name] = val
144
+ }
145
+ }
146
+ return obj
147
+ }
148
+
149
+ return defaultForType(resolved.type as string, resolved.format)
150
+ }
@@ -7,7 +7,7 @@
7
7
  <component
8
8
  :is="as"
9
9
  class="mb-0 truncate flex-initial"
10
- :class="[colorClass, { 'text-xs': size === 'xs', 'text-sm': size === 'sm', 'text-base': size === 'base' }]"
10
+ :class="[colorClass, { 'text-xs': size === 'xs', 'text-sm': size === 'sm', 'text-base': size === 'base', 'text-xl sm:text-2xl': size === 'xl' }]"
11
11
  >
12
12
  {{ organization.name }}
13
13
  <small
@@ -24,6 +24,7 @@
24
24
  'size-3': size === 'xs',
25
25
  'size-4': size === 'sm',
26
26
  'size-5': size === 'base',
27
+ 'size-6': size === 'xl',
27
28
  }"
28
29
  :aria-label="t(`L'identité de ce service public est certifiée par {certifier}`, { certifier: config.name })"
29
30
  aria-hidden="true"
@@ -53,7 +54,7 @@ withDefaults(defineProps<{
53
54
  organization: Organization | OrganizationReference
54
55
  showAcronym?: boolean
55
56
  showType?: boolean
56
- size?: 'base' | 'sm' | 'xs'
57
+ size?: 'xl' | 'base' | 'sm' | 'xs'
57
58
  colorClass?: string
58
59
  as?: string
59
60
  }>(), {
@@ -101,6 +101,7 @@
101
101
 
102
102
  <script setup lang="ts">
103
103
  import { computed, useTemplateRef } from 'vue'
104
+ import { useRoute } from 'vue-router'
104
105
  import { useTranslation } from '../composables/useTranslation'
105
106
 
106
107
  type Props = {
@@ -112,10 +113,6 @@ type Props = {
112
113
  * The page size.
113
114
  */
114
115
  pageSize?: number
115
- /**
116
- * Customize the links used
117
- */
118
- link?: (page: number) => string
119
116
  /**
120
117
  * The number of items in the collection. It's used to calculated the number of pages.
121
118
  */
@@ -174,6 +171,7 @@ function getVisiblePages(currentPage: number, pageCount: number) {
174
171
  }
175
172
 
176
173
  const { t } = useTranslation()
174
+ const route = useRoute()
177
175
  const pageCount = computed(() => Math.ceil(props.totalResults / props.pageSize))
178
176
  const visiblePages = computed(() => getVisiblePages(props.page, pageCount.value))
179
177
 
@@ -211,6 +209,11 @@ function getHref(forPage: number) {
211
209
  if (forPage < 1 || forPage > pageCount.value) {
212
210
  return undefined
213
211
  }
214
- return props.page === forPage ? undefined : (props.link ? props.link(forPage) : '#')
212
+ if (props.page === forPage) {
213
+ return undefined
214
+ }
215
+ const search = new URLSearchParams(route.query as Record<string, string>)
216
+ search.set('page', forPage.toFixed(0))
217
+ return `${route.path}?${search.toString()}`
215
218
  }
216
219
  </script>
@@ -3,7 +3,7 @@
3
3
  <div
4
4
  ref="readMoreRef"
5
5
  class="overflow-hidden"
6
- :style="{ height: containerHeight + 'px' }"
6
+ :style="{ height: readMoreRequired ? containerHeight + 'px' : 'auto' }"
7
7
  >
8
8
  <div ref="containerRef">
9
9
  <slot />
@@ -9,21 +9,15 @@
9
9
  border: none;"
10
10
  />
11
11
  </div>
12
- <SimpleBanner
13
- v-else
14
- type="warning"
15
- class="flex items-center space-x-2"
16
- >
17
- <RiErrorWarningLine class="shrink-0 size-6" />
18
- <span>{{ t("Erreur lors de l'affichage de l'aperçu.") }}</span>
19
- </SimpleBanner>
12
+ <PreviewUnavailable v-else>
13
+ {{ t("L'aperçu de ce fichier n'a pas pu être chargé. Téléchargez-le depuis l'onglet Téléchargements.") }}
14
+ </PreviewUnavailable>
20
15
  </div>
21
16
  </template>
22
17
 
23
18
  <script setup lang="ts">
24
19
  import { computed } from 'vue'
25
- import { RiErrorWarningLine } from '@remixicon/vue'
26
- import SimpleBanner from '../SimpleBanner.vue'
20
+ import PreviewUnavailable from './PreviewUnavailable.vue'
27
21
  import type { Resource } from '../../types/resources'
28
22
  import type { Dataset, DatasetV2 } from '../../types/datasets'
29
23
  import { useTranslation } from '../../composables/useTranslation'