Skip to content

Conversation

@7emansell
Copy link
Contributor

@7emansell 7emansell commented Dec 30, 2025

Adds MARC endpoint which should:

  • Suppress fields and redact subfields using annotated MARC rules
  • Handle parallel suppression/redaction
  • Override rules that are dropping control fields so that leader/controls go through

and return the serialized bib.

good test: b22144813

@7emansell 7emansell marked this pull request as ready for review January 5, 2026 17:05
@7emansell 7emansell assigned yossariano and unassigned yossariano Jan 5, 2026
@7emansell 7emansell requested a review from yossariano January 5, 2026 18:16
.filter(Boolean)

return {
unserialized: bib,
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

will remove but it's helpful for testing

Copy link
Contributor

@yossariano yossariano left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good to me!

@@ -0,0 +1,166 @@
/**
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You're putting the rest of the codebase to shame with all this detailed documentation! Nicely done though it definitely helps make it easy to understand what is going on.

const parallels = MarcSerializer.findParallelFields(bib, field)
parallels.forEach((p) => {
Object.assign(p, MarcSerializer.buildSourceWithMasking(p, matchingRule))
})
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is this an effort to link parallel fields to primary fields so that they can be visually linked on the front-end? Aren't we just rendering 880s as is?

Incidentally I'm not seeing known 880 values come through when viewing/api/v0.1/discovery/resources/b22144813.marclocally

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ah this may be wrong then– I'm trying to find the parallels of suppressed fields and suppress them, but otherwise pass parallels through

bib: {
id: bib.id,
nyplSource: bib.nyplSource,
fields: suppressedVarFields
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm not sure if this variable is misnamed, but something here does not seem right. Why are you returning something called suppressed?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good point, renamed to serialized to mean all the processed varfields


if (!linkNumbers.length) return []

return bib.varFields.filter((f) => {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm finding this chunk hard to grok. Can you use some more descriptive variable names and/or pull some of these array method callbacks into named functions?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Broken down into some more chunks

subfields: (field.subfields || []).map((subfield) => {
let content = subfield.content
if (
(rule.subfieldSpec.directive === 'include' &&
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I know this is in the original code, but do we know why this is logically here? If the directive says include but it is not present in the subfield spec, wouldn't we just skip it? Wouldn't this add [redacted] for fields that don't have content? @nonword maybe you have some insight?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants