ochre-sdk 1.0.77 → 1.0.79
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/constants.d.mts +13 -14
- package/dist/fetchers/gallery.d.mts +2 -3
- package/dist/fetchers/gallery.mjs +2 -1
- package/dist/fetchers/item-children.d.mts +3 -4
- package/dist/fetchers/item-children.mjs +2 -1
- package/dist/fetchers/item-links.d.mts +2 -3
- package/dist/fetchers/item-links.mjs +2 -1
- package/dist/fetchers/item-ocr-data.d.mts +2 -3
- package/dist/fetchers/item.d.mts +7 -8
- package/dist/fetchers/item.mjs +2 -1
- package/dist/fetchers/set/items.d.mts +2 -3
- package/dist/fetchers/set/items.mjs +2 -1
- package/dist/fetchers/set/property-values.d.mts +2 -3
- package/dist/fetchers/set/property-values.mjs +56 -49
- package/dist/fetchers/website-metadata.d.mts +2 -3
- package/dist/fetchers/website.d.mts +2 -3
- package/dist/getters.d.mts +40 -41
- package/dist/getters.mjs +6 -31
- package/dist/helpers.d.mts +3 -4
- package/dist/parsers/helpers.d.mts +16 -17
- package/dist/parsers/index.d.mts +19 -19
- package/dist/parsers/index.mjs +65 -48
- package/dist/parsers/mdx.d.mts +3 -4
- package/dist/parsers/multilingual.d.mts +9 -10
- package/dist/parsers/string.d.mts +5 -6
- package/dist/parsers/string.mjs +124 -146
- package/dist/parsers/website/index.d.mts +4 -5
- package/dist/parsers/website/index.mjs +595 -635
- package/dist/parsers/website/reader.d.mts +3 -4
- package/dist/query.d.mts +9 -7
- package/dist/query.mjs +24 -4
- package/dist/schemas.d.mts +9 -10
- package/dist/types/index.d.mts +118 -119
- package/dist/types/website.d.mts +34 -34
- package/dist/utilities.d.mts +9 -10
- package/dist/utilities.mjs +28 -25
- package/dist/xml/dates.d.mts +13 -0
- package/dist/xml/dates.mjs +49 -0
- package/dist/xml/metadata.d.mts +3 -4
- package/dist/xml/schemas.d.mts +8 -9
- package/dist/xml/schemas.mjs +15 -23
- package/dist/xml/types.d.mts +128 -131
- package/package.json +13 -12
|
@@ -3,7 +3,7 @@ import { LanguageCodes, PropertyValueContent, SimplifiedProperty } from "../../t
|
|
|
3
3
|
import { ParserOptions } from "../helpers.mjs";
|
|
4
4
|
//#region src/parsers/website/reader.d.ts
|
|
5
5
|
type WebsitePropertyContent<T extends LanguageCodes> = PropertyValueContent<T>["content"];
|
|
6
|
-
declare class WebsitePresentationReader<T extends LanguageCodes> {
|
|
6
|
+
export declare class WebsitePresentationReader<T extends LanguageCodes> {
|
|
7
7
|
private readonly sourceProperties;
|
|
8
8
|
constructor(sourceProperties: ReadonlyArray<SimplifiedProperty<T>>);
|
|
9
9
|
property(label: string): SimplifiedProperty<T> | null;
|
|
@@ -22,6 +22,5 @@ declare class WebsitePresentationReader<T extends LanguageCodes> {
|
|
|
22
22
|
get size(): number;
|
|
23
23
|
get properties(): ReadonlyArray<SimplifiedProperty<T>>;
|
|
24
24
|
}
|
|
25
|
-
declare function websitePresentationReader<T extends LanguageCodes>(properties: ReadonlyArray<SimplifiedProperty<T>>): WebsitePresentationReader<T>;
|
|
26
|
-
//#endregion
|
|
27
|
-
export { WebsitePresentationReader, websitePresentationReader };
|
|
25
|
+
export declare function websitePresentationReader<T extends LanguageCodes>(properties: ReadonlyArray<SimplifiedProperty<T>>): WebsitePresentationReader<T>;
|
|
26
|
+
//#endregion
|
package/dist/query.d.mts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { Query } from "./types/index.mjs";
|
|
2
2
|
//#region src/query.d.ts
|
|
3
|
-
declare function buildBelongsToCollectionQueryExpression(belongsToCollectionScopeUuids: Array<string>, belongsToCollectionPropertyVariableUuid: string): string | null;
|
|
3
|
+
export declare function buildBelongsToCollectionQueryExpression(belongsToCollectionScopeUuids: Array<string>, belongsToCollectionPropertyVariableUuid: string): string | null;
|
|
4
4
|
/**
|
|
5
5
|
* Compile a query tree into the XQuery `let` clauses that bind `$items` to the
|
|
6
6
|
* matching Set items
|
|
@@ -8,9 +8,12 @@ declare function buildBelongsToCollectionQueryExpression(belongsToCollectionScop
|
|
|
8
8
|
* Most queries compile to a single `cts:search` over the Set item projections.
|
|
9
9
|
* An `ocr` leaf cannot: the projections drop the `<ocr>` layer, so it resolves
|
|
10
10
|
* to a search over the Resource documents whose matching UUIDs are joined back
|
|
11
|
-
* in as an item path predicate.
|
|
12
|
-
*
|
|
13
|
-
*
|
|
11
|
+
* in as an item path predicate. A negated leaf cannot either, because CTS
|
|
12
|
+
* answers a negation for the whole fragment rather than for the item that
|
|
13
|
+
* matched, so it is filtered per item instead. Path predicates only ever AND,
|
|
14
|
+
* so such a leaf that sits under an `or` becomes its own arm of a node union
|
|
15
|
+
* instead, and one that sits under an `and` alongside a union becomes an
|
|
16
|
+
* intersection.
|
|
14
17
|
*
|
|
15
18
|
* The searchable path has to stay inline in `cts:search`: binding it to a
|
|
16
19
|
* variable first makes every query XDMP-UNSEARCHABLE.
|
|
@@ -20,7 +23,7 @@ declare function buildBelongsToCollectionQueryExpression(belongsToCollectionScop
|
|
|
20
23
|
* @param parameters.scopeQueryExpression - An optional CTS query ANDed into every compiled search
|
|
21
24
|
* @returns The prolog declaring the query helpers, and the `let` clauses binding `$items`
|
|
22
25
|
*/
|
|
23
|
-
declare function buildQueryPlan(parameters: {
|
|
26
|
+
export declare function buildQueryPlan(parameters: {
|
|
24
27
|
queries: Query | null;
|
|
25
28
|
baseItemsExpression: string;
|
|
26
29
|
scopeQueryExpression?: string | null;
|
|
@@ -28,5 +31,4 @@ declare function buildQueryPlan(parameters: {
|
|
|
28
31
|
prolog: string;
|
|
29
32
|
itemsClause: string;
|
|
30
33
|
};
|
|
31
|
-
//#endregion
|
|
32
|
-
export { buildBelongsToCollectionQueryExpression, buildQueryPlan };
|
|
34
|
+
//#endregion
|
package/dist/query.mjs
CHANGED
|
@@ -940,6 +940,23 @@ function buildCtsItemsPlan(queryExpression) {
|
|
|
940
940
|
};
|
|
941
941
|
}
|
|
942
942
|
/**
|
|
943
|
+
* Plan a negated leaf as an item path predicate
|
|
944
|
+
*
|
|
945
|
+
* A Set holds every one of its items in one fragment, and CTS resolves
|
|
946
|
+
* `cts:not-query` from the fragment indexes without filtering the match down to
|
|
947
|
+
* the node it came from. Negating inside the search query would therefore drop
|
|
948
|
+
* every item of a Set as soon as one of them matched, and keep every item of a
|
|
949
|
+
* Set that held no match at all. `cts:contains` evaluates the leaf against one
|
|
950
|
+
* item projection instead, which is the scope the negation is asking about.
|
|
951
|
+
*/
|
|
952
|
+
function buildNegatedItemsPlan(queryExpression) {
|
|
953
|
+
return {
|
|
954
|
+
kind: "search",
|
|
955
|
+
itemPredicates: [`[not(cts:contains(., ${queryExpression}))]`],
|
|
956
|
+
queryExpressions: []
|
|
957
|
+
};
|
|
958
|
+
}
|
|
959
|
+
/**
|
|
943
960
|
* Splice the children of same-kind child plans into their parent, so that a
|
|
944
961
|
* nested group of the same operator does not cost an extra search
|
|
945
962
|
*/
|
|
@@ -1021,7 +1038,7 @@ function buildItemsPlan(context, query) {
|
|
|
1021
1038
|
};
|
|
1022
1039
|
}
|
|
1023
1040
|
const queryExpression = buildLeafQueryExpression(context, query);
|
|
1024
|
-
return
|
|
1041
|
+
return query.isNegated === true ? buildNegatedItemsPlan(queryExpression) : buildCtsItemsPlan(queryExpression);
|
|
1025
1042
|
}
|
|
1026
1043
|
const optimizedIncludesGroupQueries = getCompatibleIncludesGroupLeaves(query);
|
|
1027
1044
|
if (optimizedIncludesGroupQueries != null) return buildCtsItemsPlan(buildIncludesGroupQueryExpression(context, optimizedIncludesGroupQueries));
|
|
@@ -1066,9 +1083,12 @@ function buildBelongsToCollectionQueryExpression(belongsToCollectionScopeUuids,
|
|
|
1066
1083
|
* Most queries compile to a single `cts:search` over the Set item projections.
|
|
1067
1084
|
* An `ocr` leaf cannot: the projections drop the `<ocr>` layer, so it resolves
|
|
1068
1085
|
* to a search over the Resource documents whose matching UUIDs are joined back
|
|
1069
|
-
* in as an item path predicate.
|
|
1070
|
-
*
|
|
1071
|
-
*
|
|
1086
|
+
* in as an item path predicate. A negated leaf cannot either, because CTS
|
|
1087
|
+
* answers a negation for the whole fragment rather than for the item that
|
|
1088
|
+
* matched, so it is filtered per item instead. Path predicates only ever AND,
|
|
1089
|
+
* so such a leaf that sits under an `or` becomes its own arm of a node union
|
|
1090
|
+
* instead, and one that sits under an `and` alongside a union becomes an
|
|
1091
|
+
* intersection.
|
|
1072
1092
|
*
|
|
1073
1093
|
* The searchable path has to stay inline in `cts:search`: binding it to a
|
|
1074
1094
|
* variable first makes every query XDMP-UNSEARCHABLE.
|
package/dist/schemas.d.mts
CHANGED
|
@@ -5,22 +5,22 @@ import * as v from "valibot";
|
|
|
5
5
|
* Schema for validating UUIDs
|
|
6
6
|
* @internal
|
|
7
7
|
*/
|
|
8
|
-
declare const uuidSchema: v.SchemaWithPipe<readonly [v.StringSchema<undefined>, v.CheckAction<string, "Invalid pseudo-UUID">]>;
|
|
8
|
+
export declare const uuidSchema: v.SchemaWithPipe<readonly [v.StringSchema<undefined>, v.CheckAction<string, "Invalid pseudo-UUID">]>;
|
|
9
9
|
/**
|
|
10
10
|
* Schema for validating language codes
|
|
11
11
|
* @internal
|
|
12
12
|
*/
|
|
13
|
-
declare const iso639_3Schema: v.SchemaWithPipe<readonly [v.StringSchema<"Language code must be a string">, v.RegexAction<string, "Language code must be exactly 3 lowercase letters">]>;
|
|
13
|
+
export declare const iso639_3Schema: v.SchemaWithPipe<readonly [v.StringSchema<"Language code must be a string">, v.RegexAction<string, "Language code must be exactly 3 lowercase letters">]>;
|
|
14
14
|
/**
|
|
15
15
|
* Valid component types for web elements
|
|
16
16
|
* @internal
|
|
17
17
|
*/
|
|
18
|
-
declare const componentSchema: v.PicklistSchema<readonly ["3d-viewer", "advanced-search", "annotated-document", "annotated-image", "audio-player", "bibliography", "button", "collection", "empty-space", "entries", "iframe", "iiif-viewer", "image", "image-gallery", "map", "query", "search-bar", "table", "text", "timeline", "video"], "Invalid/unknown web element component">;
|
|
18
|
+
export declare const componentSchema: v.PicklistSchema<readonly ["3d-viewer", "advanced-search", "annotated-document", "annotated-image", "audio-player", "bibliography", "button", "collection", "empty-space", "entries", "iframe", "iiif-viewer", "image", "image-gallery", "map", "query", "search-bar", "table", "text", "timeline", "video"], "Invalid/unknown web element component">;
|
|
19
19
|
/**
|
|
20
20
|
* Schema for validating gallery parameters
|
|
21
21
|
* @internal
|
|
22
22
|
*/
|
|
23
|
-
declare const gallerySchema: v.ObjectSchema<{
|
|
23
|
+
export declare const gallerySchema: v.ObjectSchema<{
|
|
24
24
|
readonly uuid: v.SchemaWithPipe<readonly [v.StringSchema<undefined>, v.CheckAction<string, "Invalid pseudo-UUID">]>;
|
|
25
25
|
readonly filter: v.OptionalSchema<v.StringSchema<undefined>, undefined>;
|
|
26
26
|
readonly page: v.SchemaWithPipe<readonly [v.NumberSchema<"Page must be positive">, v.CheckAction<number, "Page must be positive">]>;
|
|
@@ -30,12 +30,12 @@ declare const gallerySchema: v.ObjectSchema<{
|
|
|
30
30
|
* Schema for validating and parsing render options
|
|
31
31
|
* @internal
|
|
32
32
|
*/
|
|
33
|
-
declare const renderOptionsSchema: v.SchemaWithPipe<readonly [v.StringSchema<undefined>, v.TransformAction<string, string[]>, v.ArraySchema<v.PicklistSchema<["bold", "italic", "underline"], undefined>, undefined>]>;
|
|
33
|
+
export declare const renderOptionsSchema: v.SchemaWithPipe<readonly [v.StringSchema<undefined>, v.TransformAction<string, string[]>, v.ArraySchema<v.PicklistSchema<["bold", "italic", "underline"], undefined>, undefined>]>;
|
|
34
34
|
/**
|
|
35
35
|
* Schema for validating the parameters for the Set property values fetching function
|
|
36
36
|
* @internal
|
|
37
37
|
*/
|
|
38
|
-
declare const setPropertyValuesParametersSchema: v.ObjectSchema<{
|
|
38
|
+
export declare const setPropertyValuesParametersSchema: v.ObjectSchema<{
|
|
39
39
|
readonly setScopeUuids: v.SchemaWithPipe<readonly [v.ArraySchema<v.SchemaWithPipe<readonly [v.StringSchema<undefined>, v.CheckAction<string, "Invalid pseudo-UUID">]>, undefined>, v.MinLengthAction<string[], 1, "At least one set scope UUID is required">]>;
|
|
40
40
|
readonly belongsToCollectionScopeUuids: v.OptionalSchema<v.ArraySchema<v.SchemaWithPipe<readonly [v.StringSchema<undefined>, v.CheckAction<string, "Invalid pseudo-UUID">]>, undefined>, readonly []>;
|
|
41
41
|
readonly queries: v.OptionalSchema<v.NullableSchema<v.GenericSchema<unknown, Query>, undefined>, null>;
|
|
@@ -52,7 +52,7 @@ declare const setPropertyValuesParametersSchema: v.ObjectSchema<{
|
|
|
52
52
|
* Schema for validating the parameters for the item OCR data fetching function
|
|
53
53
|
* @internal
|
|
54
54
|
*/
|
|
55
|
-
declare const itemOcrDataParametersSchema: v.ObjectSchema<{
|
|
55
|
+
export declare const itemOcrDataParametersSchema: v.ObjectSchema<{
|
|
56
56
|
readonly uuid: v.SchemaWithPipe<readonly [v.StringSchema<undefined>, v.CheckAction<string, "Invalid pseudo-UUID">]>;
|
|
57
57
|
readonly value: v.SchemaWithPipe<readonly [v.StringSchema<undefined>, v.CheckAction<string, "A search value is required">]>;
|
|
58
58
|
readonly matchMode: v.OptionalSchema<v.PicklistSchema<["includes", "exact"], undefined>, "includes">;
|
|
@@ -62,7 +62,7 @@ declare const itemOcrDataParametersSchema: v.ObjectSchema<{
|
|
|
62
62
|
* Schema for validating Set items parameters
|
|
63
63
|
* @internal
|
|
64
64
|
*/
|
|
65
|
-
declare const setItemsParametersSchema: v.ObjectSchema<{
|
|
65
|
+
export declare const setItemsParametersSchema: v.ObjectSchema<{
|
|
66
66
|
readonly setScopeUuids: v.SchemaWithPipe<readonly [v.ArraySchema<v.SchemaWithPipe<readonly [v.StringSchema<undefined>, v.CheckAction<string, "Invalid pseudo-UUID">]>, undefined>, v.MinLengthAction<string[], 1, "At least one set scope UUID is required">]>;
|
|
67
67
|
readonly belongsToCollectionScopeUuids: v.OptionalSchema<v.ArraySchema<v.SchemaWithPipe<readonly [v.StringSchema<undefined>, v.CheckAction<string, "Invalid pseudo-UUID">]>, undefined>, readonly []>;
|
|
68
68
|
readonly queries: v.OptionalSchema<v.NullableSchema<v.GenericSchema<unknown, Query>, undefined>, null>;
|
|
@@ -84,5 +84,4 @@ declare const setItemsParametersSchema: v.ObjectSchema<{
|
|
|
84
84
|
readonly page: v.OptionalSchema<v.GenericSchema<unknown, number>, 1>;
|
|
85
85
|
readonly pageSize: v.OptionalSchema<v.GenericSchema<unknown, number>, 48>;
|
|
86
86
|
}, undefined>;
|
|
87
|
-
//#endregion
|
|
88
|
-
export { componentSchema, gallerySchema, iso639_3Schema, itemOcrDataParametersSchema, renderOptionsSchema, setItemsParametersSchema, setPropertyValuesParametersSchema, uuidSchema };
|
|
87
|
+
//#endregion
|