@daihum/record-formats 0.1.0 → 0.1.1

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.
@@ -1,520 +1,5 @@
1
- import { i as hasFormatErrors, n as formatFail, r as formatOk, t as createFormatIssue } from "../result-YrPe5I9D.js";
2
- import { a as getXmlText, c as parseXml, n as buildXml, r as findXmlValue, s as normalizeXmlName, t as asXmlArray } from "../xml-6kdXnoBh.js";
1
+ import "../result-Cl7IY6PN.js";
2
+ import "../xml-DXtayJiw.js";
3
+ import { a as EAD3_OFFICIAL_SCHEMA_VALIDATION, c as EAD3_TAG_LIBRARY_VERSION, d as ead3FromXmlDocument, f as ead3ToXmlDocument, h as validateEad3, i as EAD3_NAMESPACE, l as EAD3_VALIDATION_LEVEL, m as serializeEad3Xml, n as EAD3_FORMAT_GENERATION, o as EAD3_SCHEMA_REVISION, p as parseEad3Xml, r as EAD3_FORMAT_ID, s as EAD3_SCHEMA_VERSION, t as EAD3_ADAPTER_PROFILE, u as ead3Adapter } from "../ead3-DM2in-ck.js";
3
4
 
4
- //#region src/ead3/ead3.ts
5
- const EAD3_FORMAT_ID = "ead3";
6
- const EAD3_NAMESPACE = "http://ead3.archivists.org/schema/";
7
- const EAD3_FORMAT_GENERATION = "EAD3";
8
- const EAD3_SCHEMA_VERSION = "1.1.1";
9
- const EAD3_SCHEMA_REVISION = "1.1.1";
10
- const EAD3_TAG_LIBRARY_VERSION = "1.1.2";
11
- const EAD3_VALIDATION_LEVEL = "projection";
12
- const EAD3_OFFICIAL_SCHEMA_VALIDATION = false;
13
- const EAD3_ADAPTER_PROFILE = {
14
- profileId: "daihum.record-formats.ead3.projection.v0",
15
- profileVersion: "0.1.0",
16
- formatId: EAD3_FORMAT_ID,
17
- formatGeneration: EAD3_FORMAT_GENERATION,
18
- namespace: EAD3_NAMESPACE,
19
- schemaVersion: EAD3_SCHEMA_VERSION,
20
- schemaRevision: EAD3_SCHEMA_REVISION,
21
- tagLibraryVersion: EAD3_TAG_LIBRARY_VERSION,
22
- validationLevel: EAD3_VALIDATION_LEVEL,
23
- officialSchemaValidation: EAD3_OFFICIAL_SCHEMA_VALIDATION,
24
- conformanceNotes: [
25
- "This adapter is a DAIHUM finding-aid projection for common EAD3 elements.",
26
- "Validation checks required projection fields and structured parser/serializer invariants.",
27
- "It does not run official EAD3 RNG, XSD, DTD, or Schematron schema validation.",
28
- "Unknown XML subtrees can be preserved through extension fields when preserveUnknown is enabled.",
29
- "DAIHUM href/source policy metadata is carried as projection attributes and is not official EAD3 schema validation."
30
- ],
31
- sourceReferences: [{
32
- label: "Library of Congress EAD3 schema page",
33
- url: "https://www.loc.gov/ead/ead3schema.html"
34
- }, {
35
- label: "Library of Congress EAD3 tag library",
36
- url: "https://www.loc.gov/ead/EAD3taglib/"
37
- }]
38
- };
39
- const EAD3_ARRAY_TAGS = [
40
- "unitdate",
41
- "dao",
42
- "c",
43
- "odd"
44
- ];
45
- function isRecord(value) {
46
- return Boolean(value) && typeof value === "object" && !Array.isArray(value);
47
- }
48
- function readString(value) {
49
- if (typeof value !== "string") return void 0;
50
- const trimmed = value.trim();
51
- return trimmed.length > 0 ? trimmed : void 0;
52
- }
53
- function readElementText(parent, localName) {
54
- return getXmlText(findXmlValue(parent, localName));
55
- }
56
- function readParagraphElementText(parent, localName) {
57
- return readElementText(readRecord(parent, localName), "p");
58
- }
59
- function readRecord(parent, localName) {
60
- const value = findXmlValue(parent, localName);
61
- return isRecord(value) ? value : {};
62
- }
63
- function createEad3Issue(params) {
64
- return createFormatIssue({
65
- severity: params.severity ?? "error",
66
- code: params.code,
67
- path: params.path,
68
- message: params.message,
69
- format: EAD3_FORMAT_ID
70
- });
71
- }
72
- function withEad3Profile(result) {
73
- return {
74
- ...result,
75
- adapterProfile: EAD3_ADAPTER_PROFILE
76
- };
77
- }
78
- function ead3Ok(value, issues = []) {
79
- return withEad3Profile(formatOk(value, issues));
80
- }
81
- function ead3Fail(issues, value) {
82
- return withEad3Profile(formatFail(issues, value));
83
- }
84
- function collectUnknownXml(record, knownLocalNames) {
85
- const known = new Set(knownLocalNames);
86
- const unknown = Object.fromEntries(Object.entries(record).filter(([key]) => !known.has(normalizeXmlName(key))));
87
- return Object.keys(unknown).length > 0 ? unknown : void 0;
88
- }
89
- function mergeKnown(extension, known) {
90
- return {
91
- ...extension ?? {},
92
- ...known
93
- };
94
- }
95
- function hasExtensionKeys(extension) {
96
- return extension !== void 0 && Object.keys(extension).length > 0;
97
- }
98
- function hasComponentExtensions(extensions) {
99
- return hasExtensionKeys(extensions.xml) || hasExtensionKeys(extensions.did);
100
- }
101
- function hasFindingAidExtensions(extensions) {
102
- return hasExtensionKeys(extensions.ead) || hasExtensionKeys(extensions.control);
103
- }
104
- function dateToXml(date) {
105
- return mergeKnown(date.extensions, {
106
- "#text": date.expression,
107
- ...date.normalized ? { "@_normal": date.normalized } : {},
108
- ...date.type ? { "@_type": date.type } : {}
109
- });
110
- }
111
- function textBlockToXml(value) {
112
- return { p: value };
113
- }
114
- function isHrefPolicyKind(value) {
115
- return value === "preserve" || value === "relative" || value === "redact" || value === "externalize";
116
- }
117
- function readJsonRecord(value) {
118
- const text = readString(value);
119
- if (!text) return void 0;
120
- try {
121
- const parsed = JSON.parse(text);
122
- return isRecord(parsed) ? parsed : void 0;
123
- } catch {
124
- return;
125
- }
126
- }
127
- function jsonRecordAttribute(value) {
128
- if (!value || Object.keys(value).length === 0) return void 0;
129
- try {
130
- return JSON.stringify(value);
131
- } catch {
132
- return;
133
- }
134
- }
135
- function digitalObjectToXml(ref) {
136
- const locatorJson = jsonRecordAttribute(ref.sourceRef?.locator);
137
- const metadataJson = jsonRecordAttribute(ref.sourceRef?.metadata);
138
- return mergeKnown(ref.extensions, {
139
- "@_href": ref.href,
140
- ...ref.label ? { "@_label": ref.label } : {},
141
- ...ref.role ? { "@_role": ref.role } : {},
142
- ...ref.targetKind ? { "@_targetkind": ref.targetKind } : {},
143
- ...ref.hrefPolicy?.kind ? { "@_data-daihum-href-policy": ref.hrefPolicy.kind } : {},
144
- ...ref.hrefPolicy?.publicHref ? { "@_data-daihum-public-href": ref.hrefPolicy.publicHref } : {},
145
- ...ref.hrefPolicy?.baseHref ? { "@_data-daihum-base-href": ref.hrefPolicy.baseHref } : {},
146
- ...ref.hrefPolicy?.redactedHref ? { "@_data-daihum-redacted-href": ref.hrefPolicy.redactedHref } : {},
147
- ...ref.hrefPolicy?.note ? { "@_data-daihum-policy-note": ref.hrefPolicy.note } : {},
148
- ...ref.sourceRef?.kind ? { "@_data-daihum-source-kind": ref.sourceRef.kind } : {},
149
- ...ref.sourceRef?.id ? { "@_data-daihum-source-id": ref.sourceRef.id } : {},
150
- ...ref.sourceRef?.label ? { "@_data-daihum-source-label": ref.sourceRef.label } : {},
151
- ...locatorJson ? { "@_data-daihum-source-locator": locatorJson } : {},
152
- ...metadataJson ? { "@_data-daihum-source-metadata": metadataJson } : {}
153
- });
154
- }
155
- function componentToXml(component) {
156
- const did = mergeKnown(component.extensions?.did, {
157
- ...component.referenceCode ? { unitid: component.referenceCode } : {},
158
- unittitle: component.title,
159
- ...component.dates?.length ? { unitdate: component.dates.map(dateToXml) } : {},
160
- ...component.extent ? { physdesc: { extent: component.extent } } : {},
161
- ...component.creator ? { origination: { name: component.creator } } : {},
162
- ...component.language ? { langmaterial: { language: component.language } } : {},
163
- ...component.digitalObjects?.length ? { dao: component.digitalObjects.map(digitalObjectToXml) } : {}
164
- });
165
- return mergeKnown(component.extensions?.xml, {
166
- ...component.id ? { "@_id": component.id } : {},
167
- "@_level": component.level,
168
- ...component.otherLevel ? { "@_otherlevel": component.otherLevel } : {},
169
- did,
170
- ...component.abstract ? { abstract: textBlockToXml(component.abstract) } : {},
171
- ...component.scopeContent ? { scopecontent: { p: component.scopeContent } } : {},
172
- ...component.arrangement ? { arrangement: { p: component.arrangement } } : {},
173
- ...component.accessRestriction ? { accessrestrict: { p: component.accessRestriction } } : {},
174
- ...component.useRestriction ? { userestrict: { p: component.useRestriction } } : {},
175
- ...component.biographicalHistory ? { bioghist: textBlockToXml(component.biographicalHistory) } : {},
176
- ...component.custodialHistory ? { custodhist: { p: component.custodialHistory } } : {},
177
- ...component.acquisitionInformation ? { acqinfo: textBlockToXml(component.acquisitionInformation) } : {},
178
- ...component.appraisal ? { appraisal: textBlockToXml(component.appraisal) } : {},
179
- ...component.processingInformation ? { processinfo: textBlockToXml(component.processingInformation) } : {},
180
- ...component.relatedMaterial ? { relatedmaterial: textBlockToXml(component.relatedMaterial) } : {},
181
- ...component.separatedMaterial ? { separatedmaterial: textBlockToXml(component.separatedMaterial) } : {},
182
- ...component.preferredCitation ? { prefercite: textBlockToXml(component.preferredCitation) } : {},
183
- ...component.notes?.length ? { odd: component.notes.map((note) => ({ p: note })) } : {},
184
- ...component.components?.length ? { dsc: { c: component.components.map(componentToXml) } } : {}
185
- });
186
- }
187
- function findingAidToXmlObject(findingAid) {
188
- const control = mergeKnown(findingAid.extensions?.control, {
189
- recordid: findingAid.recordId,
190
- maintenancestatus: findingAid.maintenanceStatus ?? "new",
191
- publicationstatus: "inprocess",
192
- ...findingAid.agencyName ? { maintenanceagency: { agencyname: findingAid.agencyName } } : {},
193
- filedesc: { titlestmt: { titleproper: findingAid.title } }
194
- });
195
- return { ead: mergeKnown(findingAid.extensions?.ead, {
196
- "@_xmlns": EAD3_NAMESPACE,
197
- control,
198
- archdesc: componentToXml(findingAid.description)
199
- }) };
200
- }
201
- function readDate(value) {
202
- const expression = getXmlText(value);
203
- if (!expression) return void 0;
204
- const record = isRecord(value) ? value : {};
205
- const normalized = readString(findXmlValue(record, "normal"));
206
- const type = readString(findXmlValue(record, "type"));
207
- const extensions = collectUnknownXml(record, [
208
- "#text",
209
- "normal",
210
- "type"
211
- ]);
212
- return {
213
- expression,
214
- ...normalized ? { normalized } : {},
215
- ...type ? { type } : {},
216
- ...extensions ? { extensions } : {}
217
- };
218
- }
219
- function readDigitalObject(value) {
220
- if (!isRecord(value)) return void 0;
221
- const href = readString(findXmlValue(value, "href"));
222
- if (!href) return void 0;
223
- const label = readString(findXmlValue(value, "label"));
224
- const role = readString(findXmlValue(value, "role"));
225
- const targetKind = readString(findXmlValue(value, "targetkind"));
226
- const hrefPolicyKind = readString(findXmlValue(value, "data-daihum-href-policy"));
227
- const publicHref = readString(findXmlValue(value, "data-daihum-public-href"));
228
- const baseHref = readString(findXmlValue(value, "data-daihum-base-href"));
229
- const redactedHref = readString(findXmlValue(value, "data-daihum-redacted-href"));
230
- const policyNote = readString(findXmlValue(value, "data-daihum-policy-note"));
231
- const sourceKind = readString(findXmlValue(value, "data-daihum-source-kind"));
232
- const sourceId = readString(findXmlValue(value, "data-daihum-source-id"));
233
- const sourceLabel = readString(findXmlValue(value, "data-daihum-source-label"));
234
- const sourceLocator = readJsonRecord(findXmlValue(value, "data-daihum-source-locator"));
235
- const sourceMetadata = readJsonRecord(findXmlValue(value, "data-daihum-source-metadata"));
236
- const extensions = collectUnknownXml(value, [
237
- "href",
238
- "label",
239
- "role",
240
- "targetkind",
241
- "data-daihum-href-policy",
242
- "data-daihum-public-href",
243
- "data-daihum-base-href",
244
- "data-daihum-redacted-href",
245
- "data-daihum-policy-note",
246
- "data-daihum-source-kind",
247
- "data-daihum-source-id",
248
- "data-daihum-source-label",
249
- "data-daihum-source-locator",
250
- "data-daihum-source-metadata"
251
- ]);
252
- return {
253
- href,
254
- ...label ? { label } : {},
255
- ...role ? { role } : {},
256
- ...targetKind ? { targetKind } : {},
257
- ...isHrefPolicyKind(hrefPolicyKind) ? { hrefPolicy: {
258
- kind: hrefPolicyKind,
259
- ...publicHref ? { publicHref } : {},
260
- ...baseHref ? { baseHref } : {},
261
- ...redactedHref ? { redactedHref } : {},
262
- ...policyNote ? { note: policyNote } : {}
263
- } } : {},
264
- ...sourceKind && sourceId ? { sourceRef: {
265
- kind: sourceKind,
266
- id: sourceId,
267
- ...sourceLabel ? { label: sourceLabel } : {},
268
- ...sourceLocator ? { locator: sourceLocator } : {},
269
- ...sourceMetadata ? { metadata: sourceMetadata } : {}
270
- } } : {},
271
- ...extensions ? { extensions } : {}
272
- };
273
- }
274
- function readMaintenanceStatus(value) {
275
- const status = getXmlText(value);
276
- if (status === "new" || status === "revised" || status === "deleted" || status === "derived" || status === "unknown") return status;
277
- }
278
- function readLevel(value) {
279
- const level = readString(value);
280
- if (level === "collection" || level === "series" || level === "subseries" || level === "file" || level === "item" || level === "otherlevel") return { level };
281
- return {
282
- level: "otherlevel",
283
- ...level ? { otherLevel: level } : {}
284
- };
285
- }
286
- function readComponent(value, path, issues, options) {
287
- if (!isRecord(value)) return void 0;
288
- const did = readRecord(value, "did");
289
- const title = readElementText(did, "unittitle") ?? "";
290
- if (!title) issues.push(createEad3Issue({
291
- code: "ead3.component.title.required",
292
- path: `${path}.title`,
293
- message: "EAD3 component title is required."
294
- }));
295
- const childrenContainer = readRecord(value, "dsc");
296
- const dates = asXmlArray(findXmlValue(did, "unitdate")).map(readDate).filter((date) => Boolean(date));
297
- const digitalObjects = asXmlArray(findXmlValue(did, "dao")).map(readDigitalObject).filter((ref) => Boolean(ref));
298
- const components = asXmlArray(findXmlValue(childrenContainer, "c")).map((child, index) => readComponent(child, `${path}.components.${index}`, issues, options)).filter((component) => Boolean(component));
299
- const level = readLevel(findXmlValue(value, "level"));
300
- const explicitOtherLevel = readString(findXmlValue(value, "otherlevel"));
301
- const id = readString(findXmlValue(value, "id"));
302
- const referenceCode = readElementText(did, "unitid");
303
- const extent = readElementText(readRecord(did, "physdesc"), "extent");
304
- const creator = readElementText(readRecord(did, "origination"), "name");
305
- const abstract = readParagraphElementText(value, "abstract");
306
- const scopeContent = readParagraphElementText(value, "scopecontent");
307
- const arrangement = readParagraphElementText(value, "arrangement");
308
- const accessRestriction = readParagraphElementText(value, "accessrestrict");
309
- const useRestriction = readParagraphElementText(value, "userestrict");
310
- const language = readElementText(readRecord(did, "langmaterial"), "language");
311
- const biographicalHistory = readParagraphElementText(value, "bioghist");
312
- const custodialHistory = readParagraphElementText(value, "custodhist");
313
- const acquisitionInformation = readParagraphElementText(value, "acqinfo");
314
- const appraisal = readParagraphElementText(value, "appraisal");
315
- const processingInformation = readParagraphElementText(value, "processinfo");
316
- const relatedMaterial = readParagraphElementText(value, "relatedmaterial");
317
- const separatedMaterial = readParagraphElementText(value, "separatedmaterial");
318
- const preferredCitation = readParagraphElementText(value, "prefercite");
319
- const notes = asXmlArray(findXmlValue(value, "odd")).map((note) => readElementText(note, "p")).filter((note) => Boolean(note));
320
- const componentUnknown = collectUnknownXml(value, [
321
- "id",
322
- "level",
323
- "otherlevel",
324
- "did",
325
- "abstract",
326
- "scopecontent",
327
- "arrangement",
328
- "accessrestrict",
329
- "userestrict",
330
- "bioghist",
331
- "custodhist",
332
- "acqinfo",
333
- "appraisal",
334
- "processinfo",
335
- "relatedmaterial",
336
- "separatedmaterial",
337
- "prefercite",
338
- "odd",
339
- "dsc"
340
- ]);
341
- const didUnknown = collectUnknownXml(did, [
342
- "unitid",
343
- "unittitle",
344
- "unitdate",
345
- "physdesc",
346
- "origination",
347
- "langmaterial",
348
- "dao"
349
- ]);
350
- const componentExtensions = options.preserveUnknown === false ? {} : {
351
- ...componentUnknown ? { xml: componentUnknown } : {},
352
- ...didUnknown ? { did: didUnknown } : {}
353
- };
354
- return {
355
- ...id ? { id } : {},
356
- level: level.level,
357
- ...explicitOtherLevel ?? level.otherLevel ? { otherLevel: explicitOtherLevel ?? level.otherLevel } : {},
358
- title,
359
- ...referenceCode ? { referenceCode } : {},
360
- ...dates.length > 0 ? { dates } : {},
361
- ...extent ? { extent } : {},
362
- ...creator ? { creator } : {},
363
- ...abstract ? { abstract } : {},
364
- ...scopeContent ? { scopeContent } : {},
365
- ...arrangement ? { arrangement } : {},
366
- ...accessRestriction ? { accessRestriction } : {},
367
- ...useRestriction ? { useRestriction } : {},
368
- ...language ? { language } : {},
369
- ...biographicalHistory ? { biographicalHistory } : {},
370
- ...custodialHistory ? { custodialHistory } : {},
371
- ...acquisitionInformation ? { acquisitionInformation } : {},
372
- ...appraisal ? { appraisal } : {},
373
- ...processingInformation ? { processingInformation } : {},
374
- ...relatedMaterial ? { relatedMaterial } : {},
375
- ...separatedMaterial ? { separatedMaterial } : {},
376
- ...preferredCitation ? { preferredCitation } : {},
377
- ...notes.length > 0 ? { notes } : {},
378
- ...digitalObjects.length > 0 ? { digitalObjects } : {},
379
- ...components.length > 0 ? { components } : {},
380
- ...hasComponentExtensions(componentExtensions) ? { extensions: componentExtensions } : {}
381
- };
382
- }
383
- function getEadRoot(document) {
384
- if (normalizeXmlName(document.rootName) === "ead") return document.root;
385
- const maybeEad = findXmlValue(document.raw, "ead");
386
- return isRecord(maybeEad) ? maybeEad : void 0;
387
- }
388
- function ead3FromXmlDocument(document, options = {}) {
389
- const issues = [];
390
- const ead = getEadRoot(document);
391
- if (!ead) return ead3Fail([createEad3Issue({
392
- code: "ead3.root.required",
393
- path: "ead",
394
- message: "EAD3 document must contain an ead root element."
395
- })]);
396
- const control = readRecord(ead, "control");
397
- const titlestmt = readRecord(readRecord(control, "filedesc"), "titlestmt");
398
- const description = readComponent(findXmlValue(ead, "archdesc"), "description", issues, options);
399
- if (!description) return ead3Fail([createEad3Issue({
400
- code: "ead3.archdesc.required",
401
- path: "ead.archdesc",
402
- message: "EAD3 document must contain an archdesc element."
403
- })]);
404
- const recordId = readElementText(control, "recordid") ?? "";
405
- if (!recordId) issues.push(createEad3Issue({
406
- code: "ead3.recordId.required",
407
- path: "recordId",
408
- message: "EAD3 record id is required."
409
- }));
410
- const title = readElementText(titlestmt, "titleproper") ?? description.title;
411
- if (!title) issues.push(createEad3Issue({
412
- code: "ead3.title.required",
413
- path: "title",
414
- message: "EAD3 title is required."
415
- }));
416
- const agencyName = readElementText(readRecord(control, "maintenanceagency"), "agencyname");
417
- const maintenanceStatus = readMaintenanceStatus(findXmlValue(control, "maintenancestatus"));
418
- const eadUnknown = options.preserveUnknown === false ? void 0 : collectUnknownXml(ead, [
419
- "xmlns",
420
- "control",
421
- "archdesc"
422
- ]);
423
- const controlUnknown = options.preserveUnknown === false ? void 0 : collectUnknownXml(control, [
424
- "recordid",
425
- "maintenancestatus",
426
- "publicationstatus",
427
- "maintenanceagency",
428
- "filedesc"
429
- ]);
430
- const extensions = {
431
- ...eadUnknown ? { ead: eadUnknown } : {},
432
- ...controlUnknown ? { control: controlUnknown } : {}
433
- };
434
- const findingAid = {
435
- recordId,
436
- title,
437
- ...maintenanceStatus ? { maintenanceStatus } : {},
438
- ...agencyName ? { agencyName } : {},
439
- description,
440
- ...hasFindingAidExtensions(extensions) ? { extensions } : {}
441
- };
442
- return hasFormatErrors(issues) ? ead3Fail(issues, findingAid) : ead3Ok(findingAid, issues);
443
- }
444
- function parseEad3Xml(input, options = {}) {
445
- const parsed = parseXml(input, { arrayTags: EAD3_ARRAY_TAGS });
446
- if (!parsed.ok) return ead3Fail(parsed.issues);
447
- return ead3FromXmlDocument(parsed.value, options);
448
- }
449
- function ead3ToXmlDocument(findingAid, options = {}) {
450
- const issues = validateEad3(findingAid, options);
451
- if (hasFormatErrors(issues)) return ead3Fail(issues);
452
- const raw = findingAidToXmlObject(findingAid);
453
- const ead = raw.ead;
454
- if (!isRecord(ead)) return ead3Fail([createEad3Issue({
455
- code: "ead3.serialize.failed",
456
- path: "ead",
457
- message: "EAD3 serializer did not produce an ead root element."
458
- })]);
459
- return ead3Ok({
460
- rootName: "ead",
461
- root: ead,
462
- raw
463
- });
464
- }
465
- function serializeEad3Xml(findingAid, options = {}) {
466
- const document = ead3ToXmlDocument(findingAid);
467
- if (!document.ok) return ead3Fail(document.issues);
468
- return withEad3Profile(buildXml(document.value, {
469
- format: options.format ?? true,
470
- suppressEmptyNode: true
471
- }));
472
- }
473
- function validateComponent(component, path) {
474
- const issues = [];
475
- if (!readString(component.title)) issues.push(createEad3Issue({
476
- code: "ead3.component.title.required",
477
- path: `${path}.title`,
478
- message: "EAD3 component title is required."
479
- }));
480
- component.digitalObjects?.forEach((ref, index) => {
481
- if (!readString(ref.href)) issues.push(createEad3Issue({
482
- code: "ead3.digitalObject.href.required",
483
- path: `${path}.digitalObjects.${index}.href`,
484
- message: "EAD3 digital object href is required."
485
- }));
486
- });
487
- component.components?.forEach((child, index) => {
488
- issues.push(...validateComponent(child, `${path}.components.${index}`));
489
- });
490
- return issues;
491
- }
492
- function validateEad3(findingAid, options = {}) {
493
- const issues = [];
494
- if ((options.requireRecordId ?? true) && !readString(findingAid.recordId)) issues.push(createEad3Issue({
495
- code: "ead3.recordId.required",
496
- path: "recordId",
497
- message: "EAD3 record id is required."
498
- }));
499
- if (!readString(findingAid.title)) issues.push(createEad3Issue({
500
- code: "ead3.title.required",
501
- path: "title",
502
- message: "EAD3 title is required."
503
- }));
504
- issues.push(...validateComponent(findingAid.description, "description"));
505
- return issues;
506
- }
507
- const ead3Adapter = {
508
- format: EAD3_FORMAT_ID,
509
- profile: EAD3_ADAPTER_PROFILE,
510
- parse: parseEad3Xml,
511
- serialize: serializeEad3Xml,
512
- validate: validateEad3,
513
- detect(input) {
514
- return /<([A-Za-z0-9_-]+:)?ead[\s>]/.test(input);
515
- }
516
- };
517
-
518
- //#endregion
519
- export { EAD3_ADAPTER_PROFILE, EAD3_FORMAT_GENERATION, EAD3_FORMAT_ID, EAD3_NAMESPACE, EAD3_OFFICIAL_SCHEMA_VALIDATION, EAD3_SCHEMA_REVISION, EAD3_SCHEMA_VERSION, EAD3_TAG_LIBRARY_VERSION, EAD3_VALIDATION_LEVEL, ead3Adapter, ead3FromXmlDocument, ead3ToXmlDocument, parseEad3Xml, serializeEad3Xml, validateEad3 };
520
- //# sourceMappingURL=index.js.map
5
+ export { EAD3_ADAPTER_PROFILE, EAD3_FORMAT_GENERATION, EAD3_FORMAT_ID, EAD3_NAMESPACE, EAD3_OFFICIAL_SCHEMA_VALIDATION, EAD3_SCHEMA_REVISION, EAD3_SCHEMA_VERSION, EAD3_TAG_LIBRARY_VERSION, EAD3_VALIDATION_LEVEL, ead3Adapter, ead3FromXmlDocument, ead3ToXmlDocument, parseEad3Xml, serializeEad3Xml, validateEad3 };