@datagouv/components-next 1.0.2-dev.7 → 1.0.2-dev.71

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 (83) hide show
  1. package/assets/main.css +4 -0
  2. package/dist/Datafair.client-BzW-ctDf.js +30 -0
  3. package/dist/JsonPreview.client-BfMSzR07.js +40 -0
  4. package/dist/{MapContainer.client-DRkAmdOc.js → MapContainer.client-CLs-im9i.js} +35 -38
  5. package/dist/{PdfPreview.client-C-w6-w44.js → PdfPreview.client-C13PQCU_.js} +822 -865
  6. package/dist/{Pmtiles.client-BR7_ldHY.js → Pmtiles.client-CL7PXXDl.js} +574 -579
  7. package/dist/PreviewWrapper.vue_vue_type_script_setup_true_lang-C6XnsZ-7.js +61 -0
  8. package/dist/XmlPreview.client-KaENrbbG.js +34 -0
  9. package/dist/components-next.css +3 -3
  10. package/dist/components-next.js +166 -148
  11. package/dist/components.css +1 -1
  12. package/dist/{index-SrYZwgCT.js → index-C7WVVGgD.js} +1 -1
  13. package/dist/{main-B2kXxWRG.js → main-K-42Oe8-.js} +91315 -75834
  14. package/dist/{vue3-xml-viewer.common-BRxsqI9j.js → vue3-xml-viewer.common-sHPSE-jD.js} +1 -1
  15. package/package.json +16 -10
  16. package/src/components/ActivityList/ActivityList.vue +0 -2
  17. package/src/components/Chart/ChartViewer.vue +226 -0
  18. package/src/components/Chart/ChartViewerWrapper.vue +170 -0
  19. package/src/components/Form/Listbox.vue +101 -0
  20. package/src/components/Form/SearchableSelect.vue +2 -1
  21. package/src/components/InfiniteLoader.vue +53 -0
  22. package/src/components/OpenApiViewer/ContentTypeSelect.vue +48 -0
  23. package/src/components/OpenApiViewer/EndpointRequest.vue +164 -0
  24. package/src/components/OpenApiViewer/EndpointResponses.vue +149 -0
  25. package/src/components/OpenApiViewer/OpenApiViewer.vue +308 -0
  26. package/src/components/OpenApiViewer/SchemaPanel.vue +53 -0
  27. package/src/components/OpenApiViewer/SchemaTree.vue +77 -0
  28. package/src/components/OpenApiViewer/openapi.ts +150 -0
  29. package/src/components/OrganizationNameWithCertificate.vue +3 -2
  30. package/src/components/Pagination.vue +8 -5
  31. package/src/components/ReadMore.vue +1 -1
  32. package/src/components/ResourceAccordion/Datafair.client.vue +4 -10
  33. package/src/components/ResourceAccordion/JsonPreview.client.vue +23 -121
  34. package/src/components/ResourceAccordion/MapContainer.client.vue +7 -11
  35. package/src/components/ResourceAccordion/Metadata.vue +1 -2
  36. package/src/components/ResourceAccordion/PdfPreview.client.vue +24 -103
  37. package/src/components/ResourceAccordion/Pmtiles.client.vue +5 -10
  38. package/src/components/ResourceAccordion/Preview.vue +16 -21
  39. package/src/components/ResourceAccordion/PreviewLoader.vue +1 -2
  40. package/src/components/ResourceAccordion/PreviewUnavailable.vue +22 -0
  41. package/src/components/ResourceAccordion/PreviewWrapper.vue +82 -0
  42. package/src/components/ResourceAccordion/ResourceAccordion.vue +5 -7
  43. package/src/components/ResourceAccordion/XmlPreview.client.vue +16 -115
  44. package/src/components/ResourceExplorer/ResourceExplorer.vue +81 -13
  45. package/src/components/ResourceExplorer/ResourceExplorerSidebar.vue +2 -2
  46. package/src/components/ResourceExplorer/ResourceExplorerViewer.vue +30 -11
  47. package/src/components/Search/GlobalSearch.vue +173 -108
  48. package/src/components/Search/SearchInput.vue +3 -3
  49. package/src/components/TabularExplorer/TabularCell.vue +51 -0
  50. package/src/components/TabularExplorer/TabularCellPopover.vue +170 -0
  51. package/src/components/TabularExplorer/TabularExplorer.vue +870 -0
  52. package/src/components/TabularExplorer/TabularFilterContent.vue +351 -0
  53. package/src/components/TabularExplorer/TabularFilterPopover.vue +111 -0
  54. package/src/components/TabularExplorer/types.ts +83 -0
  55. package/src/composables/useHasTabularData.ts +6 -0
  56. package/src/composables/useResourceCapabilities.ts +1 -1
  57. package/src/composables/useSearchFilter.ts +118 -0
  58. package/src/composables/useStableQueryParams.ts +31 -3
  59. package/src/config.ts +3 -0
  60. package/src/functions/api.ts +34 -33
  61. package/src/functions/api.types.ts +1 -0
  62. package/src/functions/charts.ts +68 -0
  63. package/src/functions/datasets.ts +0 -17
  64. package/src/functions/resources.ts +56 -1
  65. package/src/functions/tabular.ts +60 -0
  66. package/src/functions/tabularApi.ts +138 -11
  67. package/src/main.ts +55 -7
  68. package/src/types/dataservices.ts +2 -0
  69. package/src/types/pages.ts +0 -5
  70. package/src/types/posts.ts +2 -2
  71. package/src/types/reports.ts +3 -0
  72. package/src/types/search.ts +52 -1
  73. package/src/types/site.ts +5 -3
  74. package/src/types/users.ts +0 -1
  75. package/src/types/visualizations.ts +89 -0
  76. package/assets/swagger-themes/newspaper.css +0 -1670
  77. package/dist/Datafair.client-E5D6ePRC.js +0 -35
  78. package/dist/JsonPreview.client-C-6eBbPw.js +0 -87
  79. package/dist/Swagger.client-D4-F6yEf.js +0 -4
  80. package/dist/XmlPreview.client-Dl2VCgXF.js +0 -79
  81. package/src/components/ResourceAccordion/Swagger.client.vue +0 -48
  82. package/src/functions/pagination.ts +0 -9
  83. /package/assets/illustrations/{_microscope.svg → microscope.svg} +0 -0
package/src/main.ts CHANGED
@@ -13,7 +13,7 @@ import type { License } from './types/licenses'
13
13
  import type { Member, MemberRole, NewOrganization, Organization, OrganizationOrSuggest, OrganizationReference, OrganizationSuggest } from './types/organizations'
14
14
  import type { Owned, OwnedWithFullObject, OwnedWithId } from './types/owned'
15
15
  import type { Comment, Thread } from './types/discussions'
16
- import type { Page, PageBloc, ContentBloc, BlocWithTitle, DatasetsListBloc, DataservicesListBloc, ReusesListBloc, LinkInBloc, LinksListBloc, MarkdownBloc, AccordionItemBloc, AccordionListBloc, HeroBloc } from './types/pages'
16
+ import type { PageBloc, ContentBloc, BlocWithTitle, DatasetsListBloc, DataservicesListBloc, ReusesListBloc, LinkInBloc, LinksListBloc, MarkdownBloc, AccordionItemBloc, AccordionListBloc, HeroBloc } from './types/pages'
17
17
  import type { Post } from './types/posts'
18
18
  import type { ReuseReference, NewReuse, Reuse, ReuseTopic, ReuseType } from './types/reuses'
19
19
  import type { RegisteredSchema, Schema, SchemaDetails, SchemaField, SchemaPath, SchemaPublicationMode, SchemaResponseData, SchemaVersion, ValidataError } from './types/schemas'
@@ -23,8 +23,11 @@ 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 { GlobalSearchConfig, SearchType, SortOption } from './types/search'
27
- import { getDefaultDatasetConfig, getDefaultDataserviceConfig, getDefaultReuseConfig, getDefaultOrganizationConfig, getDefaultGlobalSearchConfig, defaultDatasetSortOptions, defaultDataserviceSortOptions, defaultReuseSortOptions, defaultOrganizationSortOptions } from './types/search'
26
+ import type { Chart, ChartForm, ChartForApi, FilterCondition, Filter, AndFilters, GenericFilter, XAxisType, XAxisSortBy, SortDirection, XAxis, XAxisForm, UnitPosition, YAxis, DataSeriesType, DataSeries, DataSeriesForm } from './types/visualizations'
27
+ import type { GlobalSearchConfig, SearchType, SearchTypeConfig, SortOption, HiddenFilter, BuiltInFilterKey, DatasetSearchConfig, DatasetSearchFilters, DataserviceSearchConfig, DataserviceSearchFilters, ReuseSearchConfig, ReuseSearchFilters, OrganizationSearchConfig, OrganizationSearchFilters, TopicSearchConfig, TopicSearchFilters } from './types/search'
28
+ import { getDefaultDatasetConfig, getDefaultDataserviceConfig, getDefaultReuseConfig, getDefaultOrganizationConfig, getDefaultTopicConfig, getDefaultGlobalSearchConfig, defaultDatasetSortOptions, defaultDataserviceSortOptions, defaultReuseSortOptions, defaultOrganizationSortOptions } from './types/search'
29
+ import { useSearchFilter } from './composables/useSearchFilter'
30
+ import type { UseSearchFilterOptions } from './composables/useSearchFilter'
28
31
 
29
32
  import ActivityList from './components/ActivityList/ActivityList.vue'
30
33
  import UserActivityList from './components/ActivityList/UserActivityList.vue'
@@ -73,13 +76,15 @@ import ResourceIcon from './components/ResourceAccordion/ResourceIcon.vue'
73
76
  import ResourceExplorer from './components/ResourceExplorer/ResourceExplorer.vue'
74
77
  import ResourceExplorerSidebar from './components/ResourceExplorer/ResourceExplorerSidebar.vue'
75
78
  import ResourceExplorerViewer from './components/ResourceExplorer/ResourceExplorerViewer.vue'
76
- import Swagger from './components/ResourceAccordion/Swagger.client.vue'
79
+ import OpenApiViewer from './components/OpenApiViewer/OpenApiViewer.vue'
77
80
  import ReuseCard from './components/ReuseCard.vue'
78
81
  import ReuseHorizontalCard from './components/ReuseHorizontalCard.vue'
79
82
  import ReuseDetails from './components/ReuseDetails.vue'
80
83
  import SchemaCard from './components/SchemaCard.vue'
81
84
  import SimpleBanner from './components/SimpleBanner.vue'
82
85
  import SmallChart from './components/SmallChart.vue'
86
+ import ChartViewer from './components/Chart/ChartViewer.vue'
87
+ import ChartViewerWrapper from './components/Chart/ChartViewerWrapper.vue'
83
88
  import StatBox from './components/StatBox.vue'
84
89
  import Tab from './components/Tabs/Tab.vue'
85
90
  import TabGroup from './components/Tabs/TabGroup.vue'
@@ -94,12 +99,16 @@ import GlobalSearch from './components/Search/GlobalSearch.vue'
94
99
  import SearchInput from './components/Search/SearchInput.vue'
95
100
  import SearchableSelect from './components/Form/SearchableSelect.vue'
96
101
  import SelectGroup from './components/Form/SelectGroup.vue'
102
+ import Listbox from './components/Form/Listbox.vue'
103
+ import InfiniteLoader from './components/InfiniteLoader.vue'
104
+ import TabularExplorer from './components/TabularExplorer/TabularExplorer.vue'
97
105
  import type { UseFetchFunction } from './functions/api.types'
98
106
  import { configKey, useComponentsConfig, type PluginConfig } from './config.js'
99
107
 
100
108
  export { Toaster, toast } from 'vue-sonner'
101
109
 
102
110
  export * from './composables/useActiveDescendant'
111
+ export * from './composables/useDebouncedRef'
103
112
  export * from './composables/useMetrics'
104
113
  export * from './composables/useReuseType'
105
114
  export * from './composables/useTranslation'
@@ -116,17 +125,33 @@ export * from './functions/metrics'
116
125
  export * from './functions/never'
117
126
  export * from './functions/organizations'
118
127
  export * from './functions/owned'
119
- export * from './functions/pagination'
120
128
  export * from './functions/resources'
121
129
  export * from './functions/reuses'
122
130
  export * from './functions/schemas'
131
+ export * from './functions/tabular'
123
132
  export * from './functions/users'
133
+ export * from './functions/tabularApi'
134
+ export * from './functions/charts'
124
135
  export * from './types/access_types'
125
136
 
126
137
  export type {
127
138
  GlobalSearchConfig,
128
139
  SearchType,
140
+ SearchTypeConfig,
129
141
  SortOption,
142
+ HiddenFilter,
143
+ BuiltInFilterKey,
144
+ DatasetSearchConfig,
145
+ DatasetSearchFilters,
146
+ DataserviceSearchConfig,
147
+ DataserviceSearchFilters,
148
+ ReuseSearchConfig,
149
+ ReuseSearchFilters,
150
+ OrganizationSearchConfig,
151
+ OrganizationSearchFilters,
152
+ TopicSearchConfig,
153
+ TopicSearchFilters,
154
+ UseSearchFilterOptions,
130
155
  UseFetchFunction,
131
156
  AccessType,
132
157
  AccessAudience,
@@ -168,7 +193,6 @@ export type {
168
193
  Owned,
169
194
  OwnedWithFullObject,
170
195
  OwnedWithId,
171
- Page,
172
196
  PageBloc,
173
197
  ContentBloc,
174
198
  BlocWithTitle,
@@ -218,6 +242,23 @@ export type {
218
242
  ValidataError,
219
243
  Weight,
220
244
  WellType,
245
+ Chart,
246
+ ChartForm,
247
+ ChartForApi,
248
+ FilterCondition,
249
+ Filter,
250
+ AndFilters,
251
+ GenericFilter,
252
+ XAxisType,
253
+ XAxisSortBy,
254
+ SortDirection,
255
+ XAxis,
256
+ XAxisForm,
257
+ UnitPosition,
258
+ YAxis,
259
+ DataSeriesType,
260
+ DataSeries,
261
+ DataSeriesForm,
221
262
  }
222
263
 
223
264
  export {
@@ -225,11 +266,13 @@ export {
225
266
  getDefaultDataserviceConfig,
226
267
  getDefaultReuseConfig,
227
268
  getDefaultOrganizationConfig,
269
+ getDefaultTopicConfig,
228
270
  getDefaultGlobalSearchConfig,
229
271
  defaultDatasetSortOptions,
230
272
  defaultDataserviceSortOptions,
231
273
  defaultReuseSortOptions,
232
274
  defaultOrganizationSortOptions,
275
+ useSearchFilter,
233
276
  }
234
277
 
235
278
  // Vue Plugin
@@ -302,8 +345,10 @@ export {
302
345
  SchemaCard,
303
346
  SimpleBanner,
304
347
  SmallChart,
348
+ ChartViewer,
349
+ ChartViewerWrapper,
305
350
  StatBox,
306
- Swagger,
351
+ OpenApiViewer,
307
352
  Tab,
308
353
  TabGroup,
309
354
  TabList,
@@ -318,4 +363,7 @@ export {
318
363
  SearchInput,
319
364
  SearchableSelect,
320
365
  SelectGroup,
366
+ Listbox,
367
+ InfiniteLoader,
368
+ TabularExplorer,
321
369
  }
@@ -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
@@ -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
@@ -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
  }
@@ -1,5 +1,10 @@
1
1
  import type { PaginatedArray } from './api'
2
2
  import type { AccessType } from './access_types'
3
+ import type { Dataset } from './datasets'
4
+ import type { Dataservice } from './dataservices'
5
+ import type { Organization } from './organizations'
6
+ import type { Reuse } from './reuses'
7
+ import type { TopicV2 } from './topics'
3
8
  import type {
4
9
  CERTIFIED,
5
10
  PUBLIC_SERVICE,
@@ -291,7 +296,9 @@ export type SortOption<Sort extends string> = {
291
296
 
292
297
  export type DatasetSearchConfig = {
293
298
  class: 'datasets'
299
+ key?: string
294
300
  name?: string
301
+ placeholder?: string | null
295
302
  hiddenFilters?: HiddenFilter<DatasetSearchFilters>[]
296
303
  basicFilters?: (keyof DatasetSearchFilters)[]
297
304
  advancedFilters?: (keyof DatasetSearchFilters)[]
@@ -300,7 +307,9 @@ export type DatasetSearchConfig = {
300
307
 
301
308
  export type DataserviceSearchConfig = {
302
309
  class: 'dataservices'
310
+ key?: string
303
311
  name?: string
312
+ placeholder?: string | null
304
313
  hiddenFilters?: HiddenFilter<DataserviceSearchFilters>[]
305
314
  basicFilters?: (keyof DataserviceSearchFilters)[]
306
315
  advancedFilters?: (keyof DataserviceSearchFilters)[]
@@ -309,7 +318,9 @@ export type DataserviceSearchConfig = {
309
318
 
310
319
  export type ReuseSearchConfig = {
311
320
  class: 'reuses'
321
+ key?: string
312
322
  name?: string
323
+ placeholder?: string | null
313
324
  hiddenFilters?: HiddenFilter<ReuseSearchFilters>[]
314
325
  basicFilters?: (keyof ReuseSearchFilters)[]
315
326
  advancedFilters?: (keyof ReuseSearchFilters)[]
@@ -318,19 +329,43 @@ export type ReuseSearchConfig = {
318
329
 
319
330
  export type OrganizationSearchConfig = {
320
331
  class: 'organizations'
332
+ key?: string
321
333
  name?: string
334
+ placeholder?: string | null
322
335
  hiddenFilters?: HiddenFilter<OrganizationSearchFilters>[]
323
336
  basicFilters?: (keyof OrganizationSearchFilters)[]
324
337
  advancedFilters?: (keyof OrganizationSearchFilters)[]
325
338
  sortOptions?: SortOption<OrganizationSearchSort>[]
326
339
  }
327
340
 
328
- export type SearchTypeConfig = DatasetSearchConfig | DataserviceSearchConfig | ReuseSearchConfig | OrganizationSearchConfig
341
+ export type TopicSearchConfig = {
342
+ class: 'topics'
343
+ key?: string
344
+ name?: string
345
+ placeholder?: string | null
346
+ hiddenFilters?: HiddenFilter<TopicSearchFilters>[]
347
+ basicFilters?: (keyof TopicSearchFilters)[]
348
+ advancedFilters?: (keyof TopicSearchFilters)[]
349
+ sortOptions?: SortOption<TopicSearchSort>[]
350
+ }
351
+
352
+ export type SearchTypeConfig = DatasetSearchConfig | DataserviceSearchConfig | ReuseSearchConfig | OrganizationSearchConfig | TopicSearchConfig
353
+
354
+ export type BuiltInFilterKey = keyof DatasetSearchFilters | keyof DataserviceSearchFilters | keyof ReuseSearchFilters | keyof OrganizationSearchFilters | keyof TopicSearchFilters
329
355
 
330
356
  export type SearchType = SearchTypeConfig['class']
331
357
 
332
358
  export type GlobalSearchConfig = SearchTypeConfig[]
333
359
 
360
+ // Maps each search class to its concrete response shape.
361
+ export type SearchResponseByClass = {
362
+ datasets: DatasetSearchResponse<Dataset>
363
+ dataservices: DataserviceSearchResponse<Dataservice>
364
+ reuses: ReuseSearchResponse<Reuse>
365
+ organizations: OrganizationSearchResponse<Organization>
366
+ topics: TopicSearchResponse<TopicV2>
367
+ }
368
+
334
369
  // Helper functions for default configs
335
370
 
336
371
  export const defaultDatasetSortOptions: SortOption<DatasetSearchSort>[] = [
@@ -397,11 +432,27 @@ export function getDefaultOrganizationConfig(overrides?: Partial<Omit<Organizati
397
432
  }
398
433
  }
399
434
 
435
+ export const defaultTopicSortOptions: SortOption<TopicSearchSort>[] = [
436
+ { value: '-created', label: 'Date de création' },
437
+ { value: '-last_modified', label: 'Dernière mise à jour' },
438
+ ]
439
+
440
+ export function getDefaultTopicConfig(overrides?: Partial<Omit<TopicSearchConfig, 'class'>>): TopicSearchConfig {
441
+ return {
442
+ class: 'topics',
443
+ basicFilters: ['last_update_range', 'producer_type'],
444
+ advancedFilters: ['organization', 'tag'],
445
+ sortOptions: defaultTopicSortOptions,
446
+ ...overrides,
447
+ }
448
+ }
449
+
400
450
  export function getDefaultGlobalSearchConfig(): GlobalSearchConfig {
401
451
  return [
402
452
  getDefaultDatasetConfig(),
403
453
  getDefaultDataserviceConfig(),
404
454
  getDefaultReuseConfig(),
405
455
  getDefaultOrganizationConfig(),
456
+ getDefaultTopicConfig(),
406
457
  ]
407
458
  }
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
@@ -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
@@ -0,0 +1,89 @@
1
+ import type { TabularAggregateType } from '../functions/tabularApi'
2
+ import type { Owned, OwnedWithId } from './owned'
3
+
4
+ export type FilterCondition = 'exact' | 'differs' | 'is_null' | 'is_not_null' | 'greater' | 'less' | 'strictly_greater' | 'strictly_less'
5
+ export type Filter = {
6
+ _cls: 'Filter'
7
+ column: string
8
+ condition: FilterCondition
9
+ value: string | null
10
+ }
11
+
12
+ export type AndFilters = {
13
+ _cls: 'AndFilters'
14
+ filters: Array<Filter | AndFilters>
15
+ }
16
+
17
+ export type GenericFilter = Filter | AndFilters
18
+
19
+ export type XAxisType = 'discrete' | 'continuous'
20
+
21
+ export type XAxisSortBy = 'axis_x' | 'axis_y'
22
+
23
+ export type SortDirection = 'asc' | 'desc'
24
+
25
+ export type XAxis = {
26
+ column_x: string
27
+ sort_x_by: XAxisSortBy | null
28
+ sort_x_direction: SortDirection | null
29
+ type: XAxisType
30
+ }
31
+
32
+ export type CombinedSort = '' | 'axis_x-asc' | 'axis_x-desc' | 'axis_y-asc' | 'axis_y-desc'
33
+
34
+ export type XAxisForm = Omit<XAxis, 'sort_x_by' | 'sort_x_direction'> & { sort_combined: CombinedSort }
35
+
36
+ export type UnitPosition = 'prefix' | 'suffix'
37
+
38
+ export type YAxis = {
39
+ min: number | null
40
+ max: number | null
41
+ label: string | null
42
+ unit: string | null
43
+ unit_position: UnitPosition | null
44
+ }
45
+
46
+ export type DataSeriesType = 'line' | 'histogram'
47
+
48
+ export type DataSeries = {
49
+ type: DataSeriesType
50
+ column_y: string
51
+ aggregate_y: TabularAggregateType | null
52
+ resource_id: string
53
+ column_x_name_override: string | null
54
+ filters: GenericFilter | null
55
+ }
56
+
57
+ // Type for form where aggregate_y can be empty string for select binding
58
+ export type DataSeriesForm = Omit<DataSeries, 'aggregate_y'> & { aggregate_y: TabularAggregateType | '' | null }
59
+
60
+ export type Chart = Owned & {
61
+ id: string
62
+ title: string
63
+ slug: string
64
+ description: string
65
+ private: boolean
66
+ created_at: string
67
+ last_modified: string
68
+ deleted_at: string | null
69
+ uri: string
70
+ page: string
71
+ x_axis: XAxis
72
+ y_axis: YAxis
73
+ series: Array<DataSeries>
74
+ extras: Record<string, unknown>
75
+ permissions: { delete: boolean, edit: boolean, read: boolean }
76
+ metrics: {
77
+ views: number
78
+ }
79
+ }
80
+
81
+ export type ChartForApi = OwnedWithId & Pick<Chart, 'title' | 'description' | 'private' | 'x_axis' | 'y_axis' | 'series' | 'extras'>
82
+
83
+ export type ChartForm = Omit<ChartForApi, 'x_axis' | 'series' | 'owner' | 'organization'> & {
84
+ owned: OwnedWithId
85
+ x_axis: XAxisForm
86
+ series: Array<DataSeriesForm>
87
+ chart_type?: DataSeriesType | null
88
+ filter: GenericFilter | null
89
+ }