From a96732eef0a84861529a617880c5f892da685a88 Mon Sep 17 00:00:00 2001 From: Seyed Yahya Shirazi Date: Fri, 26 Jun 2026 15:59:41 -0700 Subject: [PATCH 1/2] doi: canonical /dataset landing target Replace legacy nemar.org/dataexplorer/detail?dataset_id= DOI _target and enrichment links with the canonical https://nemar.org/dataset/ (version DOIs: ?v=v), via two shared helpers in shared/datacite-constants.ts. Part of epic #837 (Phase 1, #838). --- backend/src/routes/admin.ts | 11 ++++++----- backend/src/services/doi.ts | 5 +++-- backend/src/services/enrich-dataset.ts | 3 ++- backend/src/services/llm-enrich.ts | 3 ++- shared/datacite-constants.ts | 22 ++++++++++++++++++++++ test/datacite.test.ts | 2 +- test/dataset-landing-url.test.ts | 26 ++++++++++++++++++++++++++ test/ezid-sandbox.test.ts | 12 ++++++------ 8 files changed, 68 insertions(+), 16 deletions(-) create mode 100644 test/dataset-landing-url.test.ts diff --git a/backend/src/routes/admin.ts b/backend/src/routes/admin.ts index 566c60c4b..3131aaeca 100644 --- a/backend/src/routes/admin.ts +++ b/backend/src/routes/admin.ts @@ -9,6 +9,7 @@ import { Hono } from "hono"; import { z } from "zod"; import { adminMiddleware, authMiddleware, ownerMiddleware } from "../middleware/auth"; +import { datasetLandingUrl, datasetVersionLandingUrl } from "../../../shared/datacite-constants.js"; import { LIVE_DATASETS, isLiveDataset } from "../constants"; import { tombstoneUserStatement } from "../db/user-tombstone"; import { SYSTEM_USER_ID } from "../lib/constants"; @@ -2124,7 +2125,7 @@ adminRoutes.post("/datasets/:id/doi/update", zValidator("json", updateDoiSchema) const metadata = bidsToDataCite(datasetId, doi, bidsDesc, enrichment); updateOptions.dataciteXml = buildDataCiteXml(metadata); - updateOptions.target = `https://nemar.org/dataexplorer/detail?dataset_id=${datasetId}`; + updateOptions.target = datasetLandingUrl(datasetId); metadataRefreshed = true; } @@ -2132,7 +2133,7 @@ adminRoutes.post("/datasets/:id/doi/update", zValidator("json", updateDoiSchema) if (body.status) { if (body.status === "public" && dataset.ezid_status === "reserved") { updateOptions.status = "public"; - updateOptions.target = `https://nemar.org/dataexplorer/detail?dataset_id=${datasetId}`; + updateOptions.target = datasetLandingUrl(datasetId); } else if (body.status === "unavailable") { updateOptions.status = "unavailable"; } @@ -2197,7 +2198,7 @@ adminRoutes.post("/datasets/:id/doi/update", zValidator("json", updateDoiSchema) const vMetadata = bidsToDataCite(datasetId, vDoi, bidsDesc, vEnrichment); vMetadata.version = ver.version; const vXml = buildDataCiteXml(vMetadata); - const vTarget = `https://nemar.org/dataexplorer/detail?dataset_id=${datasetId}&version=${ver.version}`; + const vTarget = datasetVersionLandingUrl(datasetId, ver.version); await ezidUpdateIdentifier(auth, versionIdentifier, { dataciteXml: vXml, target: vTarget, @@ -4507,7 +4508,7 @@ adminRoutes.post("/publish/:id/approve", zValidator("json", approveSchema), asyn if (vtResult instanceof Response) return vtResult; const { version, tag, datasetDesc } = vtResult; - const nemarUrl = `https://nemar.org/dataexplorer/detail?dataset_id=${datasetId}`; + const nemarUrl = datasetLandingUrl(datasetId); const archiveLine = `**Download:** [${tag}.zip](https://github.com/nemarDatasets/${repoName}/archive/refs/tags/${tag}.zip)`; const sections = [ `# ${dataset.name} - Version ${version}`, @@ -4572,7 +4573,7 @@ adminRoutes.post("/publish/:id/approve", zValidator("json", approveSchema), asyn } const auth = resolveEzidAuth(c.env, sandbox || !!dataset.is_sandbox); - const target = `https://nemar.org/dataexplorer/detail?dataset_id=${datasetId}`; + const target = datasetLandingUrl(datasetId); await ezidMakePublic(auth, dataset.ezid_identifier, target); // Update EZID status in D1 diff --git a/backend/src/services/doi.ts b/backend/src/services/doi.ts index 89b21c0ef..c51016522 100644 --- a/backend/src/services/doi.ts +++ b/backend/src/services/doi.ts @@ -5,6 +5,7 @@ * Each dataset has its own doi_provider; existing Zenodo datasets keep working. */ +import { datasetLandingUrl, datasetVersionLandingUrl } from "../../../shared/datacite-constants.js"; import type { BidsDatasetDescription, DataCiteEnrichment } from "./datacite"; import { bidsToDataCite, buildDataCiteXml } from "./datacite"; import { @@ -189,7 +190,7 @@ async function createEzidConceptDoi( const dataciteXml = buildDataCiteXml(metadata); // DOI landing page: always the NEMAR website (not GitHub) - const target = `https://nemar.org/dataexplorer/detail?dataset_id=${options.datasetId}`; + const target = datasetLandingUrl(options.datasetId); let identifier: EzidIdentifier; try { @@ -298,7 +299,7 @@ export async function createEzidVersionDoi( const dataciteXml = buildDataCiteXml(metadata); // Version DOI landing page: NEMAR website with version param (not GitHub release) - const target = `https://nemar.org/dataexplorer/detail?dataset_id=${opts.datasetId}&version=${opts.version}`; + const target = datasetVersionLandingUrl(opts.datasetId, opts.version); let identifier: EzidIdentifier; try { diff --git a/backend/src/services/enrich-dataset.ts b/backend/src/services/enrich-dataset.ts index 283b31ecc..60b77837a 100644 --- a/backend/src/services/enrich-dataset.ts +++ b/backend/src/services/enrich-dataset.ts @@ -16,6 +16,7 @@ */ import type { NemarMetadataV2 } from "../../../shared/datacite-constants.js"; +import { datasetLandingUrl } from "../../../shared/datacite-constants.js"; import type { Bindings } from "../types/bindings.js"; import { bidsToDataCite, @@ -398,7 +399,7 @@ export async function enrichDataset( `[llm-enrich] Failed to update BIDS Name in D1 for ${datasetId}: ${errorMessage(dbErr)}`, ); } - const nemarUrl = `https://nemar.org/dataexplorer/detail?dataset_id=${datasetId}`; + const nemarUrl = datasetLandingUrl(datasetId); const repoResult = await setRepoDescription(repoName, bidsName, pat, nemarUrl); if (!repoResult.ok) { console.error( diff --git a/backend/src/services/llm-enrich.ts b/backend/src/services/llm-enrich.ts index 6b1b379e8..ad1b8a75e 100644 --- a/backend/src/services/llm-enrich.ts +++ b/backend/src/services/llm-enrich.ts @@ -11,6 +11,7 @@ import { type NemarMetadataV2, type RelatedIdentifierEntry, type StructuredKeyword, + datasetLandingUrl, isValidRelationType, } from "../../../shared/datacite-constants.js"; @@ -369,7 +370,7 @@ export function seedFromBids( relation_type: "IsDescribedBy", }); } - const nemarUrl = `https://nemar.org/dataexplorer/detail?dataset_id=${datasetId}`; + const nemarUrl = datasetLandingUrl(datasetId); if (!relatedIds.some((r) => r.identifier === nemarUrl)) { relatedIds.push({ identifier: nemarUrl, diff --git a/shared/datacite-constants.ts b/shared/datacite-constants.ts index 1da01db4e..6258beda1 100644 --- a/shared/datacite-constants.ts +++ b/shared/datacite-constants.ts @@ -186,3 +186,25 @@ export interface NemarMetadataV2 { /** Union of both versions. */ export type NemarMetadata = NemarMetadataV1 | NemarMetadataV2; + +// --------------------------------------------------------------------------- +// Dataset landing URLs (DOI _target + enrichment links) +// --------------------------------------------------------------------------- + +/** + * Canonical NEMAR dataset landing URL used as the DOI `_target` and in + * enrichment/README links. Permanent and provider-agnostic; today + * `nemar.org/dataset/` forwards to `ww2.nemar.org/dataset/`. + * Replaces the retired legacy `nemar.org/dataexplorer/detail?dataset_id=`. + */ +export function datasetLandingUrl(datasetId: string): string { + return `https://nemar.org/dataset/${datasetId}`; +} + +/** + * Version-specific landing URL. `version` is the plain semver string (e.g. + * `1.1.0`); the `?v=v` form is what the ww2 dataset page honors. + */ +export function datasetVersionLandingUrl(datasetId: string, version: string): string { + return `https://nemar.org/dataset/${datasetId}?v=v${version}`; +} diff --git a/test/datacite.test.ts b/test/datacite.test.ts index dc5f4194c..74d36255e 100644 --- a/test/datacite.test.ts +++ b/test/datacite.test.ts @@ -1468,7 +1468,7 @@ describe("seedFromBids", () => { expect(githubEntry?.relation_type).toBe("IsDescribedBy"); const nemarEntry = seeded.related_identifiers?.find( - (r) => r.identifier === "https://nemar.org/dataexplorer/detail?dataset_id=nm000108", + (r) => r.identifier === "https://nemar.org/dataset/nm000108", ); expect(nemarEntry).toBeDefined(); expect(nemarEntry?.identifier_type).toBe("URL"); diff --git a/test/dataset-landing-url.test.ts b/test/dataset-landing-url.test.ts new file mode 100644 index 000000000..6f22429f4 --- /dev/null +++ b/test/dataset-landing-url.test.ts @@ -0,0 +1,26 @@ +import { describe, expect, test } from "bun:test"; +import { datasetLandingUrl, datasetVersionLandingUrl } from "../shared/datacite-constants"; + +describe("dataset landing URLs (DOI _target)", () => { + test("datasetLandingUrl returns the canonical /dataset/ URL", () => { + expect(datasetLandingUrl("nm000132")).toBe("https://nemar.org/dataset/nm000132"); + expect(datasetLandingUrl("on004350")).toBe("https://nemar.org/dataset/on004350"); + }); + + test("datasetVersionLandingUrl appends ?v=v (ww2-honored form)", () => { + expect(datasetVersionLandingUrl("nm000132", "1.1.0")).toBe( + "https://nemar.org/dataset/nm000132?v=v1.1.0", + ); + expect(datasetVersionLandingUrl("on004350", "2.0.0")).toBe( + "https://nemar.org/dataset/on004350?v=v2.0.0", + ); + }); + + test("targets are on the canonical nemar.org domain, not the legacy dataexplorer path", () => { + const concept = datasetLandingUrl("nm000132"); + const version = datasetVersionLandingUrl("nm000132", "1.0.0"); + expect(concept).not.toContain("dataexplorer"); + expect(version).not.toContain("dataexplorer"); + expect(concept.startsWith("https://nemar.org/dataset/")).toBe(true); + }); +}); diff --git a/test/ezid-sandbox.test.ts b/test/ezid-sandbox.test.ts index c84d99832..72dc5ef20 100644 --- a/test/ezid-sandbox.test.ts +++ b/test/ezid-sandbox.test.ts @@ -140,7 +140,7 @@ describe.skipIf(!SHOULD_RUN)("EZID Sandbox Integration", { timeout: 30000 }, () const minted = await mintIdentifier(EZID_TEST_AUTH, { shoulder: TEST_SHOULDER, status: "reserved", - target: `https://nemar.org/dataexplorer/detail?dataset_id=${TEST_DATASET_ID}`, + target: `https://nemar.org/dataset/${TEST_DATASET_ID}`, dataciteFields: { creator: "Test, User", title: `Test Dataset - ${new Date().toISOString()}`, @@ -238,7 +238,7 @@ describe.skipIf(!SHOULD_RUN)("EZID Sandbox Integration", { timeout: 30000 }, () const minted = await mintIdentifier(EZID_TEST_AUTH, { shoulder: TEST_SHOULDER, status: "reserved", - target: `https://nemar.org/dataexplorer/detail?dataset_id=${TEST_DATASET_ID}`, + target: `https://nemar.org/dataset/${TEST_DATASET_ID}`, dataciteXml: xml, }); @@ -604,7 +604,7 @@ describe.skipIf(!SHOULD_RUN)("EZID Sandbox Integration", { timeout: 30000 }, () const minted = await mintIdentifier(EZID_TEST_AUTH, { shoulder: TEST_SHOULDER, status: "reserved", - target: `https://nemar.org/dataexplorer/detail?dataset_id=${TEST_DATASET_ID}`, + target: `https://nemar.org/dataset/${TEST_DATASET_ID}`, dataciteXml: xml, }); createdIdentifiers.push(minted.identifier); @@ -628,7 +628,7 @@ describe.skipIf(!SHOULD_RUN)("EZID Sandbox Integration", { timeout: 30000 }, () const created = await createIdentifier(EZID_TEST_AUTH, deterministicId, { status: "reserved", - target: `https://nemar.org/dataexplorer/detail?dataset_id=${TEST_DATASET_ID}`, + target: `https://nemar.org/dataset/${TEST_DATASET_ID}`, dataciteXml: xml, }); @@ -740,7 +740,7 @@ describe.skipIf(!SHOULD_RUN)("EZID Sandbox Integration", { timeout: 30000 }, () const minted = await mintIdentifier(EZID_TEST_AUTH, { shoulder: TEST_SHOULDER, status: "reserved", - target: `https://nemar.org/dataexplorer/detail?dataset_id=${TEST_DATASET_ID}`, + target: `https://nemar.org/dataset/${TEST_DATASET_ID}`, dataciteFields: { creator: "Test, User", title: "Lifecycle Test v1.0.0", @@ -780,7 +780,7 @@ describe.skipIf(!SHOULD_RUN)("EZID Sandbox Integration", { timeout: 30000 }, () const published = await makePublic( EZID_TEST_AUTH, minted.identifier, - `https://nemar.org/dataexplorer/detail?dataset_id=${TEST_DATASET_ID}`, + `https://nemar.org/dataset/${TEST_DATASET_ID}`, ); expect(published.status).toBe("public"); console.log(" [x] Step 3: Made public"); From ce4171daba1a3aa3b459c791f81515ecb6bfb552 Mon Sep 17 00:00:00 2001 From: Seyed Yahya Shirazi Date: Fri, 26 Jun 2026 16:04:31 -0700 Subject: [PATCH 2/2] doi: merge enrich-dataset shared import --- backend/src/services/enrich-dataset.ts | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/backend/src/services/enrich-dataset.ts b/backend/src/services/enrich-dataset.ts index 60b77837a..e761b16c1 100644 --- a/backend/src/services/enrich-dataset.ts +++ b/backend/src/services/enrich-dataset.ts @@ -15,8 +15,7 @@ * structured EnrichmentRunResult without re-implementing the matrix. */ -import type { NemarMetadataV2 } from "../../../shared/datacite-constants.js"; -import { datasetLandingUrl } from "../../../shared/datacite-constants.js"; +import { type NemarMetadataV2, datasetLandingUrl } from "../../../shared/datacite-constants.js"; import type { Bindings } from "../types/bindings.js"; import { bidsToDataCite,