@datagouv/components-next 1.0.2-dev.19 → 1.0.2-dev.190

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 (156) hide show
  1. package/README.md +7 -6
  2. package/assets/main.css +4 -0
  3. package/dist/{Control-DuZJdKV_.js → Control-B9WQxlpJ.js} +1 -1
  4. package/dist/{Datafair.client-Ds3VQrRi.js → Datafair.client-VsEj9A00.js} +9 -9
  5. package/dist/{Event--kp8kMdJ.js → Event-iXDrp-fy.js} +31 -31
  6. package/dist/{Image-34hvypZI.js → Image-mNMBOofs.js} +9 -9
  7. package/dist/ImagePreview.client-cv32--L0.js +36 -0
  8. package/dist/JsonPreview.client-JmyzznjY.js +40 -0
  9. package/dist/{Map-BjUnLyj8.js → Map-BfqKMw0S.js} +1739 -1599
  10. package/dist/{MapContainer.client-B2BijMx5.js → MapContainer.client-BxGjbFJV.js} +41 -42
  11. package/dist/{OSM-s40W6sQ2.js → OSM-CcrUhItr.js} +15 -23
  12. package/dist/{PdfPreview.client-DJBMzrlC.js → PdfPreview.client-CkrjnmJP.js} +835 -856
  13. package/dist/Pmtiles.client-EAekMgpr.js +26333 -0
  14. package/dist/PreviewWrapper.vue_vue_type_script_setup_true_lang-B0OeAb39.js +60 -0
  15. package/dist/{ScaleLine-KW-nXqp3.js → ScaleLine-VGQ7nkMS.js} +2 -2
  16. package/dist/{Tile-DbNFNPfU.js → Tile-CSpn0Ca8.js} +160 -163
  17. package/dist/{TileImage-BsXBxMtq.js → TileImage-CpbaEFwd.js} +143 -131
  18. package/dist/{View-BR92hTWP.js → View-BYBpt-AU.js} +483 -422
  19. package/dist/XmlPreview.client-WcOMRUAD.js +34 -0
  20. package/dist/{common-PJfpC179.js → common-BoeTUnDZ.js} +52 -52
  21. package/dist/components-next.css +1 -52
  22. package/dist/components-next.js +194 -149
  23. package/dist/components.css +2 -2
  24. package/dist/{index-BFQX7Ccz.js → index-DLsJxwiN.js} +21842 -15810
  25. package/dist/{leaflet-src-7m1mB8LI.js → leaflet-src-D0FPslrZ.js} +185 -187
  26. package/dist/{main-vqhkVhVS.js → main-HzoTSLAM.js} +41511 -73246
  27. package/dist/{proj-DsetBcW7.js → proj-DxGbobp7.js} +662 -626
  28. package/dist/{text-clamp.esm-B5kW_XMt.js → text-clamp.esm-DVseBqZZ.js} +4 -4
  29. package/dist/{tilecoord-Db24Px13.js → tilecoord-DvX7WWiA.js} +273 -264
  30. package/dist/{vue3-json-viewer-BXwup7nO.js → vue3-json-viewer-CJLQFzXZ.js} +10 -16
  31. package/dist/{vue3-xml-viewer.common-BcNJo35o.js → vue3-xml-viewer.common-iq0K0tIG.js} +16 -16
  32. package/package.json +47 -38
  33. package/src/chart.ts +5 -0
  34. package/src/components/ActivityList/ActivityList.vue +3 -2
  35. package/src/components/AppLink.vue +3 -0
  36. package/src/components/BannerAction.vue +6 -2
  37. package/src/components/Chart/ChartViewer.vue +320 -0
  38. package/src/components/Chart/ChartViewerWrapper.vue +182 -0
  39. package/src/components/CopyButton.vue +6 -2
  40. package/src/components/DataserviceCard.vue +9 -0
  41. package/src/components/DataserviceQuality.vue +82 -0
  42. package/src/components/DataserviceQualityInline.vue +31 -0
  43. package/src/components/DataserviceQualityTooltipContent.vue +79 -0
  44. package/src/components/DatasetCard.vue +9 -4
  45. package/src/components/DatasetQuality.vue +11 -11
  46. package/src/components/DatasetQualityInline.vue +2 -2
  47. package/src/components/DatasetQualityTooltipContent.vue +1 -1
  48. package/src/components/Form/Listbox.vue +101 -0
  49. package/src/components/Form/SchemaSelect.vue +2 -0
  50. package/src/components/InfiniteLoader.vue +53 -0
  51. package/src/components/ObjectCardHeader.vue +11 -4
  52. package/src/components/OpenApiViewer/ContentTypeSelect.vue +48 -0
  53. package/src/components/OpenApiViewer/EndpointRequest.vue +164 -0
  54. package/src/components/OpenApiViewer/EndpointResponses.vue +149 -0
  55. package/src/components/OpenApiViewer/OpenApiViewer.vue +308 -0
  56. package/src/components/OpenApiViewer/SchemaPanel.vue +53 -0
  57. package/src/components/OpenApiViewer/SchemaTree.vue +77 -0
  58. package/src/components/OpenApiViewer/openapi.ts +150 -0
  59. package/src/components/OrganizationNameWithCertificate.vue +3 -2
  60. package/src/components/Pagination.vue +23 -58
  61. package/src/components/RadioInput.vue +7 -2
  62. package/src/components/ResourceAccordion/DataStructure.vue +11 -33
  63. package/src/components/ResourceAccordion/Datafair.client.vue +1 -1
  64. package/src/components/ResourceAccordion/Downloads.vue +160 -0
  65. package/src/components/ResourceAccordion/ImagePreview.client.vue +48 -0
  66. package/src/components/ResourceAccordion/JsonPreview.client.vue +23 -104
  67. package/src/components/ResourceAccordion/MapContainer.client.vue +2 -11
  68. package/src/components/ResourceAccordion/Metadata.vue +1 -2
  69. package/src/components/ResourceAccordion/PdfPreview.client.vue +58 -97
  70. package/src/components/ResourceAccordion/PdfSkeleton.vue +44 -0
  71. package/src/components/ResourceAccordion/Pmtiles.client.vue +28 -13
  72. package/src/components/ResourceAccordion/Preview.vue +11 -11
  73. package/src/components/ResourceAccordion/PreviewWrapper.vue +89 -0
  74. package/src/components/ResourceAccordion/ResourceAccordion.vue +23 -114
  75. package/src/components/ResourceAccordion/XmlPreview.client.vue +16 -98
  76. package/src/components/ResourceExplorer/ResourceExplorer.vue +102 -210
  77. package/src/components/ResourceExplorer/ResourceExplorerHeader.vue +74 -0
  78. package/src/components/ResourceExplorer/ResourceExplorerSidebar.vue +103 -71
  79. package/src/components/ResourceExplorer/ResourceExplorerViewer.vue +143 -291
  80. package/src/components/ResourceExplorer/ResourceMainAction.vue +240 -0
  81. package/src/components/ResourceExplorer/ResourceSelector.vue +51 -0
  82. package/src/components/ResourceExplorer/ResourceViewerHeader.vue +115 -0
  83. package/src/components/ResourceExplorer/ResourceViewerSkeleton.vue +94 -0
  84. package/src/components/ResourceListItem.vue +154 -0
  85. package/src/components/ReuseCard.vue +14 -6
  86. package/src/components/ReuseDetails.vue +2 -2
  87. package/src/components/ReuseHorizontalCard.vue +2 -2
  88. package/src/components/SchemaCard.vue +10 -1
  89. package/src/components/Search/Filter/AccessTypeFilter.vue +2 -2
  90. package/src/components/Search/GlobalSearch.vue +220 -117
  91. package/src/components/Search/SearchInput.vue +5 -4
  92. package/src/components/Search/Sidemenu.vue +4 -3
  93. package/src/components/TabularExplorer/TabularActiveFilters.vue +79 -0
  94. package/src/components/TabularExplorer/TabularCell.vue +50 -0
  95. package/src/components/TabularExplorer/TabularCellPopover.vue +170 -0
  96. package/src/components/TabularExplorer/TabularColumnsMenu.vue +112 -0
  97. package/src/components/TabularExplorer/TabularExplorer.vue +299 -0
  98. package/src/components/TabularExplorer/TabularFilterContent.vue +362 -0
  99. package/src/components/TabularExplorer/TabularFilterPopover.vue +106 -0
  100. package/src/components/TabularExplorer/TabularMobileFilterButton.vue +21 -0
  101. package/src/components/TabularExplorer/TabularMobileFilters.vue +150 -0
  102. package/src/components/TabularExplorer/TabularRowsInfo.vue +31 -0
  103. package/src/components/TabularExplorer/TabularSkeleton.vue +92 -0
  104. package/src/components/TabularExplorer/TabularTable.vue +481 -0
  105. package/src/components/TabularExplorer/TabularToolbar.vue +25 -0
  106. package/src/components/TabularExplorer/types.ts +81 -0
  107. package/src/components/TabularExplorer/useColumnMetadata.ts +98 -0
  108. package/src/components/TabularExplorer/useTabularContext.ts +82 -0
  109. package/src/composables/useActiveDescendant.ts +5 -0
  110. package/src/composables/useDatasetResources.ts +164 -0
  111. package/src/composables/useHasTabularData.ts +15 -1
  112. package/src/composables/useMetrics.ts +1 -1
  113. package/src/composables/useResizable.ts +46 -0
  114. package/src/composables/useResourceCapabilities.ts +48 -40
  115. package/src/composables/useSearchFilter.ts +120 -0
  116. package/src/composables/useStableQueryParams.ts +38 -6
  117. package/src/composables/useTabularProfile.ts +70 -0
  118. package/src/composables/useTranslation.ts +24 -9
  119. package/src/config.ts +21 -3
  120. package/src/functions/activities.ts +3 -3
  121. package/src/functions/api.ts +20 -42
  122. package/src/functions/api.types.ts +1 -0
  123. package/src/functions/charts.ts +99 -0
  124. package/src/functions/datasets.ts +0 -17
  125. package/src/functions/dates.ts +3 -2
  126. package/src/functions/helpers.ts +15 -0
  127. package/src/functions/metrics.ts +63 -60
  128. package/src/functions/paginate.ts +46 -0
  129. package/src/functions/resourceCapabilities.ts +34 -0
  130. package/src/functions/resources.ts +136 -1
  131. package/src/functions/schemas.ts +27 -0
  132. package/src/functions/tabular.ts +214 -0
  133. package/src/functions/tabularApi.ts +96 -11
  134. package/src/main.ts +117 -14
  135. package/src/types/dataservices.ts +17 -0
  136. package/src/types/organizations.ts +10 -0
  137. package/src/types/pages.ts +0 -5
  138. package/src/types/posts.ts +2 -2
  139. package/src/types/reports.ts +5 -1
  140. package/src/types/resources.ts +0 -1
  141. package/src/types/reuses.ts +12 -1
  142. package/src/types/search.ts +63 -1
  143. package/src/types/site.ts +5 -3
  144. package/src/types/ui.ts +2 -0
  145. package/src/types/users.ts +2 -1
  146. package/src/types/visualizations.ts +93 -0
  147. package/assets/swagger-themes/newspaper.css +0 -1670
  148. package/dist/JsonPreview.client-CYxmz0yV.js +0 -72
  149. package/dist/Pmtiles.client-C_hvRDuy.js +0 -25185
  150. package/dist/Swagger.client-B4y0hXME.js +0 -4
  151. package/dist/XmlPreview.client-LETEfNBH.js +0 -64
  152. package/src/components/ResourceAccordion/Swagger.client.vue +0 -48
  153. package/src/functions/pagination.ts +0 -9
  154. /package/src/components/{DatasetQualityItem.vue → QualityItem.vue} +0 -0
  155. /package/src/components/{DatasetQualityItemWarning.vue → QualityItemWarning.vue} +0 -0
  156. /package/src/components/{DatasetQualityScore.vue → QualityScore.vue} +0 -0
@@ -1,5 +1,6 @@
1
1
  import type { User } from './users'
2
2
  import type { Badges } from './badges'
3
+ import type { PageBloc } from './pages'
3
4
 
4
5
  export type MemberRole = 'admin' | 'editor' | 'partial_editor'
5
6
 
@@ -68,4 +69,13 @@ export type Organization = {
68
69
  reuses_by_months: Record<string, number>
69
70
  views: number
70
71
  }
72
+ // Editorial blocs powering the organization "Présentation" tab. Excluded from
73
+ // the default API read mask, so only present when requested with X-Fields.
74
+ // Read through the API's `public_presentation_blocs`: hidden from the public until
75
+ // published, but always returned to organization administrators.
76
+ presentation_blocs?: Array<PageBloc>
77
+ // Publication date of the blocs. `null` means draft (never public); a set date
78
+ // means published. Like `presentation_blocs`, only present when requested with
79
+ // X-Fields.
80
+ presentation_blocs_published_at?: string | null
71
81
  }
@@ -2,11 +2,6 @@ import type { DatasetV2 } from './datasets'
2
2
  import type { Dataservice } from './dataservices'
3
3
  import type { Reuse } from './reuses'
4
4
 
5
- export type Page = {
6
- id: string
7
- blocs: Array<PageBloc>
8
- }
9
-
10
5
  export type BlocWithTitle = {
11
6
  title: string
12
7
  subtitle: string | null
@@ -1,12 +1,12 @@
1
1
  import type { Dataset } from './datasets'
2
- import type { Page } from './pages'
2
+ import type { PageBloc } from './pages'
3
3
  import type { Reuse } from './reuses'
4
4
  import type { User } from './users'
5
5
 
6
6
  export type Post = {
7
7
  body_type: 'markdown' | 'html' | 'blocs'
8
+ blocs: Array<PageBloc>
8
9
  content: string
9
- content_as_page: Page | null
10
10
  created_at: string
11
11
  credit_to: string
12
12
  credit_url: string
@@ -1,7 +1,7 @@
1
1
  import type { User } from './users'
2
2
 
3
3
  export type ReportSubject = {
4
- class: 'Discussion' | 'Dataservice' | 'Dataset' | 'Organization' | 'Reuse'
4
+ class: 'Discussion' | 'Dataservice' | 'Dataset' | 'Organization' | 'Reuse' | 'User'
5
5
  id: string
6
6
  }
7
7
 
@@ -16,11 +16,15 @@ 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
29
+ callbacks_count: number
26
30
  }
@@ -46,7 +46,6 @@ export type OgcLayerInfo = { name: string, default_crs: string | null }
46
46
 
47
47
  export type WfsMetadata = {
48
48
  format: string
49
- layers: Array<OgcLayerInfo>
50
49
  version: string
51
50
  detected_layer: OgcLayerInfo | null
52
51
  output_formats: Array<string>
@@ -1,5 +1,5 @@
1
1
  import type { Owned, OwnedWithId } from './owned'
2
- import type { Dataset } from './datasets'
2
+ import type { Dataset, Rel } from './datasets'
3
3
  import type { Badges } from './badges'
4
4
  import type { Dataservice } from './dataservices'
5
5
 
@@ -51,6 +51,17 @@ export type Reuse = BaseReuse & {
51
51
  permissions: { edit: boolean, delete: boolean }
52
52
  }
53
53
 
54
+ /**
55
+ * Lightweight reuse returned by the listing endpoints (`/api/2/reuses/` and
56
+ * `/api/2/reuses/search/`): the `datasets` and `dataservices` reference lists
57
+ * are replaced by links to their respective listing endpoints filtered on this
58
+ * reuse, so that listing reuses does not dereference every linked dataset.
59
+ */
60
+ export type ReuseV2 = Owned & Omit<Reuse, 'datasets' | 'dataservices'> & {
61
+ datasets: Rel
62
+ dataservices: Rel
63
+ }
64
+
54
65
  export type ReuseType = {
55
66
  id: string
56
67
  label: string
@@ -1,5 +1,11 @@
1
+ import type { Component } from 'vue'
1
2
  import type { PaginatedArray } from './api'
2
3
  import type { AccessType } from './access_types'
4
+ import type { Dataset } from './datasets'
5
+ import type { Dataservice } from './dataservices'
6
+ import type { Organization } from './organizations'
7
+ import type { ReuseV2 } from './reuses'
8
+ import type { TopicV2 } from './topics'
3
9
  import type {
4
10
  CERTIFIED,
5
11
  PUBLIC_SERVICE,
@@ -291,46 +297,86 @@ export type SortOption<Sort extends string> = {
291
297
 
292
298
  export type DatasetSearchConfig = {
293
299
  class: 'datasets'
300
+ key?: string
294
301
  name?: string
302
+ icon?: Component | string
303
+ placeholder?: string | null
295
304
  hiddenFilters?: HiddenFilter<DatasetSearchFilters>[]
296
305
  basicFilters?: (keyof DatasetSearchFilters)[]
297
306
  advancedFilters?: (keyof DatasetSearchFilters)[]
298
307
  sortOptions?: SortOption<DatasetSearchSort>[]
308
+ defaultSort?: DatasetSearchSort
299
309
  }
300
310
 
301
311
  export type DataserviceSearchConfig = {
302
312
  class: 'dataservices'
313
+ key?: string
303
314
  name?: string
315
+ icon?: Component | string
316
+ placeholder?: string | null
304
317
  hiddenFilters?: HiddenFilter<DataserviceSearchFilters>[]
305
318
  basicFilters?: (keyof DataserviceSearchFilters)[]
306
319
  advancedFilters?: (keyof DataserviceSearchFilters)[]
307
320
  sortOptions?: SortOption<DataserviceSearchSort>[]
321
+ defaultSort?: DataserviceSearchSort
308
322
  }
309
323
 
310
324
  export type ReuseSearchConfig = {
311
325
  class: 'reuses'
326
+ key?: string
312
327
  name?: string
328
+ icon?: Component | string
329
+ placeholder?: string | null
313
330
  hiddenFilters?: HiddenFilter<ReuseSearchFilters>[]
314
331
  basicFilters?: (keyof ReuseSearchFilters)[]
315
332
  advancedFilters?: (keyof ReuseSearchFilters)[]
316
333
  sortOptions?: SortOption<ReuseSearchSort>[]
334
+ defaultSort?: ReuseSearchSort
317
335
  }
318
336
 
319
337
  export type OrganizationSearchConfig = {
320
338
  class: 'organizations'
339
+ key?: string
321
340
  name?: string
341
+ icon?: Component | string
342
+ placeholder?: string | null
322
343
  hiddenFilters?: HiddenFilter<OrganizationSearchFilters>[]
323
344
  basicFilters?: (keyof OrganizationSearchFilters)[]
324
345
  advancedFilters?: (keyof OrganizationSearchFilters)[]
325
346
  sortOptions?: SortOption<OrganizationSearchSort>[]
347
+ defaultSort?: OrganizationSearchSort
326
348
  }
327
349
 
328
- export type SearchTypeConfig = DatasetSearchConfig | DataserviceSearchConfig | ReuseSearchConfig | OrganizationSearchConfig
350
+ export type TopicSearchConfig = {
351
+ class: 'topics'
352
+ key?: string
353
+ name?: string
354
+ icon?: Component | string
355
+ placeholder?: string | null
356
+ hiddenFilters?: HiddenFilter<TopicSearchFilters>[]
357
+ basicFilters?: (keyof TopicSearchFilters)[]
358
+ advancedFilters?: (keyof TopicSearchFilters)[]
359
+ sortOptions?: SortOption<TopicSearchSort>[]
360
+ defaultSort?: TopicSearchSort
361
+ }
362
+
363
+ export type SearchTypeConfig = DatasetSearchConfig | DataserviceSearchConfig | ReuseSearchConfig | OrganizationSearchConfig | TopicSearchConfig
364
+
365
+ export type BuiltInFilterKey = keyof DatasetSearchFilters | keyof DataserviceSearchFilters | keyof ReuseSearchFilters | keyof OrganizationSearchFilters | keyof TopicSearchFilters
329
366
 
330
367
  export type SearchType = SearchTypeConfig['class']
331
368
 
332
369
  export type GlobalSearchConfig = SearchTypeConfig[]
333
370
 
371
+ // Maps each search class to its concrete response shape.
372
+ export type SearchResponseByClass = {
373
+ datasets: DatasetSearchResponse<Dataset>
374
+ dataservices: DataserviceSearchResponse<Dataservice>
375
+ reuses: ReuseSearchResponse<ReuseV2>
376
+ organizations: OrganizationSearchResponse<Organization>
377
+ topics: TopicSearchResponse<TopicV2>
378
+ }
379
+
334
380
  // Helper functions for default configs
335
381
 
336
382
  export const defaultDatasetSortOptions: SortOption<DatasetSearchSort>[] = [
@@ -397,11 +443,27 @@ export function getDefaultOrganizationConfig(overrides?: Partial<Omit<Organizati
397
443
  }
398
444
  }
399
445
 
446
+ export const defaultTopicSortOptions: SortOption<TopicSearchSort>[] = [
447
+ { value: '-created', label: 'Date de création' },
448
+ { value: '-last_modified', label: 'Dernière mise à jour' },
449
+ ]
450
+
451
+ export function getDefaultTopicConfig(overrides?: Partial<Omit<TopicSearchConfig, 'class'>>): TopicSearchConfig {
452
+ return {
453
+ class: 'topics',
454
+ basicFilters: ['last_update_range', 'producer_type'],
455
+ advancedFilters: ['organization', 'tag'],
456
+ sortOptions: defaultTopicSortOptions,
457
+ ...overrides,
458
+ }
459
+ }
460
+
400
461
  export function getDefaultGlobalSearchConfig(): GlobalSearchConfig {
401
462
  return [
402
463
  getDefaultDatasetConfig(),
403
464
  getDefaultDataserviceConfig(),
404
465
  getDefaultReuseConfig(),
405
466
  getDefaultOrganizationConfig(),
467
+ getDefaultTopicConfig(),
406
468
  ]
407
469
  }
package/src/types/site.ts CHANGED
@@ -1,9 +1,11 @@
1
+ import type { PageBloc } from './pages'
2
+
1
3
  export type Site = {
2
4
  id: string
3
5
  title: string
4
- datasets_page: string | null
5
- reuses_page: string | null
6
- dataservices_page: string | null
6
+ datasets_blocs: Array<PageBloc>
7
+ reuses_blocs: Array<PageBloc>
8
+ dataservices_blocs: Array<PageBloc>
7
9
  version: string
8
10
  metrics: {
9
11
  'dataservices': number
package/src/types/ui.ts CHANGED
@@ -1,3 +1,5 @@
1
1
  export type WellType = 'primary' | 'secondary'
2
2
 
3
3
  export type Weight = 'light' | 'regular' | 'semi-bold' | 'bold' | 'heavy'
4
+
5
+ export type TitleTag = 'h1' | 'h2' | 'h3' | 'h4' | 'h5' | 'h6' | 'p'
@@ -21,13 +21,14 @@ 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
28
27
  roles?: Array<string>
29
28
  organizations: Array<OrganizationReference>
30
29
  last_login_at: string | null
30
+ password_rotation_demanded: string | null
31
+ password_rotation_performed: string | null
31
32
  since: string | null
32
33
  metrics: {
33
34
  datasets: number
@@ -0,0 +1,93 @@
1
+ import type { TabularAggregateType } from '../functions/tabularApi'
2
+ import type { Owned, OwnedWithId } from './owned'
3
+ import type { ColumnType } from '../components/TabularExplorer/types'
4
+
5
+ export type FilterCondition = 'exact' | 'differs' | 'is_null' | 'is_not_null' | 'greater' | 'less' | 'strictly_greater' | 'strictly_less'
6
+ export type Filter = {
7
+ _cls: 'Filter'
8
+ column: string
9
+ condition: FilterCondition
10
+ value: string | null
11
+ }
12
+
13
+ export type AndFilters = {
14
+ _cls: 'AndFilters'
15
+ filters: Array<Filter | AndFilters>
16
+ }
17
+
18
+ export type GenericFilter = Filter | AndFilters
19
+
20
+ export type XAxisType = 'discrete' | 'continuous'
21
+
22
+ export type XAxisSortBy = 'axis_x' | 'axis_y'
23
+
24
+ export type SortDirection = 'asc' | 'desc'
25
+
26
+ export type XAxis = {
27
+ column_x: string
28
+ sort_x_by: XAxisSortBy | null
29
+ sort_x_direction: SortDirection | null
30
+ type: XAxisType
31
+ }
32
+
33
+ export type CombinedSort = '' | 'axis_x-asc' | 'axis_x-desc' | 'axis_y-asc' | 'axis_y-desc'
34
+
35
+ export type XAxisForm = Omit<XAxis, 'sort_x_by' | 'sort_x_direction'> & { sort_combined: CombinedSort }
36
+
37
+ export type UnitPosition = 'prefix' | 'suffix'
38
+
39
+ export type YAxis = {
40
+ min: number | null
41
+ max: number | null
42
+ label: string | null
43
+ unit: string | null
44
+ unit_position: UnitPosition | null
45
+ }
46
+
47
+ export type DataSeriesType = 'line' | 'histogram'
48
+
49
+ export type DataSeries = {
50
+ type: DataSeriesType
51
+ column_y: string
52
+ aggregate_y: TabularAggregateType | null
53
+ resource_id: string
54
+ column_x_name_override: string | null
55
+ filters: GenericFilter | null
56
+ }
57
+
58
+ // Type for form where aggregate_y can be empty string for select binding
59
+ export type DataSeriesForm = Omit<DataSeries, 'aggregate_y'> & { aggregate_y: TabularAggregateType | '' | null }
60
+
61
+ export type Chart = Owned & {
62
+ id: string
63
+ title: string
64
+ slug: string
65
+ description: string
66
+ private: boolean
67
+ created_at: string
68
+ last_modified: string
69
+ deleted_at: string | null
70
+ uri: string
71
+ page: string
72
+ x_axis: XAxis
73
+ y_axis: YAxis
74
+ series: Array<DataSeries>
75
+ extras: Record<string, unknown>
76
+ permissions: { delete: boolean, edit: boolean, read: boolean }
77
+ metrics: {
78
+ views: number
79
+ }
80
+ }
81
+
82
+ export type ChartForApi = OwnedWithId & Pick<Chart, 'title' | 'description' | 'private' | 'x_axis' | 'y_axis' | 'series' | 'extras'>
83
+
84
+ export type ChartForm = Omit<ChartForApi, 'x_axis' | 'series' | 'owner' | 'organization'> & {
85
+ owned: OwnedWithId
86
+ x_axis: XAxisForm
87
+ series: Array<DataSeriesForm>
88
+ chart_type?: DataSeriesType | null
89
+ filter: GenericFilter | null
90
+ }
91
+
92
+ export type ColumnDefinition = { name: string, type: ColumnType, min?: number, max?: number }
93
+ export type ColumnsDefinition = Record<string, Array<ColumnDefinition>>