@buildcanada/charts 0.1.0 → 0.2.0

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 (127) hide show
  1. package/package.json +9 -24
  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/ContentSwitchers.tsx +1 -1
  43. package/src/grapher/controls/DataTableFilterDropdown.tsx +2 -2
  44. package/src/grapher/controls/MapZoomDropdown.tsx +3 -3
  45. package/src/grapher/controls/ShareMenu.tsx +1 -1
  46. package/src/grapher/controls/entityPicker/EntityPicker.tsx +8 -8
  47. package/src/grapher/controls/entityPicker/EntityPickerConstants.ts +3 -3
  48. package/src/grapher/controls/globalEntitySelector/GlobalEntitySelector.tsx +1 -1
  49. package/src/grapher/core/EntitiesByRegionType.ts +4 -4
  50. package/src/grapher/core/EntityUrlBuilder.ts +2 -2
  51. package/src/grapher/core/FetchingGrapher.tsx +4 -4
  52. package/src/grapher/core/Grapher.tsx +10 -10
  53. package/src/grapher/core/GrapherState.tsx +47 -50
  54. package/src/grapher/core/GrapherUseHelpers.tsx +4 -4
  55. package/src/grapher/core/{LegacyToOwidTable.ts → LegacyToChartsTable.ts} +100 -100
  56. package/src/grapher/core/loadGrapherTableHelpers.ts +13 -13
  57. package/src/grapher/core/loadVariable.ts +5 -5
  58. package/src/grapher/dataTable/DataTable.sample.ts +12 -12
  59. package/src/grapher/dataTable/DataTable.tsx +22 -22
  60. package/src/grapher/dataTable/DataTableConstants.ts +9 -9
  61. package/src/grapher/entitySelector/EntitySelector.tsx +13 -13
  62. package/src/grapher/facet/FacetChart.tsx +4 -4
  63. package/src/grapher/facet/FacetMap.tsx +6 -6
  64. package/src/grapher/footer/Footer.tsx +4 -4
  65. package/src/grapher/footer/FooterManager.ts +2 -2
  66. package/src/grapher/header/Header.tsx +5 -5
  67. package/src/grapher/header/HeaderManager.ts +1 -1
  68. package/src/grapher/index.ts +8 -8
  69. package/src/grapher/lineCharts/LineChartHelpers.ts +4 -4
  70. package/src/grapher/lineCharts/LineChartState.ts +9 -9
  71. package/src/grapher/mapCharts/ChoroplethGlobe.tsx +1 -1
  72. package/src/grapher/mapCharts/GlobeController.ts +9 -9
  73. package/src/grapher/mapCharts/MapChartState.ts +16 -16
  74. package/src/grapher/mapCharts/MapSparkline.tsx +5 -5
  75. package/src/grapher/mapCharts/MapTooltip.tsx +13 -13
  76. package/src/grapher/modal/DownloadModal.scss +3 -3
  77. package/src/grapher/modal/DownloadModal.tsx +24 -29
  78. package/src/grapher/modal/SourcesDescriptions.scss +1 -1
  79. package/src/grapher/modal/SourcesKeyDataTable.tsx +2 -2
  80. package/src/grapher/modal/SourcesModal.tsx +15 -15
  81. package/src/grapher/scatterCharts/ScatterPlotChart.tsx +2 -2
  82. package/src/grapher/scatterCharts/ScatterPlotChartConstants.ts +2 -2
  83. package/src/grapher/scatterCharts/ScatterPlotChartState.ts +8 -8
  84. package/src/grapher/scatterCharts/ScatterSizeLegend.tsx +2 -2
  85. package/src/grapher/scatterCharts/ScatterUtils.ts +2 -2
  86. package/src/grapher/schema/grapher-schema.009.yaml +18 -18
  87. package/src/grapher/schema/migrations/migrations.ts +4 -4
  88. package/src/grapher/selection/MapSelectionArray.ts +1 -1
  89. package/src/grapher/selection/readme.md +1 -1
  90. package/src/grapher/slopeCharts/SlopeChartConstants.ts +3 -3
  91. package/src/grapher/slopeCharts/SlopeChartHelpers.ts +1 -1
  92. package/src/grapher/slopeCharts/SlopeChartState.ts +10 -10
  93. package/src/grapher/stackedCharts/AbstractStackedChartState.ts +8 -8
  94. package/src/grapher/stackedCharts/MarimekkoChart.tsx +5 -5
  95. package/src/grapher/stackedCharts/MarimekkoChartConstants.ts +2 -2
  96. package/src/grapher/stackedCharts/MarimekkoChartState.ts +12 -12
  97. package/src/grapher/stackedCharts/StackedBarChartState.ts +1 -1
  98. package/src/grapher/stackedCharts/StackedConstants.ts +2 -2
  99. package/src/grapher/stackedCharts/StackedDiscreteBarChartState.ts +12 -12
  100. package/src/grapher/stackedCharts/StackedDiscreteBars.tsx +2 -2
  101. package/src/grapher/tabs/Tabs.tsx +1 -1
  102. package/src/grapher/testData/{OwidTestData.sample.ts → TestData.sample.ts} +7 -7
  103. package/src/grapher/testData/{OwidTestData.ts → TestData.ts} +5 -5
  104. package/src/index.ts +7 -7
  105. package/src/types/{OwidOrigin.ts → Origin.ts} +3 -3
  106. package/src/types/{OwidSource.ts → Source.ts} +1 -1
  107. package/src/types/Variable.ts +133 -0
  108. package/src/types/{OwidVariableDisplayConfigInterface.ts → VariableDisplayConfigInterface.ts} +11 -11
  109. package/src/types/domainTypes/ContentGraph.ts +3 -3
  110. package/src/types/domainTypes/CoreTableTypes.ts +29 -29
  111. package/src/types/domainTypes/Posts.ts +2 -2
  112. package/src/types/domainTypes/Search.ts +6 -6
  113. package/src/types/domainTypes/Various.ts +1 -1
  114. package/src/types/gdocTypes/Gdoc.ts +42 -42
  115. package/src/types/grapherTypes/GrapherTypes.ts +21 -21
  116. package/src/types/index.ts +51 -51
  117. package/src/utils/MultiDimDataPageConfig.ts +1 -1
  118. package/src/utils/Util.ts +61 -55
  119. package/src/utils/{OwidVariable.ts → Variable.ts} +15 -15
  120. package/src/utils/formatValue.ts +12 -12
  121. package/src/utils/image.ts +12 -12
  122. package/src/utils/index.ts +5 -5
  123. package/src/utils/metadataHelpers.ts +19 -19
  124. package/src/utils/regions.ts +9 -9
  125. package/LICENSE.md +0 -8
  126. package/README.md +0 -113
  127. package/src/types/OwidVariable.ts +0 -133
@@ -1,6 +1,6 @@
1
1
  /**
2
2
  * Stub types for Google Docs integration.
3
- * These are simplified versions of the full OWID gdocTypes.
3
+ * These are simplified versions of the full gdocTypes.
4
4
  * Most Google Docs CMS functionality is not needed for the standalone charts library,
5
5
  * but the types are required for compilation.
6
6
  */
@@ -9,9 +9,9 @@ import { QueryParams } from "../domainTypes/Various.js"
9
9
  import { ArchivedPageVersion } from "../domainTypes/Archive.js"
10
10
 
11
11
  /**
12
- * Document types in the OWID CMS.
12
+ * Document types in the CMS.
13
13
  */
14
- export enum OwidGdocType {
14
+ export enum GdocType {
15
15
  Article = "article",
16
16
  TopicPage = "topic-page",
17
17
  LinearTopicPage = "linear-topic-page",
@@ -69,10 +69,10 @@ export interface UserCountryInformation {
69
69
  /**
70
70
  * Base interface for Gdoc content.
71
71
  */
72
- export interface OwidGdocBaseInterface {
72
+ export interface GdocBaseInterface {
73
73
  id: string
74
74
  slug: string
75
- content: OwidGdocContent
75
+ content: GdocContent
76
76
  published: boolean
77
77
  createdAt: Date
78
78
  publishedAt: Date | null
@@ -100,30 +100,30 @@ export interface OwidGdocBaseInterface {
100
100
  /**
101
101
  * Gdoc content type.
102
102
  */
103
- export interface OwidGdocContent {
104
- type: OwidGdocType
103
+ export interface GdocContent {
104
+ type: GdocType
105
105
  title?: string
106
- body?: OwidEnrichedGdocBlock[]
106
+ body?: EnrichedGdocBlock[]
107
107
  [key: string]: unknown
108
108
  }
109
109
 
110
110
  /**
111
111
  * Generic Gdoc interface.
112
112
  */
113
- export type OwidGdoc =
114
- | OwidGdocPostInterface
115
- | OwidGdocDataInsightInterface
116
- | OwidGdocAuthorInterface
117
- | OwidGdocAboutInterface
118
- | OwidGdocHomepageInterface
113
+ export type Gdoc =
114
+ | GdocPostInterface
115
+ | GdocDataInsightInterface
116
+ | GdocAuthorInterface
117
+ | GdocAboutInterface
118
+ | GdocHomepageInterface
119
119
 
120
120
  /**
121
121
  * JSON representation of a Gdoc.
122
122
  */
123
- export interface OwidGdocJSON {
123
+ export interface GdocJSON {
124
124
  id: string
125
125
  slug: string
126
- content: OwidGdocContent
126
+ content: GdocContent
127
127
  published: boolean
128
128
  createdAt: string
129
129
  publishedAt: string | null
@@ -134,61 +134,61 @@ export interface OwidGdocJSON {
134
134
  /**
135
135
  * Post (article/topic page) interface.
136
136
  */
137
- export interface OwidGdocPostInterface extends OwidGdocBaseInterface {
138
- content: OwidGdocPostContent
137
+ export interface GdocPostInterface extends GdocBaseInterface {
138
+ content: GdocPostContent
139
139
  }
140
140
 
141
- export interface OwidGdocPostContent extends OwidGdocContent {
141
+ export interface GdocPostContent extends GdocContent {
142
142
  type:
143
- | OwidGdocType.Article
144
- | OwidGdocType.TopicPage
145
- | OwidGdocType.LinearTopicPage
146
- | OwidGdocType.Fragment
147
- | OwidGdocType.AboutPage
143
+ | GdocType.Article
144
+ | GdocType.TopicPage
145
+ | GdocType.LinearTopicPage
146
+ | GdocType.Fragment
147
+ | GdocType.AboutPage
148
148
  }
149
149
 
150
150
  /**
151
151
  * Data insight interface.
152
152
  */
153
- export interface OwidGdocDataInsightInterface extends OwidGdocBaseInterface {
154
- content: OwidGdocDataInsightContent
153
+ export interface GdocDataInsightInterface extends GdocBaseInterface {
154
+ content: GdocDataInsightContent
155
155
  }
156
156
 
157
- export interface OwidGdocDataInsightContent extends OwidGdocContent {
158
- type: OwidGdocType.DataInsight
157
+ export interface GdocDataInsightContent extends GdocContent {
158
+ type: GdocType.DataInsight
159
159
  }
160
160
 
161
161
  /**
162
162
  * Author interface.
163
163
  */
164
- export interface OwidGdocAuthorInterface extends OwidGdocBaseInterface {
165
- content: OwidGdocAuthorContent
164
+ export interface GdocAuthorInterface extends GdocBaseInterface {
165
+ content: GdocAuthorContent
166
166
  }
167
167
 
168
- export interface OwidGdocAuthorContent extends OwidGdocContent {
169
- type: OwidGdocType.Author
168
+ export interface GdocAuthorContent extends GdocContent {
169
+ type: GdocType.Author
170
170
  }
171
171
 
172
172
  /**
173
173
  * About page interface.
174
174
  */
175
- export interface OwidGdocAboutInterface extends OwidGdocBaseInterface {
176
- content: OwidGdocAboutContent
175
+ export interface GdocAboutInterface extends GdocBaseInterface {
176
+ content: GdocAboutContent
177
177
  }
178
178
 
179
- export interface OwidGdocAboutContent extends OwidGdocContent {
180
- type: OwidGdocType.AboutPage
179
+ export interface GdocAboutContent extends GdocContent {
180
+ type: GdocType.AboutPage
181
181
  }
182
182
 
183
183
  /**
184
184
  * Homepage interface.
185
185
  */
186
- export interface OwidGdocHomepageInterface extends OwidGdocBaseInterface {
187
- content: OwidGdocHomepageContent
186
+ export interface GdocHomepageInterface extends GdocBaseInterface {
187
+ content: GdocHomepageContent
188
188
  }
189
189
 
190
- export interface OwidGdocHomepageContent extends OwidGdocContent {
191
- type: OwidGdocType.Homepage
190
+ export interface GdocHomepageContent extends GdocContent {
191
+ type: GdocType.Homepage
192
192
  }
193
193
 
194
194
  // =====================================================
@@ -198,7 +198,7 @@ export interface OwidGdocHomepageContent extends OwidGdocContent {
198
198
  /**
199
199
  * Base interface for enriched Gdoc blocks.
200
200
  */
201
- export interface OwidEnrichedGdocBlock {
201
+ export interface EnrichedGdocBlock {
202
202
  type: string
203
203
  parseErrors?: unknown[]
204
204
  [key: string]: unknown
@@ -216,7 +216,7 @@ export interface Span {
216
216
  /**
217
217
  * Key insights slide block.
218
218
  */
219
- export interface EnrichedBlockKeyInsightsSlide extends OwidEnrichedGdocBlock {
219
+ export interface EnrichedBlockKeyInsightsSlide extends EnrichedGdocBlock {
220
220
  type: "key-insights-slide"
221
221
  title?: string
222
222
  [key: string]: unknown
@@ -1,10 +1,10 @@
1
1
  import {
2
- OwidChartDimensionInterface,
3
- OwidVariableRoundingMode,
4
- } from "../OwidVariableDisplayConfigInterface.js"
2
+ ChartDimensionInterface,
3
+ VariableRoundingMode,
4
+ } from "../VariableDisplayConfigInterface.js"
5
5
  import { ColumnSlugs, EntityName } from "../domainTypes/CoreTableTypes.js"
6
6
  import { AxisAlign, Position } from "../domainTypes/Layout.js"
7
- import { Integer, OwidVariableId } from "../domainTypes/Various.js"
7
+ import { Integer, VariableId } from "../domainTypes/Various.js"
8
8
  import { DetailDictionary } from "../gdocTypes/Gdoc.js"
9
9
  import {
10
10
  GRAPHER_CHART_TYPES,
@@ -13,7 +13,7 @@ import {
13
13
  GRAPHER_TAB_CONFIG_OPTIONS,
14
14
  GRAPHER_TAB_QUERY_PARAMS,
15
15
  } from "./GrapherConstants.js"
16
- import { OwidVariableDataMetadataDimensions } from "../OwidVariable.js"
16
+ import { VariableDataMetadataDimensions } from "../Variable.js"
17
17
  import { ArchiveContext } from "../domainTypes/Archive.js"
18
18
  import {
19
19
  BinningStrategyIncludingManual,
@@ -233,7 +233,7 @@ export interface Tickmark {
233
233
  solid?: boolean // mostly for labelling domain start (e.g. 0)
234
234
  }
235
235
  export interface TickFormattingOptions {
236
- roundingMode?: OwidVariableRoundingMode
236
+ roundingMode?: VariableRoundingMode
237
237
  numDecimalPlaces?: number
238
238
  numSignificantFigures?: number
239
239
  unit?: string
@@ -339,9 +339,9 @@ export type ComparisonLineConfig =
339
339
  | CustomComparisonLineConfig
340
340
 
341
341
  export enum LogoOption {
342
- owid = "owid",
343
- "core+owid" = "core+owid",
344
- "gv+owid" = "gv+owid",
342
+ legacy = "legacy",
343
+ "core+legacy" = "core+legacy",
344
+ "gv+legacy" = "gv+legacy",
345
345
  buildcanada = "buildcanada",
346
346
  "buildcanada-wide" = "buildcanada-wide",
347
347
  canadaspends = "canadaspends",
@@ -441,20 +441,20 @@ export enum ColorSchemeName {
441
441
  Viridis = "Viridis",
442
442
  continents = "continents",
443
443
  stackedAreaDefault = "stackedAreaDefault",
444
- "owid-distinct" = "owid-distinct",
444
+ "distinct" = "distinct",
445
445
  SingleColorDenim = "SingleColorDenim",
446
446
  SingleColorTeal = "SingleColorTeal",
447
447
  SingleColorPurple = "SingleColorPurple",
448
448
  SingleColorDustyCoral = "SingleColorDustyCoral",
449
449
  SingleColorDarkCopper = "SingleColorDarkCopper",
450
- OwidCategoricalA = "OwidCategoricalA",
451
- OwidCategoricalB = "OwidCategoricalB",
452
- OwidCategoricalC = "OwidCategoricalC",
453
- OwidCategoricalD = "OwidCategoricalD",
454
- OwidCategoricalE = "OwidCategoricalE",
455
- OwidEnergy = "OwidEnergy",
456
- OwidEnergyLines = "OwidEnergyLines",
457
- OwidDistinctLines = "OwidDistinctLines",
450
+ CategoricalA = "CategoricalA",
451
+ CategoricalB = "CategoricalB",
452
+ CategoricalC = "CategoricalC",
453
+ CategoricalD = "CategoricalD",
454
+ CategoricalE = "CategoricalE",
455
+ Energy = "Energy",
456
+ EnergyLines = "EnergyLines",
457
+ DistinctLines = "DistinctLines",
458
458
  BinaryMapPaletteA = "BinaryMapPaletteA",
459
459
  BinaryMapPaletteB = "BinaryMapPaletteB",
460
460
  BinaryMapPaletteC = "BinaryMapPaletteC",
@@ -520,7 +520,7 @@ export interface GrapherInterface extends SortConfig {
520
520
  maxTime?: TimeBound | TimeBoundValueStr
521
521
  timelineMinTime?: Time | TimeBoundValueStr
522
522
  timelineMaxTime?: Time | TimeBoundValueStr
523
- dimensions?: OwidChartDimensionInterface[]
523
+ dimensions?: ChartDimensionInterface[]
524
524
  addCountryMode?: EntitySelectionMode
525
525
  comparisonLines?: ComparisonLineConfig[]
526
526
  stackMode?: StackMode
@@ -736,8 +736,8 @@ export enum GrapherWindowType {
736
736
  }
737
737
 
738
738
  export type AdditionalGrapherDataFetchFn = (
739
- varId: OwidVariableId,
739
+ varId: VariableId,
740
740
  loadMetadataOnly?: boolean
741
- ) => Promise<OwidVariableDataMetadataDimensions>
741
+ ) => Promise<VariableDataMetadataDimensions>
742
742
 
743
743
  export type GrapherTrendArrowDirection = "up" | "right" | "down"
@@ -14,7 +14,7 @@ export {
14
14
  JsonError,
15
15
  type JsonString,
16
16
  type SerializedGridProgram,
17
- type OwidVariableId,
17
+ type VariableId,
18
18
  type QueryParams,
19
19
  } from "./domainTypes/Various.js"
20
20
 
@@ -41,18 +41,18 @@ export {
41
41
  type CoreTableInputOption,
42
42
  type CoreQuery,
43
43
  type CoreMatrix,
44
- OwidTableSlugs,
44
+ ChartsTableSlugs,
45
45
  type EntityName,
46
46
  type EntityCode,
47
47
  type EntityId,
48
48
  type Entity,
49
- type OwidColumnDef,
50
- OwidEntityNameColumnDef,
51
- OwidEntityIdColumnDef,
52
- OwidEntityCodeColumnDef,
53
- StandardOwidColumnDefs,
54
- type OwidRow,
55
- type OwidVariableRow,
49
+ type ColumnDef,
50
+ EntityNameColumnDef,
51
+ EntityIdColumnDef,
52
+ EntityCodeColumnDef,
53
+ StandardColumnDefs,
54
+ type Row,
55
+ type VariableRow,
56
56
  ColumnTypeNames,
57
57
  type ColumnColorScale,
58
58
  type CoreColumnDef,
@@ -158,36 +158,36 @@ export {
158
158
 
159
159
  // Variable types
160
160
  export {
161
- type OwidVariableWithSource,
162
- type OwidVariableWithSourceAndDimension,
163
- type OwidVariableWithSourceAndDimensionWithoutId,
164
- type OwidVariableMixedData,
165
- type OwidVariableWithDataAndSource,
166
- type OwidVariableDimension,
167
- type OwidVariableDimensions,
168
- type OwidVariableDataMetadataDimensions,
169
- type MultipleOwidVariableDataDimensionsMap,
170
- type OwidVariableDimensionValuePartial,
171
- type OwidVariableDimensionValueFull,
172
- type OwidVariablePresentation,
173
- type OwidEntityKey,
174
- type OwidLicense,
175
- type OwidProcessingLevel,
161
+ type VariableWithSource,
162
+ type VariableWithSourceAndDimension,
163
+ type VariableWithSourceAndDimensionWithoutId,
164
+ type VariableMixedData,
165
+ type VariableWithDataAndSource,
166
+ type VariableDimension,
167
+ type VariableDimensions,
168
+ type VariableDataMetadataDimensions,
169
+ type MultipleVariableDataDimensionsMap,
170
+ type VariableDimensionValuePartial,
171
+ type VariableDimensionValueFull,
172
+ type VariablePresentation,
173
+ type EntityKey,
174
+ type License,
175
+ type ProcessingLevel,
176
176
  type IndicatorTitleWithFragments,
177
177
  joinTitleFragments,
178
- type OwidVariableType,
179
- } from "./OwidVariable.js"
178
+ type VariableType,
179
+ } from "./Variable.js"
180
180
 
181
- export type { OwidSource } from "./OwidSource.js"
182
- export type { OwidOrigin } from "./OwidOrigin.js"
181
+ export type { Source } from "./Source.js"
182
+ export type { Origin } from "./Origin.js"
183
183
 
184
184
  export {
185
- type OwidVariableDisplayConfigInterface,
186
- type OwidVariableDataTableConfigInterface,
187
- OwidVariableRoundingMode,
188
- type OwidChartDimensionInterface,
189
- type OwidChartDimensionInterfaceWithMandatorySlug,
190
- } from "./OwidVariableDisplayConfigInterface.js"
185
+ type VariableDisplayConfigInterface,
186
+ type VariableDataTableConfigInterface,
187
+ VariableRoundingMode,
188
+ type ChartDimensionInterface,
189
+ type ChartDimensionInterfaceWithMandatorySlug,
190
+ } from "./VariableDisplayConfigInterface.js"
191
191
 
192
192
  export { type Nominal, wrap, unwrap } from "./NominalType.js"
193
193
 
@@ -202,26 +202,26 @@ export {
202
202
 
203
203
  // Gdoc types (stubs for type compatibility)
204
204
  export {
205
- OwidGdocType,
205
+ GdocType,
206
206
  type NarrativeChartInfo,
207
207
  type DetailDictionary,
208
208
  type EnrichedDetail,
209
209
  type UserCountryInformation,
210
- type OwidGdocBaseInterface,
211
- type OwidGdocContent,
212
- type OwidGdoc,
213
- type OwidGdocJSON,
214
- type OwidGdocPostInterface,
215
- type OwidGdocPostContent,
216
- type OwidGdocDataInsightInterface,
217
- type OwidGdocDataInsightContent,
218
- type OwidGdocAuthorInterface,
219
- type OwidGdocAuthorContent,
220
- type OwidGdocAboutInterface,
221
- type OwidGdocAboutContent,
222
- type OwidGdocHomepageInterface,
223
- type OwidGdocHomepageContent,
224
- type OwidEnrichedGdocBlock,
210
+ type GdocBaseInterface,
211
+ type GdocContent,
212
+ type Gdoc,
213
+ type GdocJSON,
214
+ type GdocPostInterface,
215
+ type GdocPostContent,
216
+ type GdocDataInsightInterface,
217
+ type GdocDataInsightContent,
218
+ type GdocAuthorInterface,
219
+ type GdocAuthorContent,
220
+ type GdocAboutInterface,
221
+ type GdocAboutContent,
222
+ type GdocHomepageInterface,
223
+ type GdocHomepageContent,
224
+ type EnrichedGdocBlock,
225
225
  type Span,
226
226
  type EnrichedBlockKeyInsightsSlide,
227
227
  type EnrichedTopicPageIntroRelatedTopic,
@@ -300,7 +300,7 @@ export interface TagGraphNode {
300
300
 
301
301
  export const TagGraphRootName = "tag-graph-root" as const
302
302
 
303
- export type TagGraphRoot = TagGraphNode & {
303
+ export interface TagGraphRoot {
304
304
  children: TagGraphNode[]
305
305
  id: number
306
306
  isTopic: false
@@ -1,6 +1,6 @@
1
1
  /**
2
2
  * Stub for MultiDimDataPageConfig.
3
- * Multi-dimensional data page configurations are specific to OWID's data pages.
3
+ * Multi-dimensional data page configurations are specific to data pages.
4
4
  */
5
5
 
6
6
  export interface MultiDimDataPageConfigRaw {
package/src/utils/Util.ts CHANGED
@@ -17,17 +17,17 @@ import {
17
17
  VerticalAlign,
18
18
  type GridParameters,
19
19
  HorizontalAlign,
20
- type OwidEnrichedGdocBlock,
20
+ type EnrichedGdocBlock,
21
21
  type EnrichedBlockKeyInsightsSlide,
22
22
  type EnrichedTopicPageIntroRelatedTopic,
23
23
  type EnrichedTopicPageIntroDownloadButton,
24
24
  type EnrichedHybridLink,
25
- type OwidGdocPostInterface,
26
- type OwidGdocDataInsightInterface,
27
- type OwidGdocAuthorInterface,
28
- type OwidGdoc,
29
- OwidGdocType,
30
- type OwidGdocJSON,
25
+ type GdocPostInterface,
26
+ type GdocDataInsightInterface,
27
+ type GdocAuthorInterface,
28
+ type Gdoc,
29
+ GdocType,
30
+ type GdocJSON,
31
31
  type Span,
32
32
  UserCountryInformation,
33
33
  Time,
@@ -40,8 +40,8 @@ import {
40
40
  GRAPHER_CHART_TYPES,
41
41
  DbPlainTag,
42
42
  AssetMap,
43
- OwidGdocAboutInterface,
44
- OwidGdocHomepageInterface,
43
+ GdocAboutInterface,
44
+ GdocHomepageInterface,
45
45
  PrimitiveType,
46
46
  GrapherTrendArrowDirection,
47
47
  TocHeadingWithTitleSupertitle,
@@ -533,10 +533,16 @@ export async function fetchWithTimeout(
533
533
  })
534
534
  }
535
535
 
536
+ // Country detection service URL - can be configured for custom deployments
537
+ // This service should return JSON with a "country" object containing "code" and "name"
538
+ const COUNTRY_DETECTION_URL =
539
+ (typeof process !== "undefined" && process.env?.COUNTRY_DETECTION_URL) ||
540
+ "https://detect-country.example.com"
541
+
536
542
  const _getUserCountryInformation = async (): Promise<
537
543
  UserCountryInformation | undefined
538
544
  > =>
539
- await fetchWithRetry("https://detect-country.owid.io")
545
+ await fetchWithRetry(COUNTRY_DETECTION_URL)
540
546
  .then((res) => res.json())
541
547
  .then((res) => res.country)
542
548
  .catch(() => undefined)
@@ -1251,7 +1257,7 @@ export const formatDate = (date: Date): string => {
1251
1257
  * write a custom JSON parser to handle that automatically for all keys. At this
1252
1258
  * stage, the manual approach is probably simpler.
1253
1259
  */
1254
- export const getOwidGdocFromJSON = (json: OwidGdocJSON): OwidGdoc => {
1260
+ export const getGdocFromJSON = (json: GdocJSON): Gdoc => {
1255
1261
  return {
1256
1262
  ...json,
1257
1263
  createdAt: new Date(json.createdAt),
@@ -1263,7 +1269,7 @@ export const getOwidGdocFromJSON = (json: OwidGdocJSON): OwidGdoc => {
1263
1269
  // We want to infer the return type from the existing types instead of having to
1264
1270
  // manually specify it.
1265
1271
  // eslint-disable-next-line @typescript-eslint/explicit-function-return-type, @typescript-eslint/explicit-module-boundary-types
1266
- export function extractGdocPageData(gdoc: OwidGdoc) {
1272
+ export function extractGdocPageData(gdoc: Gdoc) {
1267
1273
  // Generic properties every gdoc has
1268
1274
  const gdocProps = R.pick(gdoc, [
1269
1275
  "id",
@@ -1327,10 +1333,10 @@ export function extractGdocPageData(gdoc: OwidGdoc) {
1327
1333
  .otherwise(() => commonProps)
1328
1334
  }
1329
1335
 
1330
- export type OwidGdocPageProps = ReturnType<typeof extractGdocPageData>
1336
+ export type GdocPageProps = ReturnType<typeof extractGdocPageData>
1331
1337
 
1332
- export type OwidGdocPageData = Omit<
1333
- OwidGdocPageProps,
1338
+ export type GdocPageData = Omit<
1339
+ GdocPageProps,
1334
1340
  "createdAt" | "publishedAt" | "updatedAt"
1335
1341
  > & {
1336
1342
  createdAt: string
@@ -1338,11 +1344,11 @@ export type OwidGdocPageData = Omit<
1338
1344
  updatedAt: string | null
1339
1345
  }
1340
1346
 
1341
- export function deserializeOwidGdocPageData(
1342
- json: OwidGdocPageData
1343
- ): OwidGdocPageProps {
1347
+ export function deserializeGdocPageData(
1348
+ json: GdocPageData
1349
+ ): GdocPageProps {
1344
1350
  // NOTE: We have to do manual type casting around the content.type property
1345
- // because it can be undefined in OwidGdocPostContent. That makes sense
1351
+ // because it can be undefined in GdocPostContent. That makes sense
1346
1352
  // during the gdoc creation, where we do manual validation for various
1347
1353
  // properties. But at some point we should only pass around a valid gdoc
1348
1354
  // where content.type can't be undefined anymore. So we should likely create
@@ -1353,7 +1359,7 @@ export function deserializeOwidGdocPageData(
1353
1359
  createdAt: new Date(json.createdAt),
1354
1360
  publishedAt: json.publishedAt ? new Date(json.publishedAt) : null,
1355
1361
  updatedAt: json.updatedAt ? new Date(json.updatedAt) : null,
1356
- } as OwidGdocPageProps
1362
+ } as GdocPageProps
1357
1363
  }
1358
1364
 
1359
1365
  // Checking whether we have clipboard write access is surprisingly complicated.
@@ -1516,7 +1522,7 @@ export function bind<This, Args extends any[], Return>(
1516
1522
  // It's more than just the EnrichedBlocks and Spans, because some EnrichedBlocks have nested children
1517
1523
  // that contain URLs/filenames
1518
1524
  export type NodeWithUrl =
1519
- | OwidEnrichedGdocBlock
1525
+ | EnrichedGdocBlock
1520
1526
  | Span
1521
1527
  | EnrichedHybridLink
1522
1528
  | EnrichedTopicPageIntroRelatedTopic
@@ -1593,13 +1599,13 @@ export function traverseEnrichedSpan(
1593
1599
  .exhaustive()
1594
1600
  }
1595
1601
 
1596
- // If your node is a OwidEnrichedGdocBlock, the callback will apply to it
1602
+ // If your node is a EnrichedGdocBlock, the callback will apply to it
1597
1603
  // If your node has children that are Spans, the spanCallback will apply to them
1598
- // If your node has children that aren't OwidEnrichedGdocBlocks or Spans
1604
+ // If your node has children that aren't EnrichedGdocBlocks or Spans
1599
1605
  // you'll have to handle those children yourself in your callback
1600
1606
  export function traverseEnrichedBlock(
1601
- node: OwidEnrichedGdocBlock,
1602
- callback: (x: OwidEnrichedGdocBlock) => void,
1607
+ node: EnrichedGdocBlock,
1608
+ callback: (x: EnrichedGdocBlock) => void,
1603
1609
  spanCallback?: (x: Span) => void
1604
1610
  ): void {
1605
1611
  match(node)
@@ -1860,7 +1866,7 @@ export function spansToUnformattedPlainText(spans: Span[]): string {
1860
1866
  }
1861
1867
 
1862
1868
  export function generateToc(
1863
- body: OwidEnrichedGdocBlock[] | undefined,
1869
+ body: EnrichedGdocBlock[] | undefined,
1864
1870
  isTocForLinearTopicPage: boolean = false
1865
1871
  ): TocHeadingWithTitleSupertitle[] {
1866
1872
  if (!body) return []
@@ -1930,10 +1936,10 @@ export function generateToc(
1930
1936
  return toc
1931
1937
  }
1932
1938
 
1933
- export function checkIsOwidGdocType(
1939
+ export function checkIsGdocType(
1934
1940
  gdocType: unknown
1935
- ): gdocType is OwidGdocType {
1936
- return Object.values(OwidGdocType).includes(gdocType as any)
1941
+ ): gdocType is GdocType {
1942
+ return Object.values(GdocType).includes(gdocType as any)
1937
1943
  }
1938
1944
 
1939
1945
  export function isArrayOfNumbers(arr: unknown[]): arr is number[] {
@@ -1977,16 +1983,16 @@ export function extractDetailsFromSyntax(str: string): string[] {
1977
1983
 
1978
1984
  /**
1979
1985
  * If you're using this type guard, make sure you're okay with Fragments
1980
- * See https://github.com/owid/owid-grapher/issues/3426
1986
+ * See # legacy issue 3426
1981
1987
  */
1982
- export function checkIsGdocPost(x: unknown): x is OwidGdocPostInterface {
1983
- const type = _.get(x, "content.type") as OwidGdocType | undefined
1988
+ export function checkIsGdocPost(x: unknown): x is GdocPostInterface {
1989
+ const type = _.get(x, "content.type") as GdocType | undefined
1984
1990
  return [
1985
- OwidGdocType.Article,
1986
- OwidGdocType.TopicPage,
1987
- OwidGdocType.LinearTopicPage,
1988
- OwidGdocType.Fragment,
1989
- OwidGdocType.AboutPage,
1991
+ GdocType.Article,
1992
+ GdocType.TopicPage,
1993
+ GdocType.LinearTopicPage,
1994
+ GdocType.Fragment,
1995
+ GdocType.AboutPage,
1990
1996
  ].includes(type as any)
1991
1997
  }
1992
1998
 
@@ -1994,40 +2000,40 @@ export function checkIsGdocPost(x: unknown): x is OwidGdocPostInterface {
1994
2000
  * Fragments were developed before we had a robust gdoc type system in place
1995
2001
  * Use this function when you want to be sure you're dealing with published editorial content
1996
2002
  * and not just content that has the right shape
1997
- * See https://github.com/owid/owid-grapher/issues/3426
2003
+ * See # legacy issue 3426
1998
2004
  */
1999
2005
  export function checkIsGdocPostExcludingFragments(
2000
2006
  x: unknown
2001
- ): x is OwidGdocPostInterface {
2002
- const type = _.get(x, "content.type") as OwidGdocType | undefined
2007
+ ): x is GdocPostInterface {
2008
+ const type = _.get(x, "content.type") as GdocType | undefined
2003
2009
  return [
2004
- OwidGdocType.Article,
2005
- OwidGdocType.TopicPage,
2006
- OwidGdocType.LinearTopicPage,
2007
- OwidGdocType.AboutPage,
2010
+ GdocType.Article,
2011
+ GdocType.TopicPage,
2012
+ GdocType.LinearTopicPage,
2013
+ GdocType.AboutPage,
2008
2014
  ].includes(type as any)
2009
2015
  }
2010
2016
 
2011
2017
  export function checkIsDataInsight(
2012
- gdoc: OwidGdoc
2013
- ): gdoc is OwidGdocDataInsightInterface {
2014
- return gdoc.content.type === OwidGdocType.DataInsight
2018
+ gdoc: Gdoc
2019
+ ): gdoc is GdocDataInsightInterface {
2020
+ return gdoc.content.type === GdocType.DataInsight
2015
2021
  }
2016
2022
 
2017
2023
  export function checkIsAboutPage(
2018
- gdoc: OwidGdoc
2019
- ): gdoc is OwidGdocAboutInterface {
2020
- return gdoc.content.type === OwidGdocType.AboutPage
2024
+ gdoc: Gdoc
2025
+ ): gdoc is GdocAboutInterface {
2026
+ return gdoc.content.type === GdocType.AboutPage
2021
2027
  }
2022
2028
 
2023
- export function checkIsAuthor(gdoc: OwidGdoc): gdoc is OwidGdocAuthorInterface {
2024
- return gdoc.content.type === OwidGdocType.Author
2029
+ export function checkIsAuthor(gdoc: Gdoc): gdoc is GdocAuthorInterface {
2030
+ return gdoc.content.type === GdocType.Author
2025
2031
  }
2026
2032
 
2027
2033
  export function checkIsHomepage(
2028
- gdoc: OwidGdoc
2029
- ): gdoc is OwidGdocHomepageInterface {
2030
- return gdoc.content.type === OwidGdocType.Homepage
2034
+ gdoc: Gdoc
2035
+ ): gdoc is GdocHomepageInterface {
2036
+ return gdoc.content.type === GdocType.Homepage
2031
2037
  }
2032
2038
 
2033
2039
  /**