ochre-sdk 1.3.25 → 1.3.27
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/dist/categories.d.mts +56 -56
- package/dist/categories.mjs +39 -39
- package/dist/constants.d.mts +8 -8
- package/dist/constants.mjs +6 -6
- package/dist/errors.d.mts +12 -12
- package/dist/errors.mjs +22 -23
- package/dist/fetchers/container-items.d.mts +28 -28
- package/dist/fetchers/container-items.mjs +27 -27
- package/dist/fetchers/gallery.d.mts +13 -13
- package/dist/fetchers/gallery.mjs +2 -2
- package/dist/fetchers/item-children.d.mts +12 -12
- package/dist/fetchers/item-children.mjs +2 -2
- package/dist/fetchers/item-links.d.mts +10 -10
- package/dist/fetchers/item-links.mjs +6 -6
- package/dist/fetchers/item-locations.d.mts +20 -20
- package/dist/fetchers/item-locations.mjs +3 -3
- package/dist/fetchers/item-ocr-data.d.mts +23 -23
- package/dist/fetchers/item-ocr-data.mjs +44 -44
- package/dist/fetchers/item.d.mts +23 -18
- package/dist/fetchers/item.mjs +15 -15
- package/dist/fetchers/map-layers.d.mts +15 -15
- package/dist/fetchers/map-layers.mjs +12 -11
- package/dist/fetchers/request.d.mts +40 -40
- package/dist/fetchers/request.mjs +37 -37
- package/dist/fetchers/set/items.d.mts +15 -15
- package/dist/fetchers/set/items.mjs +1 -1
- package/dist/fetchers/set/property-values.d.mts +16 -16
- package/dist/fetchers/set/property-values.mjs +43 -43
- package/dist/fetchers/tree/items.d.mts +27 -27
- package/dist/fetchers/tree/items.mjs +1 -1
- package/dist/fetchers/website-metadata.d.mts +4 -4
- package/dist/fetchers/website-metadata.mjs +9 -9
- package/dist/fetchers/website.d.mts +10 -10
- package/dist/fetchers/website.mjs +12 -12
- package/dist/getters.d.mts +83 -83
- package/dist/getters.mjs +74 -74
- package/dist/helpers.d.mts +4 -4
- package/dist/helpers.mjs +7 -7
- package/dist/index.d.mts +3 -3
- package/dist/index.mjs +5 -5
- package/dist/languages.d.mts +58 -58
- package/dist/languages.mjs +21 -21
- package/dist/ocr.d.mts +27 -27
- package/dist/ocr.mjs +29 -29
- package/dist/parsers/helpers.d.mts +23 -23
- package/dist/parsers/helpers.mjs +8 -8
- package/dist/parsers/index.d.mts +2 -2
- package/dist/parsers/index.mjs +15 -15
- package/dist/parsers/languages.d.mts +49 -49
- package/dist/parsers/languages.mjs +49 -49
- package/dist/parsers/multilingual.d.mts +174 -174
- package/dist/parsers/multilingual.mjs +146 -146
- package/dist/parsers/partial-date.d.mts +12 -12
- package/dist/parsers/partial-date.mjs +11 -11
- package/dist/parsers/property-token.d.mts +20 -20
- package/dist/parsers/property-token.mjs +16 -16
- package/dist/parsers/string.d.mts +33 -33
- package/dist/parsers/string.mjs +62 -64
- package/dist/parsers/website/bounds.d.mts +6 -6
- package/dist/parsers/website/bounds.mjs +5 -5
- package/dist/parsers/website/components.d.mts +46 -31
- package/dist/parsers/website/components.mjs +84 -51
- package/dist/parsers/website/index.d.mts +2 -2
- package/dist/parsers/website/index.mjs +45 -48
- package/dist/parsers/website/links.d.mts +24 -24
- package/dist/parsers/website/links.mjs +18 -18
- package/dist/parsers/website/messages.d.mts +16 -16
- package/dist/parsers/website/messages.mjs +14 -14
- package/dist/parsers/website/options.d.mts +1 -1
- package/dist/parsers/website/properties.d.mts +17 -8
- package/dist/parsers/website/properties.mjs +31 -10
- package/dist/parsers/website/reader.d.mts +55 -47
- package/dist/parsers/website/reader.mjs +66 -51
- package/dist/parsers/website/slug.d.mts +50 -50
- package/dist/parsers/website/slug.mjs +36 -36
- package/dist/parsers/website/styles.d.mts +18 -18
- package/dist/parsers/website/styles.mjs +19 -19
- package/dist/parsers/website/walk.d.mts +46 -46
- package/dist/parsers/website/walk.mjs +34 -34
- package/dist/query.d.mts +63 -63
- package/dist/query.mjs +137 -140
- package/dist/reflection.d.mts +51 -51
- package/dist/reflection.mjs +45 -45
- package/dist/schemas.d.mts +44 -44
- package/dist/schemas.mjs +50 -50
- package/dist/types/index.d.mts +192 -192
- package/dist/types/utilities.d.mts +5 -5
- package/dist/types/website.d.mts +74 -62
- package/dist/xml/dates.d.mts +9 -9
- package/dist/xml/dates.mjs +9 -9
- package/dist/xml/metadata.d.mts +14 -14
- package/dist/xml/metadata.mjs +18 -18
- package/dist/xml/schemas.mjs +24 -24
- package/dist/xml/types.d.mts +9 -9
- package/dist/xquery.d.mts +49 -49
- package/dist/xquery.mjs +50 -50
- package/package.json +10 -10
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
/**
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
2
|
+
Flatten an intersection so editors show one object instead of `A & B`
|
|
3
|
+
|
|
4
|
+
Deliberately not re-exported from the package root: it is a TypeScript
|
|
5
|
+
presentation detail, not part of the OCHRE model.
|
|
6
|
+
*/
|
|
7
7
|
export type Prettify<T> = { [K in keyof T]: T[K]; } & {};
|
package/dist/types/website.d.mts
CHANGED
|
@@ -1,16 +1,16 @@
|
|
|
1
1
|
import { MultilingualString } from "../parsers/multilingual.mjs";
|
|
2
|
+
import { Bibliography, Identification, ItemCategory, LanguageCodes, License, Metadata, Person, QueryablePropertyValueDataType, SimplifiedProperty } from "./index.mjs";
|
|
2
3
|
import { Prettify } from "./utilities.mjs";
|
|
3
|
-
import { Bibliography, Identification, ItemCategory, LanguageCodes, License, Metadata, Person, QueryablePropertyValueDataType } from "./index.mjs";
|
|
4
4
|
/**
|
|
5
|
-
|
|
6
|
-
|
|
5
|
+
Represents a context tree level item with a variable and value
|
|
6
|
+
*/
|
|
7
7
|
export type ContextTreeLevelItem = {
|
|
8
8
|
variableUuid: string;
|
|
9
9
|
valueUuid: string | null;
|
|
10
10
|
};
|
|
11
11
|
/**
|
|
12
|
-
|
|
13
|
-
|
|
12
|
+
Represents a context tree level with a context item
|
|
13
|
+
*/
|
|
14
14
|
export type ContextTreeLevel<T extends LanguageCodes = LanguageCodes> = {
|
|
15
15
|
context: Array<ContextTreeLevelItem>;
|
|
16
16
|
identification: Identification<T>;
|
|
@@ -18,12 +18,12 @@ export type ContextTreeLevel<T extends LanguageCodes = LanguageCodes> = {
|
|
|
18
18
|
type: string;
|
|
19
19
|
};
|
|
20
20
|
/**
|
|
21
|
-
|
|
22
|
-
|
|
21
|
+
Represents the input control a filter context level is rendered with
|
|
22
|
+
*/
|
|
23
23
|
export type ContextTreeFilterVariant = "checkbox" | "chip" | "range" | "tile" | "toggle";
|
|
24
24
|
/**
|
|
25
|
-
|
|
26
|
-
|
|
25
|
+
Represents a filter context tree level with a context item
|
|
26
|
+
*/
|
|
27
27
|
export type ContextTreeFilterLevel<T extends LanguageCodes = LanguageCodes> = Prettify<ContextTreeLevel<T> & {
|
|
28
28
|
filterType: "property" | "coordinates" | "bibliography" | "period";
|
|
29
29
|
filterVariant: ContextTreeFilterVariant | null;
|
|
@@ -32,8 +32,8 @@ export type ContextTreeFilterLevel<T extends LanguageCodes = LanguageCodes> = Pr
|
|
|
32
32
|
isSidebarOpen: boolean;
|
|
33
33
|
}>;
|
|
34
34
|
/**
|
|
35
|
-
|
|
36
|
-
|
|
35
|
+
Represents a context tree with levels grouped by behavior
|
|
36
|
+
*/
|
|
37
37
|
export type ContextTree<T extends LanguageCodes = LanguageCodes> = {
|
|
38
38
|
flatten: Array<ContextTreeLevel<T>>;
|
|
39
39
|
suppress: Array<ContextTreeLevel<T>>;
|
|
@@ -45,17 +45,17 @@ export type ContextTree<T extends LanguageCodes = LanguageCodes> = {
|
|
|
45
45
|
prominent: Array<ContextTreeLevel<T>>;
|
|
46
46
|
};
|
|
47
47
|
/**
|
|
48
|
-
|
|
49
|
-
|
|
48
|
+
Represents a scope with its UUID, type and identification
|
|
49
|
+
*/
|
|
50
50
|
export type Scope<T extends LanguageCodes = LanguageCodes> = {
|
|
51
51
|
uuid: string;
|
|
52
52
|
type: string;
|
|
53
53
|
identification: Identification<T>;
|
|
54
54
|
};
|
|
55
55
|
/**
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
56
|
+
Represents the parsed OCHRE "options" block shared by the website itself and
|
|
57
|
+
by every web element component that supports it
|
|
58
|
+
*/
|
|
59
59
|
export type WebOptions<T extends LanguageCodes = LanguageCodes> = {
|
|
60
60
|
scopes: Array<Scope<T>> | null;
|
|
61
61
|
contextTree: ContextTree<T> | null;
|
|
@@ -64,43 +64,43 @@ export type WebOptions<T extends LanguageCodes = LanguageCodes> = {
|
|
|
64
64
|
};
|
|
65
65
|
};
|
|
66
66
|
/**
|
|
67
|
-
|
|
68
|
-
|
|
67
|
+
The style overrides for each viewport a website presentation targets
|
|
68
|
+
*/
|
|
69
69
|
export type ResponsiveStyles = {
|
|
70
70
|
default: Array<Style>;
|
|
71
71
|
tablet: Array<Style>;
|
|
72
72
|
mobile: Array<Style>;
|
|
73
73
|
};
|
|
74
74
|
/**
|
|
75
|
-
|
|
76
|
-
|
|
75
|
+
Whether an item page section and its header are shown
|
|
76
|
+
*/
|
|
77
77
|
export type WebSectionDisplay = {
|
|
78
78
|
isDisplayed: boolean;
|
|
79
79
|
isHeaderDisplayed: boolean;
|
|
80
80
|
};
|
|
81
81
|
/**
|
|
82
|
-
|
|
83
|
-
|
|
82
|
+
How a collection displays its items
|
|
83
|
+
*/
|
|
84
84
|
export type WebCollectionVariant = "slide" | "table" | "card" | "tile" | "showcase";
|
|
85
85
|
/**
|
|
86
|
-
|
|
87
|
-
|
|
86
|
+
How a website indicates that content is loading
|
|
87
|
+
*/
|
|
88
88
|
export type WebLoadingVariant = "spinner" | "skeleton" | "animation" | "none";
|
|
89
89
|
/**
|
|
90
|
-
|
|
91
|
-
|
|
90
|
+
How an item page groups a repeated section
|
|
91
|
+
*/
|
|
92
92
|
export type WebSectionVariant = "discrete" | "tabs-horizontal" | "tabs-vertical" | "tabular";
|
|
93
93
|
/**
|
|
94
|
-
|
|
95
|
-
|
|
94
|
+
How a website displays an item's related items
|
|
95
|
+
*/
|
|
96
96
|
export type WebRelationVariant = "list" | "dropdown-list" | "grid" | "gallery" | "inline";
|
|
97
97
|
/**
|
|
98
|
-
|
|
99
|
-
|
|
98
|
+
The IIIF viewer a website renders images with
|
|
99
|
+
*/
|
|
100
100
|
export type WebIiifViewer = "universal-viewer" | "clover";
|
|
101
101
|
/**
|
|
102
|
-
|
|
103
|
-
|
|
102
|
+
How a website restricts access to its content
|
|
103
|
+
*/
|
|
104
104
|
export type WebsitePrivacy = "public" | "password" | "credentials-ochre";
|
|
105
105
|
export type StylesheetItem<T extends LanguageCodes = LanguageCodes> = {
|
|
106
106
|
uuid: string;
|
|
@@ -129,12 +129,12 @@ export type WebsitePropertyQuery<T extends LanguageCodes = LanguageCodes> = Webs
|
|
|
129
129
|
or: Array<WebsitePropertyQuery<T>>;
|
|
130
130
|
};
|
|
131
131
|
/**
|
|
132
|
-
|
|
133
|
-
|
|
132
|
+
Represents the OCHRE website type
|
|
133
|
+
*/
|
|
134
134
|
export type WebsiteType = "traditional" | "digital-collection" | "plum" | "cedar" | "elm" | "maple" | "oak" | "palm";
|
|
135
135
|
/**
|
|
136
|
-
|
|
137
|
-
|
|
136
|
+
Represents a sidebar with its title, items, layout and responsive styles
|
|
137
|
+
*/
|
|
138
138
|
export type WebSidebar<T extends LanguageCodes = LanguageCodes> = {
|
|
139
139
|
isDisplayed: boolean;
|
|
140
140
|
items: Array<WebElement<T> | WebBlock<T>>;
|
|
@@ -144,8 +144,8 @@ export type WebSidebar<T extends LanguageCodes = LanguageCodes> = {
|
|
|
144
144
|
cssStyles: ResponsiveStyles;
|
|
145
145
|
};
|
|
146
146
|
/**
|
|
147
|
-
|
|
148
|
-
|
|
147
|
+
Represents a website with its properties and items
|
|
148
|
+
*/
|
|
149
149
|
export type Website<T extends LanguageCodes = LanguageCodes> = {
|
|
150
150
|
uuid: string;
|
|
151
151
|
type: "website" | "segment";
|
|
@@ -192,6 +192,18 @@ export type Website<T extends LanguageCodes = LanguageCodes> = {
|
|
|
192
192
|
items: Array<WebElement<T> | WebBlock<T>> | null;
|
|
193
193
|
};
|
|
194
194
|
sidebar: WebSidebar<T> | null;
|
|
195
|
+
/**
|
|
196
|
+
The settings every page of the website starts from, which a page
|
|
197
|
+
overrides by setting the property itself, each null when the website
|
|
198
|
+
leaves it unset
|
|
199
|
+
*/
|
|
200
|
+
page: { [K in "width" | "variant" | "isBreadcrumbsDisplayed" | "isSidebarDisplayed" | "isNavbarSearchBarDisplayed"]: Webpage<T>["properties"][K] | null; };
|
|
201
|
+
/**
|
|
202
|
+
The settings every element of a component starts from, keyed by
|
|
203
|
+
component name: the "component" properties of this website, then of each
|
|
204
|
+
enclosing one, which an element overrides by setting the property itself
|
|
205
|
+
*/
|
|
206
|
+
componentDefaults: Partial<Record<WebElementComponentName, Array<Array<SimplifiedProperty<T>>>>>;
|
|
195
207
|
itemPage: {
|
|
196
208
|
isMainContentDisplayed: boolean;
|
|
197
209
|
description: WebSectionDisplay;
|
|
@@ -225,10 +237,10 @@ export type Website<T extends LanguageCodes = LanguageCodes> = {
|
|
|
225
237
|
}>;
|
|
226
238
|
};
|
|
227
239
|
/**
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
240
|
+
The bare Map element of an OAK website, null for every other design. Its
|
|
241
|
+
bare Collection elements are in `items` as pages hidden from the navbar,
|
|
242
|
+
in tree order.
|
|
243
|
+
*/
|
|
232
244
|
oak: {
|
|
233
245
|
map: WebElementOf<"map", T> | null;
|
|
234
246
|
} | null;
|
|
@@ -237,8 +249,8 @@ export type WebsiteSegment<T extends LanguageCodes = LanguageCodes> = Website<T>
|
|
|
237
249
|
type: "segment";
|
|
238
250
|
};
|
|
239
251
|
/**
|
|
240
|
-
|
|
241
|
-
|
|
252
|
+
Represents a webpage with its title, slug, properties, items and subpages
|
|
253
|
+
*/
|
|
242
254
|
export type Webpage<T extends LanguageCodes = LanguageCodes> = {
|
|
243
255
|
uuid: string;
|
|
244
256
|
type: "page";
|
|
@@ -274,8 +286,8 @@ export type Webpage<T extends LanguageCodes = LanguageCodes> = {
|
|
|
274
286
|
webpages: Array<Webpage<T>>;
|
|
275
287
|
};
|
|
276
288
|
/**
|
|
277
|
-
|
|
278
|
-
|
|
289
|
+
Represents a title with its label and variant
|
|
290
|
+
*/
|
|
279
291
|
export type WebTitle<T extends LanguageCodes = LanguageCodes> = {
|
|
280
292
|
label: MultilingualString<T>;
|
|
281
293
|
variant: "default" | "simple";
|
|
@@ -288,8 +300,8 @@ export type WebTitle<T extends LanguageCodes = LanguageCodes> = {
|
|
|
288
300
|
};
|
|
289
301
|
};
|
|
290
302
|
/**
|
|
291
|
-
|
|
292
|
-
|
|
303
|
+
Base properties for web elements
|
|
304
|
+
*/
|
|
293
305
|
export type WebElement<T extends LanguageCodes = LanguageCodes> = {
|
|
294
306
|
uuid: string;
|
|
295
307
|
language: string | null;
|
|
@@ -298,8 +310,8 @@ export type WebElement<T extends LanguageCodes = LanguageCodes> = {
|
|
|
298
310
|
cssStyles: ResponsiveStyles;
|
|
299
311
|
} & WebElementComponent<T>;
|
|
300
312
|
/**
|
|
301
|
-
|
|
302
|
-
|
|
313
|
+
Union type of all possible web element components
|
|
314
|
+
*/
|
|
303
315
|
export type WebElementComponent<T extends LanguageCodes = LanguageCodes> = {
|
|
304
316
|
component: "3d-viewer";
|
|
305
317
|
linkUuid: string;
|
|
@@ -519,8 +531,8 @@ export type WebElementOf<U extends WebElementComponentName, T extends LanguageCo
|
|
|
519
531
|
component: U;
|
|
520
532
|
}>;
|
|
521
533
|
/**
|
|
522
|
-
|
|
523
|
-
|
|
534
|
+
Represents an image used in web elements
|
|
535
|
+
*/
|
|
524
536
|
export type WebImage<T extends LanguageCodes = LanguageCodes> = {
|
|
525
537
|
uuid: string | null;
|
|
526
538
|
label: MultilingualString<T> | null;
|
|
@@ -530,8 +542,8 @@ export type WebImage<T extends LanguageCodes = LanguageCodes> = {
|
|
|
530
542
|
quality: "low" | "high";
|
|
531
543
|
};
|
|
532
544
|
/**
|
|
533
|
-
|
|
534
|
-
|
|
545
|
+
Represents a CSS style with label and value
|
|
546
|
+
*/
|
|
535
547
|
export type Style = {
|
|
536
548
|
label: string;
|
|
537
549
|
value: string;
|
|
@@ -545,8 +557,8 @@ export type WebAccordionItem<T extends LanguageCodes = LanguageCodes> = {
|
|
|
545
557
|
items: Array<WebBlockItem<T>>;
|
|
546
558
|
};
|
|
547
559
|
/**
|
|
548
|
-
|
|
549
|
-
|
|
560
|
+
Represents a block of vertical or horizontal content alignment
|
|
561
|
+
*/
|
|
550
562
|
export type WebBlock<T extends LanguageCodes = LanguageCodes, U extends WebBlockLayout = WebBlockLayout> = {
|
|
551
563
|
uuid: string;
|
|
552
564
|
language: string | null;
|
|
@@ -558,12 +570,12 @@ export type WebBlock<T extends LanguageCodes = LanguageCodes, U extends WebBlock
|
|
|
558
570
|
layout: U;
|
|
559
571
|
wrap: "nowrap" | "wrap" | "wrap-reverse";
|
|
560
572
|
/**
|
|
561
|
-
|
|
562
|
-
|
|
573
|
+
valid `gridTemplateColumns` or `gridTemplateRows` CSS property value
|
|
574
|
+
*/
|
|
563
575
|
spacing: string | null;
|
|
564
576
|
/**
|
|
565
|
-
|
|
566
|
-
|
|
577
|
+
`gap` CSS property value
|
|
578
|
+
*/
|
|
567
579
|
gap: string | null;
|
|
568
580
|
isAccordionEnabled: U extends "accordion" ? boolean : never;
|
|
569
581
|
isAccordionExpandedByDefault: U extends "accordion" ? boolean : never;
|
|
@@ -601,6 +613,6 @@ export type ProtectedWebsite<T extends LanguageCodes = LanguageCodes> = {
|
|
|
601
613
|
};
|
|
602
614
|
export type AccordionWebBlock<T extends LanguageCodes = LanguageCodes> = WebBlock<T, "accordion">;
|
|
603
615
|
/**
|
|
604
|
-
|
|
605
|
-
|
|
616
|
+
Represents a stylesheet item with its UUID and category
|
|
617
|
+
*/
|
|
606
618
|
export type StylesheetCategory = Extract<ItemCategory, "propertyVariable" | "propertyValue">;
|
package/dist/xml/dates.d.mts
CHANGED
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
/**
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
2
|
+
Parses ISO date/time strings and OCHRE's "YYYY-MM-DD HH:mm:ss" format.
|
|
3
|
+
Like date-fns parseISO: strings without a timezone offset (including
|
|
4
|
+
date-only strings) are parsed as local time, not UTC. Returns an
|
|
5
|
+
Invalid Date for anything unparseable.
|
|
6
|
+
|
|
7
|
+
@param value - The date/time string to parse.
|
|
8
|
+
@returns A Date object representing the parsed date/time, or an Invalid Date if parsing fails.
|
|
9
|
+
@internal
|
|
10
|
+
*/
|
|
11
11
|
export declare function parseDateTime(value: string): Date;
|
package/dist/xml/dates.mjs
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
// src/xml/dates.ts
|
|
2
2
|
/**
|
|
3
|
-
|
|
3
|
+
Regular expression to match ISO date/time strings and OCHRE's "YYYY-MM-DD HH:mm:ss" format.
|
|
4
4
|
*/
|
|
5
5
|
const DATE_TIME_REGEX = /^(\d{4})(?:-(\d{2})(?:-(\d{2}))?)?(?:T(\d{2})(?::(\d{2})(?::(\d{2})(?:[.,](\d+))?)?)?(Z|[+-]\d{2}(?::?\d{2})?)?)?$/;
|
|
6
6
|
function applyTimezoneOffset(date, timezone) {
|
|
@@ -11,14 +11,14 @@ function applyTimezoneOffset(date, timezone) {
|
|
|
11
11
|
return new Date(date.getTime() + offsetSign * (offsetHours * 36e5 + offsetMinutes * 6e4));
|
|
12
12
|
}
|
|
13
13
|
/**
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
14
|
+
Parses ISO date/time strings and OCHRE's "YYYY-MM-DD HH:mm:ss" format.
|
|
15
|
+
Like date-fns parseISO: strings without a timezone offset (including
|
|
16
|
+
date-only strings) are parsed as local time, not UTC. Returns an
|
|
17
|
+
Invalid Date for anything unparseable.
|
|
18
|
+
|
|
19
|
+
@param value - The date/time string to parse.
|
|
20
|
+
@returns A Date object representing the parsed date/time, or an Invalid Date if parsing fails.
|
|
21
|
+
@internal
|
|
22
22
|
*/
|
|
23
23
|
function parseDateTime(value) {
|
|
24
24
|
const match = DATE_TIME_REGEX.exec(value.replace(" ", "T"));
|
package/dist/xml/metadata.d.mts
CHANGED
|
@@ -1,18 +1,18 @@
|
|
|
1
1
|
/**
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
2
|
+
Read the offset a node started at in the source XML
|
|
3
|
+
@param value - The parsed node
|
|
4
|
+
@returns The offset, or null when the node carries no source metadata
|
|
5
|
+
@internal
|
|
6
|
+
*/
|
|
7
7
|
export declare function getXMLSourceIndex(value: unknown): number | null;
|
|
8
8
|
/**
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
9
|
+
Re-attach the source metadata validation dropped
|
|
10
|
+
|
|
11
|
+
`v.safeParse` returns a fresh object graph and does not carry over the
|
|
12
|
+
non-enumerable symbol `fast-xml-parser` records offsets under, so it is
|
|
13
|
+
grafted back on by walking the validated output alongside the raw input.
|
|
14
|
+
@param output - The validated output to graft onto
|
|
15
|
+
@param input - The raw parsed input to read metadata from
|
|
16
|
+
@internal
|
|
17
|
+
*/
|
|
18
18
|
export declare function restoreXMLMetadata(output: unknown, input: unknown): void;
|
package/dist/xml/metadata.mjs
CHANGED
|
@@ -3,35 +3,35 @@ import { XMLParser } from "fast-xml-parser";
|
|
|
3
3
|
// src/xml/metadata.ts
|
|
4
4
|
const XML_METADATA_SYMBOL = XMLParser.getMetaDataSymbol();
|
|
5
5
|
/**
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
6
|
+
Read the source metadata `fast-xml-parser` attaches under a symbol key
|
|
7
|
+
|
|
8
|
+
Returned as `unknown`: nothing here needs to know its shape, only whether it
|
|
9
|
+
is there, and {@link getXMLSourceIndex} narrows the one field it reads.
|
|
10
|
+
@param value - The value to read from
|
|
11
|
+
@returns The metadata, or undefined when there is none
|
|
12
12
|
*/
|
|
13
13
|
function readXMLMetadata(value) {
|
|
14
14
|
return readProperty(value, XML_METADATA_SYMBOL);
|
|
15
15
|
}
|
|
16
16
|
/**
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
17
|
+
Read the offset a node started at in the source XML
|
|
18
|
+
@param value - The parsed node
|
|
19
|
+
@returns The offset, or null when the node carries no source metadata
|
|
20
|
+
@internal
|
|
21
21
|
*/
|
|
22
22
|
function getXMLSourceIndex(value) {
|
|
23
23
|
const startIndex = readProperty(readXMLMetadata(value), "startIndex");
|
|
24
24
|
return typeof startIndex === "number" ? startIndex : null;
|
|
25
25
|
}
|
|
26
26
|
/**
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
27
|
+
Re-attach the source metadata validation dropped
|
|
28
|
+
|
|
29
|
+
`v.safeParse` returns a fresh object graph and does not carry over the
|
|
30
|
+
non-enumerable symbol `fast-xml-parser` records offsets under, so it is
|
|
31
|
+
grafted back on by walking the validated output alongside the raw input.
|
|
32
|
+
@param output - The validated output to graft onto
|
|
33
|
+
@param input - The raw parsed input to read metadata from
|
|
34
|
+
@internal
|
|
35
35
|
*/
|
|
36
36
|
function restoreXMLMetadata(output, input) {
|
|
37
37
|
if (!isObject(output) || !isObject(input)) return;
|
package/dist/xml/schemas.mjs
CHANGED
|
@@ -49,10 +49,10 @@ const XMLRichTextEnvelope = {
|
|
|
49
49
|
annotation: v.optional(v.string("XMLRichTextEnvelope: annotation is string and optional"))
|
|
50
50
|
};
|
|
51
51
|
/**
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
52
|
+
The entries every string-like OCHRE element carries
|
|
53
|
+
|
|
54
|
+
Spread rather than re-listed by the shapes that embed a string envelope, so
|
|
55
|
+
a shape cannot declare the envelope in its type and forget to validate it.
|
|
56
56
|
*/
|
|
57
57
|
const XMLStringEntries = {
|
|
58
58
|
payload: v.optional(v.string("XMLString: payload is string and optional")),
|
|
@@ -309,12 +309,12 @@ const XMLProperty = v.lazy(() => v.object({
|
|
|
309
309
|
property: v.optional(v.array(XMLProperty, "XMLProperty: property is array of XMLProperty"))
|
|
310
310
|
}, "XMLProperty: Shape error"));
|
|
311
311
|
/**
|
|
312
|
-
|
|
313
|
-
|
|
314
|
-
|
|
315
|
-
|
|
316
|
-
|
|
317
|
-
|
|
312
|
+
The raw shape of a simplified property
|
|
313
|
+
|
|
314
|
+
Identical to {@link XMLProperty}: OCHRE serves one shape, and the
|
|
315
|
+
"simplified" distinction is a parsing choice, not a wire-format one. The
|
|
316
|
+
parser decides whether a label becomes a multilingual string or a plain
|
|
317
|
+
string; nothing about the XML differs.
|
|
318
318
|
*/
|
|
319
319
|
const XMLSimplifiedProperty = XMLProperty;
|
|
320
320
|
const XMLBaseItem = v.object({
|
|
@@ -822,16 +822,16 @@ const XMLWebsiteSegment = v.lazy(() => v.object({
|
|
|
822
822
|
publicationDateTime: v.optional(customDateTime("XMLWebsiteSegment: publicationDateTime is not a valid datetime"))
|
|
823
823
|
}, "XMLWebsiteSegment: Shape error"));
|
|
824
824
|
/**
|
|
825
|
-
|
|
826
|
-
|
|
827
|
-
|
|
828
|
-
|
|
829
|
-
|
|
830
|
-
|
|
831
|
-
|
|
832
|
-
|
|
833
|
-
|
|
834
|
-
|
|
825
|
+
A website resource item
|
|
826
|
+
|
|
827
|
+
The member order is load-bearing, because a union returns its first match
|
|
828
|
+
and every member is an object schema, which drops the keys its own shape
|
|
829
|
+
does not name. {@link XMLWebsiteSegment} goes first: every entry on
|
|
830
|
+
{@link XMLWebsiteResource} other than `uuid` is optional, so a segment
|
|
831
|
+
wrapper satisfies that schema too and would come back without its
|
|
832
|
+
`segments`. {@link XMLWebsiteResourceGroup} goes last for the mirror
|
|
833
|
+
reason, since a resource holding children satisfies the group shape and
|
|
834
|
+
would lose its own slug and properties.
|
|
835
835
|
*/
|
|
836
836
|
const XMLWebsiteResourceItem = v.lazy(() => v.union([
|
|
837
837
|
XMLWebsiteSegment,
|
|
@@ -901,10 +901,10 @@ const XMLDataItem = v.union([
|
|
|
901
901
|
v.object({ set: v.array(XMLSet) }, "XMLDataItem: set is array of XMLSet")
|
|
902
902
|
], "XMLDataItem: Shape error");
|
|
903
903
|
/**
|
|
904
|
-
|
|
905
|
-
|
|
906
|
-
|
|
907
|
-
|
|
904
|
+
Whether any child of these items has children of its own
|
|
905
|
+
|
|
906
|
+
Driven by the child element's name rather than an accessor, so the check does
|
|
907
|
+
not have to name a declared element type and cannot drift from one.
|
|
908
908
|
*/
|
|
909
909
|
function hasNestedRecursiveChildren(items, childKey) {
|
|
910
910
|
for (const item of items) for (const child of readArrayProperty(item, childKey)) if (readArrayProperty(child, childKey).length > 0) return true;
|
package/dist/xml/types.d.mts
CHANGED
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
export type XMLItemCategory = "tree" | "bibliography" | "spatialUnit" | "concept" | "period" | "person" | "propertyVariable" | "variable" | "propertyValue" | "value" | "text" | "resource" | "set";
|
|
2
2
|
export type XMLRecursiveItemCategory = Exclude<XMLItemCategory, "tree" | "person" | "propertyVariable" | "propertyValue" | "set">;
|
|
3
3
|
/**
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
4
|
+
Rich text envelope shared by `<string>` and `<content>` nodes, carrying the
|
|
5
|
+
inline links, presentation properties and annotation identifier that turn a
|
|
6
|
+
span of text into an annotation.
|
|
7
|
+
*/
|
|
8
8
|
export type XMLRichTextEnvelope = {
|
|
9
9
|
links?: XMLLink;
|
|
10
10
|
properties?: {
|
|
@@ -244,11 +244,11 @@ export type XMLProperty = {
|
|
|
244
244
|
property?: Array<XMLProperty>;
|
|
245
245
|
};
|
|
246
246
|
/**
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
247
|
+
The raw shape of a simplified property
|
|
248
|
+
|
|
249
|
+
Identical to {@link XMLProperty}: the "simplified" distinction is a parsing
|
|
250
|
+
choice, not a wire-format one.
|
|
251
|
+
*/
|
|
252
252
|
export type XMLSimplifiedProperty = XMLProperty;
|
|
253
253
|
export type XMLBaseItem = {
|
|
254
254
|
uuid: string;
|