@museumwnf/viewer-core 2.28.0 → 2.29.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.
package/README.md CHANGED
@@ -524,6 +524,8 @@ needs it; the standalone sites never import it.
524
524
  | `partnerKey(partner, countries = [])` | `{ legacyId, countryCode }` from a partner's `backward_compatibility` — `mwnf3:museums:Mus21:ua` on the DXA sites, `mwnf3_sharing_history:sh_partners:at_01_d` on Sharing History, whose key carries the country as its own prefix rather than a fourth segment. `countries` is the fallback for a partner with no `backward_compatibility` at all: its `country_id` resolved to the country's own `code`. |
525
525
  | `partnerFromKey(partners, countries, countryCode, legacyId)` | the partner a legacy `/partner/:country/:id` route names, or null — `partnerKey` in reverse |
526
526
  | `itemFromUidPath(items, path)` | the item a legacy dbUid *path* names, or null — `backward_compatibility` with `:` swapped for `/`, matched case-insensitively (Sharing History stores its keys lowercase) |
527
+ | `itemIdFromLegacyPaths(legacyPaths, path)` | the item id a dbUid path names in a package's `legacy_paths.json` (`items`, keyed by the path lower case); null for none, `undefined` when the package has no map |
528
+ | `partnerIdFromLegacyPaths(legacyPaths, countryCode, legacyId)` | the partner id `legacy_paths.json`'s `partners` map gives `<country>/<legacy id>`; null for none, `undefined` without a map |
527
529
 
528
530
  ### `@museumwnf/viewer-core/dxa`
529
531
 
@@ -569,7 +571,7 @@ below for whichever future site needs its own).
569
571
 
570
572
  | Export (gallery / exhibition) | Reads | Returns |
571
573
  | --- | --- | --- |
572
- | `useGalleryData(config)` / `useExhibitionData(config)` | `config.eager` (entity names `loadEnglish` loads eagerly; default the family's own list, the exhibition's also carrying `themes`) | the family's whole data layer: `tr`/`md`/`mdInline`/`mdStrip`/`labelOf`/`loadEnglish`/`translations`, every entity and lookup map (`items`, `partners`, `countries`, `tags`, `dynasties`, `timelines`, `timelineEvents`, …), the routes (`itemRoute`, `partnerRoute`, `partnerObjectsRoute`), the legacy URL wrappers (`itemFromUidPath`, `partnerFromKey` — gallery only), the DXA legacy country code both ways (`countryIdForCode(code)`, idempotent on an id, and `countryLabel(countryId)`, one table the collection and the timeline both read), `chromeImage`, `manifest`, `defaultLang`, plus family-specific fields (gallery: `siblingGalleries`/`pickSiblings`; exhibition: `isHiddenPartner` (the site's `exhibition.hiddenPartners` when its config sets them, else the package's `hidden_partner_ids`), `isInstitution`, `projectName`, `exhibitionTitle`/`exhibitionSubtitle`/`exhibitionHeadline`/`bannerCaption`, `siblingSites`) |
574
+ | `useGalleryData(config)` / `useExhibitionData(config)` | `config.eager` (entity names `loadEnglish` loads eagerly; default the family's own list, the exhibition's also carrying `themes`) | the family's whole data layer: `tr`/`md`/`mdInline`/`mdStrip`/`labelOf`/`loadEnglish`/`translations`, every entity and lookup map (`items`, `partners`, `countries`, `tags`, `dynasties`, `timelines`, `timelineEvents`, …), the routes (`itemRoute`, `partnerRoute`, `partnerObjectsRoute`), the legacy URL wrappers (`itemFromUidPath`, `partnerFromKey` — gallery only; they look the address up in `legacy_paths.json` once `loadLegacyPaths()` has loaded it, else decode the legacy keys), the DXA legacy country code both ways (`countryIdForCode(code)`, idempotent on an id, and `countryLabel(countryId)`, one table the collection and the timeline both read), `chromeImage`, `manifest`, `defaultLang`, plus family-specific fields (gallery: `siblingGalleries`/`pickSiblings`; exhibition: `isHiddenPartner` (the site's `exhibition.hiddenPartners` when its config sets them, else the package's `hidden_partner_ids`), `isInstitution`, `projectName`, `exhibitionTitle`/`exhibitionSubtitle`/`exhibitionHeadline`/`bannerCaption`, `siblingSites`) |
573
575
  | `useGalleryCollection(data, config)` / `useExhibitionCollection(data, config)` | the `data` object above; `config` unused today | `FACETS`, `tile(item, t)`, `collectionResults` (the `CatalogueResultsView` spec), plus the facet-value helpers (`countryIdForCode` — the data layer's —, `tagLabelForLegacy`, a tag facet keyed on the tag's `legacy_tag_id`, or on its own `id` when it has none, gallery's own `tagIdForLegacy`, `hasEveryTag`) |
574
576
  | `useGalleryTimeline(data, collection, config)` / `useExhibitionTimeline(data, collection, config)` | `data`, the `collection` object above (for its `tile`); `config` unused today | the timeline specs (`timelineResults`/`timelineSpec`, `timelineGallery`/`timelineGallerySpec`), `timelineEvents` (viewer-core's `useTimelineEvents` engine — for an exhibition, the one its flags put in force, country or local), and the data layer's `countryLabel`/`countryIdForCode`; the gallery adds `timelineGalleryItems`, the exhibition `usesLocalTimeline` and `hasTimeline` for its local-vs-country chronology switch, decided by the site's `exhibition.timeline` (`'site'`, `'country'` or `false`) when its config sets one, else by the package's `has_timeline`/`has_country_timeline` |
575
577
  | `useGalleryPartner(data, collection, config)` / `useExhibitionPartner(data, config)` | `data`, and (gallery only) `collection` for its `tile` | `partnerList`/`partnerListSpec`, `partnerSheet`/`partnerSheetSpec`, and (gallery only) `partnerObjects` — the exhibition shape's `partnerSpecs.js` never carried an objects-page spec |
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@museumwnf/viewer-core",
3
- "version": "2.28.0",
3
+ "version": "2.29.0",
4
4
  "description": "Application engine for MWNF websites: turns a dataset.config.js into a mounted Vue application.",
5
5
  "type": "module",
6
6
  "license": "SEE LICENSE IN LICENSE.md",
@@ -130,11 +130,15 @@ export function useGalleryCollection(data, config = {}) {
130
130
  // `sort.tiebreak`, viewer-layout's dxa/gallery pages):
131
131
  // dxa-api's `ORDER BY startDate, countryName, partnerName`, then MySQL's
132
132
  // own order, which is the table's key: the record's legacy key, its
133
- // numbers compared as numbers (inventory-app#2423).
133
+ // numbers compared as numbers (inventory-app#2423). A package from
134
+ // inventory-app's pass 3 ships that order as each record's `sort_key`
135
+ // (a rank), which then breaks the tie in place of the legacy key.
134
136
  function legacyOrder(a, b) {
135
137
  return compareText(labelOf('countries', a.country_id), labelOf('countries', b.country_id))
136
138
  || compareText(labelOf('partners', a.partner_id), labelOf('partners', b.partner_id))
137
- || compareKeys(a.backward_compatibility, b.backward_compatibility)
139
+ || (Number.isInteger(a.sort_key) && Number.isInteger(b.sort_key)
140
+ ? a.sort_key - b.sort_key
141
+ : compareKeys(a.backward_compatibility, b.backward_compatibility))
138
142
  }
139
143
 
140
144
  // ── The results page, as a spec ──────────────────────────────────────
@@ -2,7 +2,10 @@ import { computed } from 'vue'
2
2
  import { mediaUrl } from '../../siteConfig.js'
3
3
  import { useCatalogueData } from '../../composables/useCatalogueData.js'
4
4
  import { useDataPackage } from '../../composables/useDataPackage.js'
5
- import { itemFromUidPath as legacyItemFromUidPath, partnerFromKey as legacyPartnerFromKey } from '../../legacy/index.js'
5
+ import { entityRef, loadEntities } from '../../composables/useEntities.js'
6
+ import {
7
+ itemFromUidPath as legacyItemFromUidPath, itemIdFromLegacyPaths, partnerFromKey as legacyPartnerFromKey, partnerIdFromLegacyPaths,
8
+ } from '../../legacy/index.js'
6
9
  import { useLegacyCountryCodes } from '../countryCodes.js'
7
10
  import { toNewSite, withScheme } from '../../legacySites.js'
8
11
 
@@ -95,11 +98,27 @@ export function useGalleryData(config = {}) {
95
98
  // site does, pure, over plain lists; these two wrappers bind it to this
96
99
  // gallery's own `items`/`partners`/`countries` refs, so the site's legacy
97
100
  // routes keep calling them with the arguments they already carry.
101
+ //
102
+ // A package from inventory-app's pass 3 ships the addresses resolved, as
103
+ // `legacy_paths.json`: once it is loaded (`loadLegacyPaths()`), the two
104
+ // look the address up there and never read a record's legacy key. An older
105
+ // package has no such file, and they decode the keys as before.
106
+ const legacyPaths = entityRef('legacy_paths')
107
+
108
+ /** Loads `legacy_paths.json` when the package has it; resolves either way. */
109
+ function loadLegacyPaths() {
110
+ return loadEntities(['legacy_paths']).catch(() => null)
111
+ }
112
+
98
113
  function itemFromUidPath(path) {
114
+ const id = itemIdFromLegacyPaths(legacyPaths.value, path)
115
+ if (id !== undefined) return id === null ? null : itemById.value.get(id) ?? null
99
116
  return legacyItemFromUidPath(items.value ?? [], path)
100
117
  }
101
118
 
102
119
  function partnerFromKey(countryCode, legacyId) {
120
+ const id = partnerIdFromLegacyPaths(legacyPaths.value, countryCode, legacyId)
121
+ if (id !== undefined) return id === null ? null : partnerById.value.get(id) ?? null
103
122
  return legacyPartnerFromKey(partners.value ?? [], countries.value ?? [], countryCode, legacyId)
104
123
  }
105
124
 
@@ -151,7 +170,7 @@ export function useGalleryData(config = {}) {
151
170
  gallery, items, tags, partners, countries, languages, dynasties, glossary, timelines, timelineEvents,
152
171
  itemById, partnerById, countryById, tagById, dynastyById, timelineById, languageByCode,
153
172
  countryIdForCode, countryLabel,
154
- itemRoute, partnerRoute, partnerObjectsRoute, itemFromUidPath, partnerFromKey,
173
+ itemRoute, partnerRoute, partnerObjectsRoute, itemFromUidPath, partnerFromKey, loadLegacyPaths,
155
174
  chromeImage, siblingGalleries, siblingUrl, pickSiblings,
156
175
  }
157
176
  }
@@ -84,7 +84,11 @@ export function useGalleryItemDetail(data, timeline) {
84
84
  chipClass,
85
85
  },
86
86
  notice: {
87
- show: (record) => (useSiteConfig().noticeProjects ?? []).includes(record.project_id),
87
+ // A package from inventory-app's pass 3 says it on the record (`notice`);
88
+ // an older one is read through the site's `noticeProjects`.
89
+ show: (record) => (typeof record.notice === 'boolean'
90
+ ? record.notice
91
+ : (useSiteConfig().noticeProjects ?? []).includes(record.project_id)),
88
92
  label: 'partner.item.explorePartnerNote',
89
93
  },
90
94
  museum: {
@@ -56,3 +56,26 @@ export function itemFromUidPath(items, path) {
56
56
  const needle = String(path ?? '').split('/').join(':').toLowerCase()
57
57
  return (items ?? []).find((item) => item?.backward_compatibility?.toLowerCase() === needle) ?? null
58
58
  }
59
+
60
+ /**
61
+ * The item id a legacy dbUid *path* names, from the package's
62
+ * `legacy_paths.json` (inventory-app pass 3): its `items` map, keyed by the
63
+ * path lower case. `undefined` when the package has no such map (an older
64
+ * package: the caller decodes `backward_compatibility` as before), `null`
65
+ * when the map has no entry.
66
+ */
67
+ export function itemIdFromLegacyPaths(legacyPaths, path) {
68
+ if (!legacyPaths?.items) return undefined
69
+ return legacyPaths.items[String(path ?? '').split(/[/:]/).join('/').toLowerCase()] ?? null
70
+ }
71
+
72
+ /**
73
+ * The partner id a legacy `/partner/:country/:id` route names, from the
74
+ * package's `legacy_paths.json` `partners` map (`<country>/<legacy id>`).
75
+ * `undefined` when the package has no such map, `null` for no entry.
76
+ */
77
+ export function partnerIdFromLegacyPaths(legacyPaths, countryCode, legacyId) {
78
+ if (!legacyPaths?.partners) return undefined
79
+ return legacyPaths.partners[`${countryCode}/${legacyId}`] ?? null
80
+ }
81
+