@buildcanada/charts 0.1.1 → 0.2.2

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 (122) hide show
  1. package/package.json +2 -2
  2. package/src/components/Button/Button.scss +17 -17
  3. package/src/components/Button/Button.tsx +4 -4
  4. package/src/components/MarkdownTextWrap/MarkdownTextWrap.tsx +1 -1
  5. package/src/components/index.ts +1 -1
  6. package/src/components/stubs/DataCitation.tsx +1 -1
  7. package/src/components/stubs/IndicatorKeyData.tsx +1 -1
  8. package/src/components/stubs/IndicatorProcessing.tsx +1 -1
  9. package/src/components/stubs/IndicatorSources.tsx +1 -1
  10. package/src/components/styles/colors.scss +1 -1
  11. package/src/components/styles/mixins.scss +5 -5
  12. package/src/core-table/{OwidTable.ts → ChartsTable.ts} +31 -31
  13. package/src/core-table/CoreTable.ts +12 -12
  14. package/src/core-table/CoreTableColumns.ts +24 -24
  15. package/src/core-table/CoreTableUtils.ts +7 -7
  16. package/src/core-table/{OwidTableSynthesizers.ts → TableSynthesizers.ts} +24 -24
  17. package/src/core-table/{OwidTableUtil.ts → TableUtil.ts} +5 -5
  18. package/src/core-table/index.ts +3 -3
  19. package/src/explorer/ColumnGrammar.ts +1 -1
  20. package/src/explorer/Explorer.sample.ts +7 -7
  21. package/src/explorer/Explorer.scss +1 -1
  22. package/src/explorer/Explorer.tsx +23 -23
  23. package/src/explorer/ExplorerConstants.ts +2 -2
  24. package/src/explorer/ExplorerGrammar.ts +3 -3
  25. package/src/explorer/ExplorerProgram.ts +21 -18
  26. package/src/explorer/ExplorerUtils.ts +1 -1
  27. package/src/explorer/gridLang/readme.md +1 -1
  28. package/src/grapher/axis/Axis.ts +3 -3
  29. package/src/grapher/barCharts/DiscreteBarChart.tsx +2 -2
  30. package/src/grapher/barCharts/DiscreteBarChartState.ts +8 -8
  31. package/src/grapher/captionedChart/Logos.tsx +11 -13
  32. package/src/grapher/captionedChart/LogosSVG.tsx +2 -2
  33. package/src/grapher/chart/ChartAreaContent.tsx +1 -1
  34. package/src/grapher/chart/ChartDimension.ts +15 -15
  35. package/src/grapher/chart/ChartInterface.ts +6 -6
  36. package/src/grapher/chart/ChartManager.ts +3 -3
  37. package/src/grapher/chart/ChartUtils.tsx +3 -3
  38. package/src/grapher/color/ColorConstants.ts +2 -2
  39. package/src/grapher/color/ColorScale.ts +4 -4
  40. package/src/grapher/color/ColorSchemes.ts +26 -26
  41. package/src/grapher/color/CustomSchemes.ts +227 -227
  42. package/src/grapher/controls/DataTableFilterDropdown.tsx +2 -2
  43. package/src/grapher/controls/MapZoomDropdown.tsx +3 -3
  44. package/src/grapher/controls/ShareMenu.tsx +1 -1
  45. package/src/grapher/controls/entityPicker/EntityPicker.tsx +8 -8
  46. package/src/grapher/controls/entityPicker/EntityPickerConstants.ts +3 -3
  47. package/src/grapher/controls/globalEntitySelector/GlobalEntitySelector.tsx +1 -1
  48. package/src/grapher/core/EntitiesByRegionType.ts +4 -4
  49. package/src/grapher/core/EntityUrlBuilder.ts +2 -2
  50. package/src/grapher/core/FetchingGrapher.tsx +4 -4
  51. package/src/grapher/core/Grapher.tsx +10 -10
  52. package/src/grapher/core/GrapherState.tsx +46 -46
  53. package/src/grapher/core/GrapherUseHelpers.tsx +4 -4
  54. package/src/grapher/core/{LegacyToOwidTable.ts → LegacyToChartsTable.ts} +100 -100
  55. package/src/grapher/core/loadGrapherTableHelpers.ts +13 -13
  56. package/src/grapher/core/loadVariable.ts +5 -5
  57. package/src/grapher/dataTable/DataTable.sample.ts +12 -12
  58. package/src/grapher/dataTable/DataTable.tsx +22 -22
  59. package/src/grapher/dataTable/DataTableConstants.ts +9 -9
  60. package/src/grapher/entitySelector/EntitySelector.tsx +12 -12
  61. package/src/grapher/facet/FacetChart.tsx +4 -4
  62. package/src/grapher/facet/FacetMap.tsx +6 -6
  63. package/src/grapher/footer/Footer.tsx +4 -4
  64. package/src/grapher/footer/FooterManager.ts +2 -2
  65. package/src/grapher/header/Header.tsx +5 -5
  66. package/src/grapher/header/HeaderManager.ts +1 -1
  67. package/src/grapher/index.ts +8 -8
  68. package/src/grapher/lineCharts/LineChartHelpers.ts +3 -3
  69. package/src/grapher/lineCharts/LineChartState.ts +9 -9
  70. package/src/grapher/mapCharts/ChoroplethGlobe.tsx +1 -1
  71. package/src/grapher/mapCharts/GlobeController.ts +9 -9
  72. package/src/grapher/mapCharts/MapChartState.ts +16 -16
  73. package/src/grapher/mapCharts/MapSparkline.tsx +5 -5
  74. package/src/grapher/mapCharts/MapTooltip.tsx +13 -13
  75. package/src/grapher/modal/DownloadModal.scss +3 -3
  76. package/src/grapher/modal/DownloadModal.tsx +24 -29
  77. package/src/grapher/modal/SourcesDescriptions.scss +1 -1
  78. package/src/grapher/modal/SourcesKeyDataTable.tsx +2 -2
  79. package/src/grapher/modal/SourcesModal.tsx +15 -15
  80. package/src/grapher/scatterCharts/ScatterPlotChart.tsx +2 -2
  81. package/src/grapher/scatterCharts/ScatterPlotChartConstants.ts +2 -2
  82. package/src/grapher/scatterCharts/ScatterPlotChartState.ts +8 -8
  83. package/src/grapher/scatterCharts/ScatterSizeLegend.tsx +2 -2
  84. package/src/grapher/scatterCharts/ScatterUtils.ts +2 -2
  85. package/src/grapher/schema/grapher-schema.009.yaml +18 -18
  86. package/src/grapher/schema/migrations/migrations.ts +4 -4
  87. package/src/grapher/selection/MapSelectionArray.ts +1 -1
  88. package/src/grapher/selection/readme.md +1 -1
  89. package/src/grapher/slopeCharts/SlopeChartConstants.ts +3 -3
  90. package/src/grapher/slopeCharts/SlopeChartState.ts +10 -10
  91. package/src/grapher/stackedCharts/AbstractStackedChartState.ts +8 -8
  92. package/src/grapher/stackedCharts/MarimekkoChart.tsx +5 -5
  93. package/src/grapher/stackedCharts/MarimekkoChartConstants.ts +2 -2
  94. package/src/grapher/stackedCharts/MarimekkoChartState.ts +12 -12
  95. package/src/grapher/stackedCharts/StackedBarChartState.ts +1 -1
  96. package/src/grapher/stackedCharts/StackedConstants.ts +2 -2
  97. package/src/grapher/stackedCharts/StackedDiscreteBarChartState.ts +12 -12
  98. package/src/grapher/stackedCharts/StackedDiscreteBars.tsx +2 -2
  99. package/src/grapher/testData/{OwidTestData.sample.ts → TestData.sample.ts} +7 -7
  100. package/src/grapher/testData/{OwidTestData.ts → TestData.ts} +5 -5
  101. package/src/index.ts +7 -7
  102. package/src/types/{OwidOrigin.ts → Origin.ts} +3 -3
  103. package/src/types/{OwidSource.ts → Source.ts} +1 -1
  104. package/src/types/Variable.ts +133 -0
  105. package/src/types/{OwidVariableDisplayConfigInterface.ts → VariableDisplayConfigInterface.ts} +11 -11
  106. package/src/types/domainTypes/ContentGraph.ts +2 -2
  107. package/src/types/domainTypes/CoreTableTypes.ts +29 -29
  108. package/src/types/domainTypes/Posts.ts +2 -2
  109. package/src/types/domainTypes/Search.ts +6 -6
  110. package/src/types/domainTypes/Various.ts +1 -1
  111. package/src/types/gdocTypes/Gdoc.ts +42 -42
  112. package/src/types/grapherTypes/GrapherTypes.ts +21 -21
  113. package/src/types/index.ts +50 -50
  114. package/src/utils/MultiDimDataPageConfig.ts +1 -1
  115. package/src/utils/Util.ts +61 -55
  116. package/src/utils/{OwidVariable.ts → Variable.ts} +15 -15
  117. package/src/utils/formatValue.ts +12 -12
  118. package/src/utils/image.ts +12 -12
  119. package/src/utils/index.ts +5 -5
  120. package/src/utils/metadataHelpers.ts +19 -19
  121. package/src/utils/regions.ts +9 -9
  122. package/src/types/OwidVariable.ts +0 -133
@@ -8,18 +8,18 @@ import {
8
8
  deleteRuntimeAndUnchangedProps,
9
9
  } from "./persistable/Persistable.js"
10
10
  import {
11
- OwidVariableDataTableConfigInterface,
12
- OwidVariableDisplayConfigInterface,
13
- OwidVariableRoundingMode,
11
+ VariableDataTableConfigInterface,
12
+ VariableDisplayConfigInterface,
13
+ VariableRoundingMode,
14
14
  } from "../types/index.js"
15
15
 
16
- class OwidVariableDisplayConfigDefaults {
16
+ class VariableDisplayConfigDefaults {
17
17
  name: string | undefined = undefined
18
18
  unit: string | undefined = undefined
19
19
  shortUnit: string | undefined = undefined
20
20
  isProjection: boolean | undefined = undefined
21
21
  conversionFactor: number | undefined = undefined
22
- roundingMode: OwidVariableRoundingMode | undefined = undefined
22
+ roundingMode: VariableRoundingMode | undefined = undefined
23
23
  numDecimalPlaces: number | undefined = undefined
24
24
  numSignificantFigures: number | undefined = undefined
25
25
  tolerance: number | undefined = undefined
@@ -27,7 +27,7 @@ class OwidVariableDisplayConfigDefaults {
27
27
  zeroDay: string | undefined = undefined
28
28
  entityAnnotationsMap: string | undefined = undefined
29
29
  includeInTable: boolean | undefined = true
30
- tableDisplay: OwidVariableDataTableConfigInterface | undefined = undefined
30
+ tableDisplay: VariableDataTableConfigInterface | undefined = undefined
31
31
  color: string | undefined = undefined
32
32
  plotMarkersOnlyInLineChart: boolean | undefined = undefined
33
33
 
@@ -53,30 +53,30 @@ class OwidVariableDisplayConfigDefaults {
53
53
  }
54
54
  }
55
55
 
56
- export class OwidVariableDisplayConfig
57
- extends OwidVariableDisplayConfigDefaults
56
+ export class VariableDisplayConfig
57
+ extends VariableDisplayConfigDefaults
58
58
  implements Persistable
59
59
  {
60
- updateFromObject(obj?: Partial<OwidVariableDisplayConfigInterface>): void {
60
+ updateFromObject(obj?: Partial<VariableDisplayConfigInterface>): void {
61
61
  if (obj) updatePersistables(this, obj)
62
62
  }
63
63
 
64
- toObject(): OwidVariableDisplayConfigDefaults {
64
+ toObject(): VariableDisplayConfigDefaults {
65
65
  return deleteRuntimeAndUnchangedProps(
66
66
  objectWithPersistablesToObject(this),
67
- new OwidVariableDisplayConfigDefaults()
67
+ new VariableDisplayConfigDefaults()
68
68
  )
69
69
  }
70
70
 
71
- constructor(obj?: Partial<OwidVariableDisplayConfigInterface>) {
71
+ constructor(obj?: Partial<VariableDisplayConfigInterface>) {
72
72
  super()
73
73
  if (obj) this.updateFromObject(obj)
74
74
  }
75
75
  }
76
76
 
77
- // export interface OwidVariablesAndEntityKey {
77
+ // export interface VariablesAndEntityKey {
78
78
  // variables: {
79
- // [id: string]: OwidVariableWithDataAndSource
79
+ // [id: string]: VariableWithDataAndSource
80
80
  // }
81
- // entityKey: OwidEntityKey
81
+ // entityKey: EntityKey
82
82
  // }
@@ -1,7 +1,7 @@
1
1
  import { FormatSpecifier } from "d3-format"
2
2
  import { createFormatter } from "./Util.js"
3
3
  import {
4
- OwidVariableRoundingMode,
4
+ VariableRoundingMode,
5
5
  TickFormattingOptions,
6
6
  } from "../types/index.js"
7
7
 
@@ -22,11 +22,11 @@ function getTrim({
22
22
  roundingMode,
23
23
  trailingZeroes,
24
24
  }: {
25
- roundingMode: OwidVariableRoundingMode
25
+ roundingMode: VariableRoundingMode
26
26
  trailingZeroes: boolean
27
27
  }): "~" | "" {
28
28
  // always show trailing zeroes when rounding to significant figures
29
- return roundingMode === OwidVariableRoundingMode.significantFigures
29
+ return roundingMode === VariableRoundingMode.significantFigures
30
30
  ? ""
31
31
  : trailingZeroes
32
32
  ? ""
@@ -47,7 +47,7 @@ function getType({
47
47
  value,
48
48
  unit,
49
49
  }: {
50
- roundingMode: OwidVariableRoundingMode
50
+ roundingMode: VariableRoundingMode
51
51
  numberAbbreviation: "long" | "short" | false
52
52
  value: number
53
53
  unit: string
@@ -56,9 +56,9 @@ function getType({
56
56
  // r: decimal notation, rounded to significant digits
57
57
  // s: decimal notation with an SI prefix, rounded to significant digits
58
58
 
59
- const typeMap: Record<OwidVariableRoundingMode, "f" | "r"> = {
60
- [OwidVariableRoundingMode.decimalPlaces]: "f",
61
- [OwidVariableRoundingMode.significantFigures]: "r",
59
+ const typeMap: Record<VariableRoundingMode, "f" | "r"> = {
60
+ [VariableRoundingMode.decimalPlaces]: "f",
61
+ [VariableRoundingMode.significantFigures]: "r",
62
62
  }
63
63
  const type = typeMap[roundingMode]
64
64
 
@@ -85,12 +85,12 @@ function getPrecision({
85
85
  type,
86
86
  }: {
87
87
  value: number
88
- roundingMode: OwidVariableRoundingMode
88
+ roundingMode: VariableRoundingMode
89
89
  numDecimalPlaces: number
90
90
  numSignificantFigures: number
91
91
  type: "f" | "s" | "r"
92
92
  }): string {
93
- if (roundingMode === OwidVariableRoundingMode.significantFigures) {
93
+ if (roundingMode === VariableRoundingMode.significantFigures) {
94
94
  return `${numSignificantFigures}`
95
95
  }
96
96
 
@@ -157,7 +157,7 @@ function postprocessString({
157
157
  numDecimalPlaces,
158
158
  }: {
159
159
  string: string
160
- roundingMode: OwidVariableRoundingMode
160
+ roundingMode: VariableRoundingMode
161
161
  numberAbbreviation: "long" | "short" | false
162
162
  spaceBeforeUnit: boolean
163
163
  useNoBreakSpace: boolean
@@ -168,7 +168,7 @@ function postprocessString({
168
168
  let output = string
169
169
 
170
170
  // handling infinitesimal values
171
- if (roundingMode !== OwidVariableRoundingMode.significantFigures) {
171
+ if (roundingMode !== VariableRoundingMode.significantFigures) {
172
172
  const tooSmallThreshold = Math.pow(10, -numDecimalPlaces).toPrecision(1)
173
173
  if (numberAbbreviation && 0 < value && value < +tooSmallThreshold) {
174
174
  output = "<" + output.replace(/0\.?(\d+)?/, tooSmallThreshold)
@@ -194,7 +194,7 @@ function postprocessString({
194
194
  export function formatValue(
195
195
  value: number,
196
196
  {
197
- roundingMode = OwidVariableRoundingMode.decimalPlaces,
197
+ roundingMode = VariableRoundingMode.decimalPlaces,
198
198
  trailingZeroes = false, // only applies to fixed-point notation
199
199
  unit = "",
200
200
  spaceBeforeUnit = !checkIsUnitPercent(unit),
@@ -6,8 +6,8 @@ Common utlities for deriving properties from image metadata.
6
6
  import { traverseEnrichedBlock } from "./Util.js"
7
7
  import {
8
8
  AssetMap,
9
- OwidGdoc,
10
- OwidGdocType,
9
+ Gdoc,
10
+ GdocType,
11
11
  ImageMetadata,
12
12
  } from "../types/index.js"
13
13
  import { match, P } from "ts-pattern"
@@ -172,18 +172,18 @@ export function generateSourceProps(
172
172
  return props
173
173
  }
174
174
 
175
- export function getFeaturedImageFilename(gdoc: OwidGdoc): string | undefined {
175
+ export function getFeaturedImageFilename(gdoc: Gdoc): string | undefined {
176
176
  return match(gdoc)
177
177
  .with(
178
178
  {
179
179
  content: {
180
180
  type: P.union(
181
- OwidGdocType.Article,
182
- OwidGdocType.TopicPage,
183
- OwidGdocType.LinearTopicPage,
184
- OwidGdocType.AboutPage,
185
- OwidGdocType.Author,
186
- OwidGdocType.Announcement
181
+ GdocType.Article,
182
+ GdocType.TopicPage,
183
+ GdocType.LinearTopicPage,
184
+ GdocType.AboutPage,
185
+ GdocType.Author,
186
+ GdocType.Announcement
187
187
  ),
188
188
  },
189
189
  },
@@ -192,7 +192,7 @@ export function getFeaturedImageFilename(gdoc: OwidGdoc): string | undefined {
192
192
  return featuredImageFilename
193
193
  }
194
194
  )
195
- .with({ content: { type: OwidGdocType.DataInsight } }, (gdoc) => {
195
+ .with({ content: { type: GdocType.DataInsight } }, (gdoc) => {
196
196
  // Use the first image in the document as the featured image
197
197
  let filename: string | undefined = undefined
198
198
  for (const block of gdoc.content.body) {
@@ -206,7 +206,7 @@ export function getFeaturedImageFilename(gdoc: OwidGdoc): string | undefined {
206
206
  })
207
207
  .with(
208
208
  {
209
- content: { type: OwidGdocType.Profile },
209
+ content: { type: GdocType.Profile },
210
210
  },
211
211
  (match) => match.content["featured-image"]
212
212
  )
@@ -214,7 +214,7 @@ export function getFeaturedImageFilename(gdoc: OwidGdoc): string | undefined {
214
214
  {
215
215
  content: {
216
216
  type: P.optional(
217
- P.union(OwidGdocType.Fragment, OwidGdocType.Homepage)
217
+ P.union(GdocType.Fragment, GdocType.Homepage)
218
218
  ),
219
219
  },
220
220
  },
@@ -76,8 +76,8 @@ export {
76
76
  getPhraseForArchivalDate,
77
77
  } from "./metadataHelpers.js"
78
78
 
79
- // OwidVariable display config
80
- export { OwidVariableDisplayConfig } from "./OwidVariable.js"
79
+ // Variable display config
80
+ export { VariableDisplayConfig } from "./Variable.js"
81
81
 
82
82
  // Persistable
83
83
  export {
@@ -105,8 +105,8 @@ export {
105
105
  listedRegionsNames,
106
106
  type Country,
107
107
  type IncomeGroup,
108
- type OwidIncomeGroupName,
109
- checkIsOwidIncomeGroupName,
108
+ type IncomeGroupName,
109
+ checkIsIncomeGroupName,
110
110
  getCountryBySlug,
111
111
  getCountryByName,
112
112
  getRegionByNameOrVariantName,
@@ -123,7 +123,7 @@ export {
123
123
  getRegionAlternativeNames,
124
124
  mappableCountries,
125
125
  checkIsCountry,
126
- checkIsOwidContinent,
126
+ checkIsContinent,
127
127
  checkIsIncomeGroup,
128
128
  getIncomeGroups,
129
129
  getCountryNamesForRegion,
@@ -1,12 +1,12 @@
1
1
  // @ts-nocheck
2
2
  import * as R from "remeda"
3
3
  import {
4
- OwidOrigin,
5
- OwidVariableWithSource,
6
- OwidProcessingLevel,
4
+ Origin,
5
+ VariableWithSource,
6
+ ProcessingLevel,
7
7
  DisplaySource,
8
8
  IndicatorTitleWithFragments,
9
- OwidSource,
9
+ Source,
10
10
  } from "../types/index.js"
11
11
  import * as _ from "lodash-es"
12
12
  import { excludeUndefined } from "./Util"
@@ -14,7 +14,7 @@ import dayjs from "./dayjs.js"
14
14
  import { parseArchivalDate } from "./archival/archivalDate.js"
15
15
 
16
16
  export function getOriginAttributionFragments(
17
- origins: OwidOrigin[] | undefined
17
+ origins: Origin[] | undefined
18
18
  ): string[] {
19
19
  return origins
20
20
  ? origins.map((origin) => {
@@ -40,7 +40,7 @@ export const splitSourceTextIntoFragments = (
40
40
 
41
41
  export function getAttributionFragmentsFromVariable(
42
42
  variable: Pick<
43
- OwidVariableWithSource,
43
+ VariableWithSource,
44
44
  "presentation" | "origins" | "source"
45
45
  >
46
46
  ): string[] {
@@ -89,7 +89,7 @@ const isDate = (date: string): boolean => {
89
89
  }
90
90
 
91
91
  export const getLastUpdatedFromVariable = (
92
- variable: Pick<OwidVariableWithSource, "catalogPath" | "origins">
92
+ variable: Pick<VariableWithSource, "catalogPath" | "origins">
93
93
  ): string | undefined => {
94
94
  // if possible, extract date from the catalog path
95
95
  const version = getETLPathComponents(variable.catalogPath ?? "")?.version
@@ -110,7 +110,7 @@ export const getLastUpdatedFromVariable = (
110
110
  }
111
111
 
112
112
  export const getNextUpdateFromVariable = (
113
- variable: Pick<OwidVariableWithSource, "catalogPath" | "updatePeriodDays">
113
+ variable: Pick<VariableWithSource, "catalogPath" | "updatePeriodDays">
114
114
  ): string | undefined => {
115
115
  const lastUpdated = getLastUpdatedFromVariable(variable)
116
116
  let nextUpdate = undefined
@@ -126,7 +126,7 @@ export const getNextUpdateFromVariable = (
126
126
  }
127
127
 
128
128
  export const getPhraseForProcessingLevel = (
129
- processingLevel: OwidProcessingLevel | undefined
129
+ processingLevel: ProcessingLevel | undefined
130
130
  ): string => {
131
131
  switch (processingLevel) {
132
132
  case "major":
@@ -138,7 +138,7 @@ export const getPhraseForProcessingLevel = (
138
138
  }
139
139
  }
140
140
 
141
- const prepareOriginForDisplay = (origin: OwidOrigin): DisplaySource => {
141
+ const prepareOriginForDisplay = (origin: Origin): DisplaySource => {
142
142
  let label = origin.producer ?? ""
143
143
  if (origin.title && origin.title !== label) {
144
144
  label += " – " + origin.title
@@ -154,7 +154,7 @@ const prepareOriginForDisplay = (origin: OwidOrigin): DisplaySource => {
154
154
  }
155
155
 
156
156
  export const prepareSourcesForDisplay = (
157
- variable: Pick<OwidVariableWithSource, "origins" | "source">
157
+ variable: Pick<VariableWithSource, "origins" | "source">
158
158
  ): DisplaySource[] => {
159
159
  const { origins, source } = variable
160
160
 
@@ -181,7 +181,7 @@ export const prepareSourcesForDisplay = (
181
181
  return sourcesForDisplay
182
182
  }
183
183
 
184
- const getYearSuffixFromOrigin = (o: OwidOrigin): string => {
184
+ const getYearSuffixFromOrigin = (o: Origin): string => {
185
185
  const year = o.dateAccessed
186
186
  ? dayjs(o.dateAccessed, ["YYYY-MM-DD", "YYYY"]).year()
187
187
  : o.datePublished
@@ -192,15 +192,15 @@ const getYearSuffixFromOrigin = (o: OwidOrigin): string => {
192
192
  }
193
193
 
194
194
  export const getCitationShort = (
195
- origins: OwidOrigin[],
195
+ origins: Origin[],
196
196
  attributions: string[],
197
- owidProcessingLevel: OwidProcessingLevel | undefined
197
+ processingLevel: ProcessingLevel | undefined
198
198
  ): string => {
199
199
  const producersWithYear = _.uniq(
200
200
  origins.map((o) => `${o.producer}${getYearSuffixFromOrigin(o)}`)
201
201
  )
202
202
  const processingLevelPhrase =
203
- getPhraseForProcessingLevel(owidProcessingLevel)
203
+ getPhraseForProcessingLevel(processingLevel)
204
204
 
205
205
  const attributionFragments = attributions ?? producersWithYear
206
206
  const attributionPotentiallyShortened =
@@ -226,12 +226,12 @@ export const getPhraseForArchivalDate = (
226
226
 
227
227
  export const getCitationLong = (
228
228
  indicatorTitle: IndicatorTitleWithFragments,
229
- origins: OwidOrigin[],
230
- source: OwidSource | undefined,
229
+ origins: Origin[],
230
+ source: Source | undefined,
231
231
  attributions: string[],
232
232
  attributionShort: string | undefined,
233
233
  titleVariant: string | undefined,
234
- owidProcessingLevel: OwidProcessingLevel | undefined,
234
+ processingLevel: ProcessingLevel | undefined,
235
235
  citationUrl: string | undefined,
236
236
  archivalDate: string | undefined
237
237
  ): string => {
@@ -243,7 +243,7 @@ export const getCitationLong = (
243
243
  origins.map((o) => `${o.producer}${getYearSuffixFromOrigin(o)}`)
244
244
  )
245
245
  const processingLevelPhrase =
246
- getPhraseForProcessingLevel(owidProcessingLevel)
246
+ getPhraseForProcessingLevel(processingLevel)
247
247
 
248
248
  const attributionFragments = attributions ?? producersWithYear
249
249
  const attributionUnshortened = attributionFragments.join("; ")
@@ -38,14 +38,14 @@ export interface Aggregate extends BaseRegion {
38
38
  }
39
39
 
40
40
  export interface Continent extends BaseRegion {
41
- name: OwidContinentName
41
+ name: ContinentName
42
42
  regionType: RegionType.Continent
43
43
  translationCodes?: string[]
44
44
  members: string[]
45
45
  }
46
46
 
47
47
  export interface IncomeGroup extends BaseRegion {
48
- name: OwidIncomeGroupName
48
+ name: IncomeGroupName
49
49
  regionType: RegionType.IncomeGroup
50
50
  members: string[]
51
51
  }
@@ -61,7 +61,7 @@ export type Region = Country | Aggregate | Continent | IncomeGroup | Province
61
61
 
62
62
  export const regions: Region[] = entities as Region[]
63
63
 
64
- type OwidContinentName =
64
+ type ContinentName =
65
65
  | "Africa"
66
66
  | "Asia"
67
67
  | "Europe"
@@ -69,7 +69,7 @@ type OwidContinentName =
69
69
  | "Oceania"
70
70
  | "South America"
71
71
 
72
- export type OwidIncomeGroupName =
72
+ export type IncomeGroupName =
73
73
  | "OWID_LIC"
74
74
  | "OWID_LMC"
75
75
  | "OWID_UMC"
@@ -85,9 +85,9 @@ export const aggregateSources = [
85
85
  ] as const
86
86
  export type AggregateSource = (typeof aggregateSources)[number]
87
87
 
88
- export function checkIsOwidIncomeGroupName(
88
+ export function checkIsIncomeGroupName(
89
89
  name: string
90
- ): name is OwidIncomeGroupName {
90
+ ): name is IncomeGroupName {
91
91
  return (
92
92
  name === "OWID_LIC" ||
93
93
  name === "OWID_LMC" ||
@@ -103,7 +103,7 @@ export function checkIsCountry(region: Region): region is Country {
103
103
  )
104
104
  }
105
105
 
106
- export function checkIsOwidContinent(region: Region): region is Continent {
106
+ export function checkIsContinent(region: Region): region is Continent {
107
107
  return region.regionType === RegionType.Continent
108
108
  }
109
109
 
@@ -199,9 +199,9 @@ export const incomeGroupsByName = lazy(
199
199
  () =>
200
200
  Object.fromEntries(
201
201
  regions
202
- .filter((region) => checkIsOwidIncomeGroupName(region.code))
202
+ .filter((region) => checkIsIncomeGroupName(region.code))
203
203
  .map((region) => [region.code, region])
204
- ) as Record<OwidIncomeGroupName, IncomeGroup>
204
+ ) as Record<IncomeGroupName, IncomeGroup>
205
205
  )
206
206
 
207
207
  const countriesBySlug = lazy(() =>
@@ -1,133 +0,0 @@
1
- import { OwidOrigin } from "./OwidOrigin.js"
2
- import { OwidSource } from "./OwidSource.js"
3
- import { OwidVariableDisplayConfigInterface } from "./OwidVariableDisplayConfigInterface.js"
4
-
5
- export interface OwidVariableWithSource {
6
- id: number
7
- name?: string
8
- description?: string
9
- descriptionShort?: string
10
- descriptionFromProducer?: string
11
- descriptionKey?: string[]
12
- descriptionProcessing?: string
13
- unit?: string
14
- display?: OwidVariableDisplayConfigInterface
15
- shortUnit?: string
16
- datasetName?: string
17
- datasetId?: number
18
- coverage?: string
19
- nonRedistributable?: boolean
20
- source?: OwidSource
21
- origins?: OwidOrigin[]
22
- schemaVersion?: number
23
- processingLevel?: OwidProcessingLevel
24
- presentation?: OwidVariablePresentation
25
- shortName?: string
26
- timespan?: string
27
- catalogPath?: string
28
- license?: OwidLicense
29
- updatePeriodDays?: number
30
- datasetVersion?: string
31
- licenses?: OwidLicense[]
32
- type?: OwidVariableType
33
-
34
- // omitted:
35
- // code
36
- // coverage
37
- // dataPath
38
- // metadataPath
39
- }
40
-
41
- export interface IndicatorTitleWithFragments {
42
- title: string
43
- attributionShort?: string
44
- titleVariant?: string
45
- }
46
-
47
- export function joinTitleFragments(
48
- attributionShort: string | undefined,
49
- titleVariant: string | undefined
50
- ): string | undefined {
51
- if (attributionShort && titleVariant && attributionShort !== titleVariant) {
52
- return `${titleVariant} – ${attributionShort}`
53
- }
54
- if (attributionShort) {
55
- return attributionShort
56
- }
57
- if (titleVariant) {
58
- return titleVariant
59
- }
60
- return undefined
61
- }
62
-
63
- export interface OwidLicense {
64
- name: string
65
- url: string
66
- }
67
-
68
- export interface OwidVariablePresentation {
69
- titlePublic?: string
70
- titleVariant?: string
71
- attributionShort?: string
72
- attribution?: string
73
- topicTagsLinks?: string[]
74
- faqs?: FaqLink[]
75
- }
76
-
77
- export type OwidProcessingLevel = "minor" | "major"
78
-
79
- export interface FaqLink {
80
- gdocId: string
81
- fragmentId: string
82
- }
83
-
84
- export type OwidVariableWithSourceAndDimension = OwidVariableWithSource & {
85
- dimensions: OwidVariableDimensions
86
- }
87
-
88
- export type OwidVariableWithSourceAndDimensionWithoutId = Omit<
89
- OwidVariableWithSourceAndDimension,
90
- "id"
91
- >
92
-
93
- export interface OwidVariableMixedData {
94
- years: number[]
95
- entities: number[]
96
- values: (string | number)[]
97
- }
98
-
99
- export type OwidVariableWithDataAndSource = OwidVariableWithSource &
100
- OwidVariableMixedData
101
-
102
- export interface OwidVariableDimension {
103
- values: OwidVariableDimensionValuePartial[]
104
- }
105
-
106
- export interface OwidVariableDimensions {
107
- years: OwidVariableDimension
108
- entities: OwidVariableDimension
109
- values?: OwidVariableDimension
110
- }
111
-
112
- export type OwidVariableDataMetadataDimensions = {
113
- data: OwidVariableMixedData
114
- metadata: OwidVariableWithSourceAndDimension
115
- }
116
- export type MultipleOwidVariableDataDimensionsMap = Map<
117
- number,
118
- OwidVariableDataMetadataDimensions
119
- >
120
-
121
- export interface OwidVariableDimensionValuePartial {
122
- id: number
123
- name?: string
124
- code?: string
125
- }
126
- export type OwidVariableDimensionValueFull =
127
- Required<OwidVariableDimensionValuePartial>
128
-
129
- export interface OwidEntityKey {
130
- [id: string]: OwidVariableDimensionValuePartial
131
- }
132
-
133
- export type OwidVariableType = "string" | "float" | "int" | "mixed" | "ordinal"