ochre-sdk 0.21.7 → 0.21.8
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/index.d.mts +1 -1
- package/dist/index.mjs +83 -1
- package/package.json +1 -1
package/dist/index.d.mts
CHANGED
|
@@ -734,7 +734,7 @@ type QueryLeaf = {
|
|
|
734
734
|
language: string;
|
|
735
735
|
isNegated?: boolean;
|
|
736
736
|
} | {
|
|
737
|
-
target: "title" | "description" | "image" | "periods" | "bibliography";
|
|
737
|
+
target: "title" | "description" | "image" | "periods" | "bibliography" | "notes";
|
|
738
738
|
value: string;
|
|
739
739
|
matchMode: "includes" | "exact";
|
|
740
740
|
isCaseSensitive: boolean;
|
package/dist/index.mjs
CHANGED
|
@@ -839,7 +839,8 @@ const setQueryLeafSchema = z.union([
|
|
|
839
839
|
"description",
|
|
840
840
|
"image",
|
|
841
841
|
"periods",
|
|
842
|
-
"bibliography"
|
|
842
|
+
"bibliography",
|
|
843
|
+
"notes"
|
|
843
844
|
]),
|
|
844
845
|
value: z.string(),
|
|
845
846
|
matchMode: z.enum(["includes", "exact"]),
|
|
@@ -2196,6 +2197,23 @@ function buildCombinedSearchableContentNodesExpression(contentNodesExpressions)
|
|
|
2196
2197
|
if (searchableExpressions.length === 1) return searchableExpressions[0] ?? "()";
|
|
2197
2198
|
return `(${searchableExpressions.join(", ")})`;
|
|
2198
2199
|
}
|
|
2200
|
+
function buildAttributeValuesExpression(params) {
|
|
2201
|
+
const { nodeExpression, attributeName } = params;
|
|
2202
|
+
return `for $node in ${nodeExpression}[@${attributeName}]
|
|
2203
|
+
return string($node/@${attributeName})`;
|
|
2204
|
+
}
|
|
2205
|
+
function buildNotesContentNodesExpression(language) {
|
|
2206
|
+
return `notes/note/content[@xml:lang="${language}"]`;
|
|
2207
|
+
}
|
|
2208
|
+
function buildNotesTitleValuesExpression(language) {
|
|
2209
|
+
return buildAttributeValuesExpression({
|
|
2210
|
+
nodeExpression: buildNotesContentNodesExpression(language),
|
|
2211
|
+
attributeName: "title"
|
|
2212
|
+
});
|
|
2213
|
+
}
|
|
2214
|
+
function buildNotesValueExpressions(language) {
|
|
2215
|
+
return [buildFlattenedContentValuesExpression(buildNotesContentNodesExpression(language)), buildNotesTitleValuesExpression(language)];
|
|
2216
|
+
}
|
|
2199
2217
|
function buildPropertyValueNodesExpression(params) {
|
|
2200
2218
|
const predicates = [];
|
|
2201
2219
|
if (params?.excludeInherited) predicates.push(`not(@inherited="true")`);
|
|
@@ -2577,12 +2595,37 @@ function buildPropertyScalarCandidateBranch(params) {
|
|
|
2577
2595
|
)
|
|
2578
2596
|
)`;
|
|
2579
2597
|
}
|
|
2598
|
+
function buildNotesCandidateBranch(params) {
|
|
2599
|
+
const { termExpression, isCaseSensitive, language } = params;
|
|
2600
|
+
return `cts:element-query(xs:QName("notes"),
|
|
2601
|
+
cts:element-query(xs:QName("note"),
|
|
2602
|
+
cts:element-query(xs:QName("content"),
|
|
2603
|
+
cts:and-query((
|
|
2604
|
+
cts:element-attribute-value-query(xs:QName("content"), xs:QName("xml:lang"), ${stringLiteral(language)}),
|
|
2605
|
+
cts:or-query((
|
|
2606
|
+
${buildCtsElementAttributeWordQueryExpression({
|
|
2607
|
+
elementName: "content",
|
|
2608
|
+
attributeName: "title",
|
|
2609
|
+
termExpression,
|
|
2610
|
+
isCaseSensitive
|
|
2611
|
+
})},
|
|
2612
|
+
${buildCtsWordQueryExpression({
|
|
2613
|
+
termExpression,
|
|
2614
|
+
isCaseSensitive
|
|
2615
|
+
})}
|
|
2616
|
+
))
|
|
2617
|
+
))
|
|
2618
|
+
)
|
|
2619
|
+
)
|
|
2620
|
+
)`;
|
|
2621
|
+
}
|
|
2580
2622
|
function getGroupableIncludesValue(query) {
|
|
2581
2623
|
switch (query.target) {
|
|
2582
2624
|
case "string":
|
|
2583
2625
|
case "title":
|
|
2584
2626
|
case "description":
|
|
2585
2627
|
case "image":
|
|
2628
|
+
case "notes":
|
|
2586
2629
|
case "periods":
|
|
2587
2630
|
case "bibliography": return query.value;
|
|
2588
2631
|
case "property":
|
|
@@ -2657,6 +2700,21 @@ function buildPropertyStringIncludesGroupMember(query) {
|
|
|
2657
2700
|
})
|
|
2658
2701
|
};
|
|
2659
2702
|
}
|
|
2703
|
+
function buildNotesIncludesGroupMember(query) {
|
|
2704
|
+
return {
|
|
2705
|
+
rawPredicate: buildCombinedRawStringMatchPredicate({
|
|
2706
|
+
valueExpressions: buildNotesValueExpressions(query.language),
|
|
2707
|
+
value: query.value,
|
|
2708
|
+
matchMode: "includes",
|
|
2709
|
+
isCaseSensitive: query.isCaseSensitive
|
|
2710
|
+
}),
|
|
2711
|
+
buildCandidateTermQuery: (termExpression) => buildNotesCandidateBranch({
|
|
2712
|
+
termExpression,
|
|
2713
|
+
isCaseSensitive: query.isCaseSensitive,
|
|
2714
|
+
language: query.language
|
|
2715
|
+
})
|
|
2716
|
+
};
|
|
2717
|
+
}
|
|
2660
2718
|
function buildIncludesGroupMember(query) {
|
|
2661
2719
|
switch (query.target) {
|
|
2662
2720
|
case "string": return buildItemStringIncludesGroupMember(query);
|
|
@@ -2695,6 +2753,7 @@ function buildIncludesGroupMember(query) {
|
|
|
2695
2753
|
language: query.language,
|
|
2696
2754
|
containerElementName: "image"
|
|
2697
2755
|
});
|
|
2756
|
+
case "notes": return buildNotesIncludesGroupMember(query);
|
|
2698
2757
|
case "property":
|
|
2699
2758
|
if (query.dataType === "all") throw new Error(`Property queries with dataType "all" are not compatible with includes-group optimization`);
|
|
2700
2759
|
return buildPropertyStringIncludesGroupMember(query);
|
|
@@ -2876,6 +2935,23 @@ function buildPropertyAllValueClause(query) {
|
|
|
2876
2935
|
candidateQueryVar: null
|
|
2877
2936
|
};
|
|
2878
2937
|
}
|
|
2938
|
+
function buildNotesValueClause(params) {
|
|
2939
|
+
const { query, version, queryKey, allowCtsPredicates } = params;
|
|
2940
|
+
return buildCombinedRawStringMatchClause({
|
|
2941
|
+
valueExpressions: buildNotesValueExpressions(query.language),
|
|
2942
|
+
value: query.value,
|
|
2943
|
+
matchMode: query.matchMode,
|
|
2944
|
+
isCaseSensitive: query.isCaseSensitive,
|
|
2945
|
+
version,
|
|
2946
|
+
queryKey,
|
|
2947
|
+
allowCtsPredicates,
|
|
2948
|
+
buildCandidateTermQuery: (termExpression) => buildNotesCandidateBranch({
|
|
2949
|
+
termExpression,
|
|
2950
|
+
isCaseSensitive: query.isCaseSensitive,
|
|
2951
|
+
language: query.language
|
|
2952
|
+
})
|
|
2953
|
+
});
|
|
2954
|
+
}
|
|
2879
2955
|
/**
|
|
2880
2956
|
* Build a property predicate for an XQuery string.
|
|
2881
2957
|
*/
|
|
@@ -3037,6 +3113,12 @@ function buildQueryClause(params) {
|
|
|
3037
3113
|
language: query.language
|
|
3038
3114
|
})
|
|
3039
3115
|
});
|
|
3116
|
+
case "notes": return buildNotesValueClause({
|
|
3117
|
+
query,
|
|
3118
|
+
version,
|
|
3119
|
+
queryKey,
|
|
3120
|
+
allowCtsPredicates
|
|
3121
|
+
});
|
|
3040
3122
|
case "property": return buildPropertyClause({
|
|
3041
3123
|
query,
|
|
3042
3124
|
version,
|