@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.
package/README.md CHANGED
@@ -7,6 +7,7 @@ The package is intentionally modular and tree-shakeable. Consumers import only t
7
7
  ```ts
8
8
  import { parseXml } from '@daihum/record-formats/xml';
9
9
  import { parseEad3Xml } from '@daihum/record-formats/ead3';
10
+ import { parseArchiveDescriptionJson } from '@daihum/record-formats/archive-description';
10
11
  ```
11
12
 
12
13
  ## Initial scope
@@ -14,6 +15,8 @@ import { parseEad3Xml } from '@daihum/record-formats/ead3';
14
15
  - Common result and issue contracts for parse, serialize, and validation workflows.
15
16
  - XML parse/build helpers backed by `fast-xml-parser`.
16
17
  - EAD3 finding-aid projection helpers adapted from Carrel's initial XML/EAD starter.
18
+ - `archive-description.v1`, the canonical recursive Archive record, with JSON Schema,
19
+ DACS profile validation, and explicit EAD3 projection diagnostics.
17
20
 
18
21
  Future modules can add TEI, MARC/MARCXML, MODS, Dublin Core, EAC-CPF, and crosswalk helpers under explicit subpaths without forcing consumers to import the whole surface.
19
22
 
@@ -31,6 +34,24 @@ Future modules can add TEI, MARC/MARCXML, MODS, Dublin Core, EAC-CPF, and crossw
31
34
 
32
35
  This means the adapter validates DAIHUM's common finding-aid projection fields and parser/serializer invariants. It does not run official EAD3 RNG, XSD, DTD, or Schematron schema validation yet. Consumers should surface the adapter profile when exporting or importing EAD XML so users can distinguish projection output from full schema validation.
33
36
 
37
+ ## Archive Description
38
+
39
+ `@daihum/record-formats/archive-description` owns the canonical Archive-domain
40
+ record. One `archive-description.v1` record represents one finding aid. Its
41
+ stable node ids and recursive `subItems` tree keep hierarchy and description in
42
+ one versioned truth while opaque target refs connect nodes to external material,
43
+ page, representation, or annotation records.
44
+
45
+ EAD3 is a bidirectional projection of that record, not the canonical store.
46
+ Projection results include structured warnings whenever a canonical fact cannot
47
+ be represented. DACS checks are a separate conformance profile; they do not
48
+ change the structural parser. The JSON Schema id and revision are exported for
49
+ storage envelopes and exchange validation.
50
+
51
+ Cross-tree node-id uniqueness is enforced by the package runtime validator.
52
+ JSON Schema validates the recursive shape and collection root but cannot express
53
+ that global uniqueness invariant.
54
+
34
55
  ## Boundaries
35
56
 
36
57
  This package owns format adapters and reusable record mappings. Product storage, UI, CLI, import jobs, copy, and downstream persistence remain in Carrel, ONTAL, or other consuming apps.
@@ -0,0 +1,163 @@
1
+ import { i as FormatResult, l as SerializeResult, n as FormatIssue, s as ParseResult } from "../result-D7vcrlFh.js";
2
+ import { k as Ead3FindingAid, w as Ead3Component } from "../index-DxjnI5KZ.js";
3
+ import "../index-BNudmNFx.js";
4
+
5
+ //#region src/archive-description/types.d.ts
6
+ declare const ARCHIVE_DESCRIPTION_SCHEMA: "archive-description.v1";
7
+ type ArchiveDescriptionSchema = typeof ARCHIVE_DESCRIPTION_SCHEMA;
8
+ type ArchiveDescriptionLevel = 'collection' | 'series' | 'subseries' | 'file' | 'item' | 'otherlevel';
9
+ type ArchiveDescriptionMaintenanceStatus = 'new' | 'revised' | 'deleted' | 'derived' | 'unknown';
10
+ type ArchiveDescriptionDate = Readonly<{
11
+ expression: string;
12
+ normalized?: string;
13
+ type?: string;
14
+ certainty?: string;
15
+ }>;
16
+ type ArchiveDescriptionAccessPointType = 'person' | 'family' | 'organization' | 'place' | 'subject' | 'documentaryForm' | 'occupation' | 'function' | (string & Record<never, never>);
17
+ type ArchiveDescriptionAccessPoint = Readonly<{
18
+ type: ArchiveDescriptionAccessPointType;
19
+ label: string;
20
+ identifier?: string;
21
+ source?: string;
22
+ }>;
23
+ /** A product-neutral reference to material, a representation, or an annotation. */
24
+ type ArchiveDescriptionTargetRef = Readonly<{
25
+ kind: string;
26
+ id: string;
27
+ href?: string;
28
+ label?: string;
29
+ role?: string;
30
+ locator?: Readonly<Record<string, unknown>>;
31
+ metadata?: Readonly<Record<string, unknown>>;
32
+ }>;
33
+ type ArchiveDescriptionReviewStatus = 'unreviewed' | 'needs_review' | 'accepted' | 'rejected';
34
+ type ArchiveDescriptionProvenance = Readonly<{
35
+ createdBy: string;
36
+ createdAt: string;
37
+ method: string;
38
+ rules?: readonly string[];
39
+ tool?: string;
40
+ model?: string;
41
+ reviewStatus?: ArchiveDescriptionReviewStatus;
42
+ reviewedBy?: string;
43
+ reviewedAt?: string;
44
+ }>;
45
+ type ArchiveDescriptionSourceDiagnostic = Readonly<{
46
+ severity: 'error' | 'warning' | 'info';
47
+ code: string;
48
+ message: string;
49
+ path?: readonly string[];
50
+ }>;
51
+ type ArchiveDescriptionSourceRecord = Readonly<{
52
+ id: string;
53
+ producer: string;
54
+ format?: string;
55
+ source?: string;
56
+ retrievedAt?: string;
57
+ raw?: unknown;
58
+ mappedFields?: readonly string[];
59
+ unmappedFields?: unknown;
60
+ diagnostics?: readonly ArchiveDescriptionSourceDiagnostic[];
61
+ }>;
62
+ type ArchiveDescriptionVendorExtension = Readonly<{
63
+ namespace: string;
64
+ name: string;
65
+ value: unknown;
66
+ }>;
67
+ type ArchiveDescriptionExtensions = Readonly<{
68
+ ead3?: Readonly<Record<string, unknown>>;
69
+ vendor?: readonly ArchiveDescriptionVendorExtension[];
70
+ }>;
71
+ type ArchiveDescriptionNode = Readonly<{
72
+ /** Stable identity. It must not be derived from array position. */
73
+ id: string;
74
+ level: ArchiveDescriptionLevel;
75
+ otherLevel?: string;
76
+ title: string;
77
+ referenceCode?: string;
78
+ repository?: string;
79
+ dates?: readonly ArchiveDescriptionDate[];
80
+ extent?: string;
81
+ creator?: string;
82
+ creatorStatus?: 'known' | 'unknown' | 'not_applicable';
83
+ abstract?: string;
84
+ scopeContent?: string;
85
+ arrangement?: string;
86
+ accessRestriction?: string;
87
+ useRestriction?: string;
88
+ language?: string;
89
+ biographicalHistory?: string;
90
+ custodialHistory?: string;
91
+ acquisitionInformation?: string;
92
+ appraisal?: string;
93
+ processingInformation?: string;
94
+ relatedMaterial?: string;
95
+ separatedMaterial?: string;
96
+ preferredCitation?: string;
97
+ notes?: readonly string[];
98
+ accessPoints?: readonly ArchiveDescriptionAccessPoint[];
99
+ targets?: readonly ArchiveDescriptionTargetRef[];
100
+ provenance?: ArchiveDescriptionProvenance;
101
+ subItems?: readonly ArchiveDescriptionNode[];
102
+ extensions?: ArchiveDescriptionExtensions;
103
+ }>;
104
+ type ArchiveDescriptionRecord = Readonly<{
105
+ schema: ArchiveDescriptionSchema;
106
+ recordId: string;
107
+ title: string;
108
+ maintenanceStatus?: ArchiveDescriptionMaintenanceStatus;
109
+ language?: string;
110
+ agencyName?: string;
111
+ description: ArchiveDescriptionNode;
112
+ provenance: ArchiveDescriptionProvenance;
113
+ sourceRecords?: readonly ArchiveDescriptionSourceRecord[];
114
+ extensions?: ArchiveDescriptionExtensions;
115
+ }>;
116
+ type ArchiveDescriptionSerializeOptions = Readonly<{
117
+ format?: boolean;
118
+ }>;
119
+ //#endregion
120
+ //#region src/archive-description/archive-description.d.ts
121
+ declare const ARCHIVE_DESCRIPTION_FORMAT_ID = "archive-description";
122
+ declare function validateArchiveDescription(value: unknown): readonly FormatIssue[];
123
+ declare function parseArchiveDescriptionJson(input: string): ParseResult<ArchiveDescriptionRecord>;
124
+ declare function serializeArchiveDescriptionJson(record: ArchiveDescriptionRecord, options?: ArchiveDescriptionSerializeOptions): SerializeResult<string>;
125
+ declare const archiveDescriptionAdapter: {
126
+ format: string;
127
+ parse: typeof parseArchiveDescriptionJson;
128
+ serialize: typeof serializeArchiveDescriptionJson;
129
+ validate: typeof validateArchiveDescription;
130
+ detect(input: string): boolean;
131
+ };
132
+ //#endregion
133
+ //#region src/archive-description/dacs.d.ts
134
+ declare const DACS_PROFILE_ID = "daihum.record-formats.archive-description.dacs.v1";
135
+ type DacsValidationOptions = Readonly<{
136
+ requireMinimumAtEveryLevel?: boolean;
137
+ }>;
138
+ declare function validateDacsArchiveDescription(record: ArchiveDescriptionRecord, options?: DacsValidationOptions): readonly FormatIssue[];
139
+ //#endregion
140
+ //#region src/archive-description/ead3-projection.d.ts
141
+ declare const ARCHIVE_DESCRIPTION_EAD3_PROJECTION_ID = "daihum.record-formats.archive-description.ead3.v1";
142
+ type ArchiveDescriptionFromEad3Options = Readonly<{
143
+ provenance: ArchiveDescriptionProvenance;
144
+ sourceRecord?: ArchiveDescriptionSourceRecord;
145
+ nodeId?: (component: Ead3Component, path: string) => string | undefined;
146
+ }>;
147
+ declare function archiveDescriptionToEad3(record: ArchiveDescriptionRecord): FormatResult<Ead3FindingAid>;
148
+ declare function archiveDescriptionFromEad3(findingAid: Ead3FindingAid, options: ArchiveDescriptionFromEad3Options): FormatResult<ArchiveDescriptionRecord>;
149
+ //#endregion
150
+ //#region src/archive-description/identity.d.ts
151
+ declare const ARCHIVE_DESCRIPTION_SCHEMA_ID = "https://daihum.dev/schema/record-formats/archive-description.v1.json";
152
+ declare const ARCHIVE_DESCRIPTION_SCHEMA_TITLE = "DAIHUM Archive Description";
153
+ declare const ARCHIVE_DESCRIPTION_SCHEMA_VERSION: "archive-description.v1";
154
+ declare function canonicalJson(value: unknown): string;
155
+ declare function contentHash(input: string): string;
156
+ //#endregion
157
+ //#region src/archive-description/json-schema.d.ts
158
+ declare function buildArchiveDescriptionJsonSchema(): Record<string, unknown>;
159
+ declare const archiveDescriptionJsonSchema: Record<string, unknown>;
160
+ declare const ARCHIVE_DESCRIPTION_SCHEMA_REVISION: string;
161
+ //#endregion
162
+ export { ARCHIVE_DESCRIPTION_EAD3_PROJECTION_ID, ARCHIVE_DESCRIPTION_FORMAT_ID, ARCHIVE_DESCRIPTION_SCHEMA, ARCHIVE_DESCRIPTION_SCHEMA_ID, ARCHIVE_DESCRIPTION_SCHEMA_REVISION, ARCHIVE_DESCRIPTION_SCHEMA_TITLE, ARCHIVE_DESCRIPTION_SCHEMA_VERSION, type ArchiveDescriptionAccessPoint, type ArchiveDescriptionAccessPointType, type ArchiveDescriptionDate, type ArchiveDescriptionExtensions, type ArchiveDescriptionFromEad3Options, type ArchiveDescriptionLevel, type ArchiveDescriptionMaintenanceStatus, type ArchiveDescriptionNode, type ArchiveDescriptionProvenance, type ArchiveDescriptionRecord, type ArchiveDescriptionReviewStatus, type ArchiveDescriptionSchema, type ArchiveDescriptionSerializeOptions, type ArchiveDescriptionSourceDiagnostic, type ArchiveDescriptionSourceRecord, type ArchiveDescriptionTargetRef, type ArchiveDescriptionVendorExtension, DACS_PROFILE_ID, type DacsValidationOptions, archiveDescriptionAdapter, archiveDescriptionFromEad3, archiveDescriptionJsonSchema, archiveDescriptionToEad3, buildArchiveDescriptionJsonSchema, canonicalJson, contentHash, parseArchiveDescriptionJson, serializeArchiveDescriptionJson, validateArchiveDescription, validateDacsArchiveDescription };
163
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","names":[],"sources":["../../src/archive-description/types.ts","../../src/archive-description/archive-description.ts","../../src/archive-description/dacs.ts","../../src/archive-description/ead3-projection.ts","../../src/archive-description/identity.ts","../../src/archive-description/json-schema.ts"],"sourcesContent":[],"mappings":";;;;;cAAa;KAED,wBAAA,UAAkC;KAElC,uBAAA;KAQA,mCAAA;KAOA,sBAAA,GAAyB;EAnBxB,UAAA,EAAA,MAAA;EAED,UAAA,CAAA,EAAA,MAAA;EAEA,IAAA,CAAA,EAAA,MAAA;EAQA,SAAA,CAAA,EAAA,MAAA;AAOZ,CAAA,CAAA;AAOY,KAAA,iCAAA,GAAiC,QAS/B,GAAM,QAAA,GAAA,cAAA,GAAA,OAAA,GAAA,SAAA,GAAA,iBAAA,GAAA,YAAA,GAAA,UAAA,GAAA,CAAA,MAAA,GAAN,MAAM,CAAA,KAAA,EAAA,KAAA,CAAA,CAAA;AAER,KAAA,6BAAA,GAAgC,QACpC,CAAA;EAOI,IAAA,EAPJ,iCAO+B;EAMlB,KAAA,EAAA,MAAA;EAAT,UAAA,CAAA,EAAA,MAAA;EACU,MAAA,CAAA,EAAA,MAAA;CAAT,CAAA;;AAPqC,KAAtC,2BAAA,GAA8B,QAAQ,CAAA;EAUt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