Skip to content

Commit 91c9c2e

Browse files
committed
Updated data manager components
1 parent 3ad5433 commit 91c9c2e

File tree

11 files changed

+53
-27
lines changed

11 files changed

+53
-27
lines changed

packages/column-views/CHANGELOG.md

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,14 @@ All notable changes to this project will be documented in this file. The format
44
is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/), and this
55
project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
66

7+
## [3.1.0] - 2026-01-31
8+
9+
- Moved `MacrostratDataProvider` and data fetchers to
10+
`@macrostrat/data-provider` for better modularity.
11+
- Standardize approach to clickable/linkable data items in `UnitDetailsPanel`,
12+
using a new `MacrostratInteractionProvider` from
13+
`@macrostrat/data-components`.
14+
715
## [3.0.3] - 2026-01-29
816

917
- Change layout of `package.json`

packages/column-views/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@macrostrat/column-views",
3-
"version": "3.0.3",
3+
"version": "3.1.0",
44
"description": "Data views for Macrostrat stratigraphic columns",
55
"repository": {
66
"type": "git",

packages/column-views/src/data-provider/unit-selection.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,7 @@ const selectedUnitAtom = atom(
6969
target: HTMLElement | null = null,
7070
): BaseUnit | null => {
7171
if (!get(allowUnitSelectionAtom)) {
72-
throw new Error("Unit selection is disabled.");
72+
console.error("Unit selection is disabled.");
7373
}
7474

7575
let unitID: number | null;

packages/data-components/CHANGELOG.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,11 @@
11
# Changelog
22

3+
## [1.1.0] - 2026-01-31
4+
5+
- Create a `MacrostratInteractionProvider` to standardize handling of navigation
6+
for clickable/linkable data items.
7+
- Moved scoped data store utilities (based on `jotai-scope`) to this library.
8+
39
## [1.0.1] - 2026-01-29
410

511
- Change layout of `package.json`

packages/data-components/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@macrostrat/data-components",
3-
"version": "1.0.1",
3+
"version": "1.1.0",
44
"description": "A library of React components tailored for Macrostrat data and endpoints",
55
"repository": {
66
"type": "git",
Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
# Changelog
22

3-
## [0.1.0] - 2026-01-31
3+
## [1.0.0] - 2026-01-31
44

5-
Moved data provider functionality to a separate package for better modularity.
5+
Moved `MacrostratDataProvider` and data fetchers from `@macrostrat/column-views`
6+
for better modularity.

packages/data-provider/package.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@macrostrat/data-provider",
3-
"version": "0.1.0",
3+
"version": "1.0.0",
44
"description": "Data views for Macrostrat stratigraphic columns",
55
"repository": {
66
"type": "git",
@@ -44,6 +44,7 @@
4444
"@macrostrat/ui-components": "workspace:^",
4545
"@types/topojson-client": "^3.1.5",
4646
"cross-fetch": "^4.1.0",
47+
"d3-geo": "^3.1.1",
4748
"topojson-client": "^3.1.0",
4849
"zustand": "^5.0.3"
4950
},

packages/data-provider/src/fetch.ts

Lines changed: 21 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -5,11 +5,7 @@ import {
55
StratName,
66
UnitLong,
77
} from "@macrostrat/api-types";
8-
import {
9-
addQueryString,
10-
joinURL,
11-
useAPIResult,
12-
} from "@macrostrat/ui-components";
8+
import { addQueryString, joinURL } from "@macrostrat/ui-components";
139
import crossFetch from "cross-fetch";
1410
import { feature } from "topojson-client";
1511
import { geoArea } from "d3-geo";
@@ -24,12 +20,16 @@ const defaultFetch = createScopedFetch("https://macrostrat.org/api/v2");
2420

2521
export type ColumnStatusCode = "in process" | "active" | "obsolete";
2622

27-
export interface ColumnFetchOptions {
23+
interface FetchBaseOptions {
24+
// The fetch implementation to use
25+
fetch?: (url: string, options?: RequestInit) => Promise<Response>;
26+
}
27+
28+
export interface ColumnFetchOptions extends FetchBaseOptions {
2829
apiBaseURL?: string;
2930
projectID?: number;
3031
statusCode?: ColumnStatusCode | ColumnStatusCode[];
3132
format?: "geojson" | "topojson" | "geojson_bare";
32-
fetch?: any;
3333
}
3434

3535
export async function fetchAllColumns(
@@ -153,15 +153,17 @@ async function unwrapResponse(res) {
153153
return resData["success"]["data"];
154154
}
155155

156-
export async function fetchLithologies(fetch = defaultFetch) {
156+
export async function fetchLithologies(opts: FetchBaseOptions = {}) {
157+
const { fetch = defaultFetch } = opts;
157158
const res = await fetch("/defs/lithologies?all");
158159
return await unwrapResponse(res);
159160
}
160161

161162
export async function fetchIntervals(
162163
timescaleID: number | null,
163-
fetch = defaultFetch,
164+
opts: FetchBaseOptions = {},
164165
) {
166+
const { fetch = defaultFetch } = opts;
165167
let url = `/defs/intervals`;
166168
if (timescaleID != null) {
167169
url += `?timescale_id=${timescaleID}`;
@@ -172,15 +174,17 @@ export async function fetchIntervals(
172174
return await unwrapResponse(res);
173175
}
174176

175-
export async function fetchEnvironments(fetch = defaultFetch) {
177+
export async function fetchEnvironments(opts: FetchBaseOptions = {}) {
178+
const { fetch = defaultFetch } = opts;
176179
const res = await fetch("/defs/environments?all");
177180
return await unwrapResponse(res);
178181
}
179182

180183
export async function fetchRefs(
181184
refs: number[],
182-
fetch = defaultFetch,
185+
opts: FetchBaseOptions = {},
183186
): Promise<MacrostratRef[]> {
187+
const { fetch = defaultFetch } = opts;
184188
let url = `/defs/refs`;
185189
if (refs.length == 0) {
186190
return [];
@@ -192,8 +196,9 @@ export async function fetchRefs(
192196

193197
export async function fetchStratNames(
194198
names: number[],
195-
fetch = defaultFetch,
199+
opts: FetchBaseOptions = {},
196200
): Promise<StratName[]> {
201+
const { fetch = defaultFetch } = opts;
197202
let url = `/defs/strat_names`;
198203
if (names.length == 0) {
199204
return [];
@@ -210,8 +215,9 @@ export type ColumnData = {
210215

211216
export async function fetchUnits(
212217
columns: number[],
213-
fetch = defaultFetch,
218+
opts: FetchBaseOptions = {},
214219
): Promise<ColumnData[]> {
220+
const { fetch = defaultFetch } = opts;
215221
const params = new URLSearchParams();
216222
params.append("response", "long");
217223

@@ -245,8 +251,9 @@ export async function fetchUnits(
245251

246252
export async function fetchColumnUnits(
247253
col_id: number,
248-
fetch = defaultFetch,
254+
opts: FetchBaseOptions = {},
249255
): Promise<ColumnData> {
256+
const { fetch = defaultFetch } = opts;
250257
const params = new URLSearchParams();
251258
params.append("response", "long");
252259
params.append("col_id", col_id.toString());

packages/data-provider/src/provider.ts

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -105,7 +105,7 @@ function createRefsSlice(set, get) {
105105
if (missing.length == 0) {
106106
return ids.map((id) => refs.get(id));
107107
}
108-
const data = await fetchRefs(missing, fetch);
108+
const data = await fetchRefs(missing, { fetch });
109109
if (data == null) return [];
110110
for (const d of data) {
111111
refs.set(d.ref_id, d);
@@ -163,7 +163,7 @@ function createLithologiesSlice(set, get) {
163163
const { lithologies, fetch } = get();
164164
let lithMap = lithologies;
165165
if (lithMap == null) {
166-
const data = await fetchLithologies(fetch);
166+
const data = await fetchLithologies({ fetch });
167167
if (data == null) return;
168168
lithMap = new Map(data.map((d) => [d.lith_id, d]));
169169
set({ lithologies: lithMap });
@@ -182,7 +182,7 @@ function createEnvironmentsSlice(set, get) {
182182
const { environments, fetch } = get();
183183
let envMap = environments;
184184
if (envMap == null) {
185-
const data = await fetchEnvironments(fetch);
185+
const data = await fetchEnvironments({ fetch });
186186
if (data == null) return [];
187187
envMap = new Map(data.map((d) => [d.environ_id, d]));
188188
set({ environments: envMap });
@@ -202,7 +202,7 @@ function createIntervalsSlice(set, get) {
202202
let _intervals = intervals;
203203
if (intervals == null || !includesTimescale(intervals, timescaleID)) {
204204
// Fetch the intervals
205-
const data = await fetchIntervals(timescaleID, fetch);
205+
const data = await fetchIntervals(timescaleID, { fetch });
206206
if (data == null) {
207207
return [];
208208
}
@@ -241,7 +241,7 @@ function createStratNamesSlice(set, get) {
241241
}
242242
}
243243
if (stratNamesToLoad.length > 0) {
244-
const data = await fetchStratNames(stratNamesToLoad, fetch);
244+
const data = await fetchStratNames(stratNamesToLoad, { fetch });
245245
if (data == null) return stratNamesAlreadyLoaded;
246246
for (const d of data) {
247247
nameMap.set(d.strat_name_id, d);

scripts/publish-helpers/status.ts

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -179,8 +179,10 @@ async function packageVersionExistsInRegistry(pkg): Promise<PackageStatus> {
179179

180180
let msg = chalk.bold(moduleString(pkg));
181181
// Show last version
182-
const lastVersion: string | null =
183-
info.versions[info.versions.length - 1] ?? null;
182+
let lastVersion: string | null = null;
183+
if (info != null && info.versions != null && info.versions.length > 0) {
184+
lastVersion = info.versions[info.versions.length - 1];
185+
}
184186

185187
let hasChanges: boolean | null = null;
186188
if (lastVersion != null) {

0 commit comments

Comments
 (0)