ochre-sdk 1.3.19 → 1.3.20
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/query.mjs +41 -23
- package/dist/types/index.d.mts +5 -0
- package/package.json +1 -1
package/dist/query.mjs
CHANGED
|
@@ -232,12 +232,12 @@ function buildPropertyLabelQuery(propertyVariable) {
|
|
|
232
232
|
value: searchValue(propertyVariable)
|
|
233
233
|
});
|
|
234
234
|
}
|
|
235
|
-
function
|
|
236
|
-
return
|
|
235
|
+
function buildValueIdReferenceQuery() {
|
|
236
|
+
return buildPlainElementAttributeValueQueryExpression({
|
|
237
237
|
elementName: "value",
|
|
238
238
|
attributeName: "dataType",
|
|
239
|
-
value: searchValue("IDREF")
|
|
240
|
-
})
|
|
239
|
+
value: searchValue("xs:IDREF")
|
|
240
|
+
});
|
|
241
241
|
}
|
|
242
242
|
/**
|
|
243
243
|
* Match a field's `content` in a language, falling back to another language
|
|
@@ -435,7 +435,6 @@ function buildPropertyAllQueryExpression(parameters) {
|
|
|
435
435
|
return buildPropertyTextMatchQueryExpression({
|
|
436
436
|
propertyVariable: query.propertyVariable,
|
|
437
437
|
propertyRelation: query.propertyRelation,
|
|
438
|
-
valueFilters: [buildValueNotIdReferenceQuery()],
|
|
439
438
|
contentQueryExpression: buildRichTextContentQueryExpression({
|
|
440
439
|
language: query.language,
|
|
441
440
|
fallbackLanguage: query.fallbackLanguage,
|
|
@@ -467,6 +466,26 @@ function buildPropertyIdReferenceQueryExpression(parameters) {
|
|
|
467
466
|
}))
|
|
468
467
|
});
|
|
469
468
|
}
|
|
469
|
+
function buildPropertyIdReferenceTextQueryExpression(parameters) {
|
|
470
|
+
const { propertyVariable, propertyRelation, value, matchMode, isCaseSensitive, language, fallbackLanguage } = parameters;
|
|
471
|
+
return buildPropertyTextMatchQueryExpression({
|
|
472
|
+
propertyVariable,
|
|
473
|
+
propertyRelation,
|
|
474
|
+
valueFilters: [buildValueIdReferenceQuery()],
|
|
475
|
+
contentQueryExpression: matchMode === "exact" ? buildValueContentExactInnerQuery({
|
|
476
|
+
language,
|
|
477
|
+
fallbackLanguage,
|
|
478
|
+
value,
|
|
479
|
+
isCaseSensitive
|
|
480
|
+
}) : buildRichTextContentQueryExpression({
|
|
481
|
+
language,
|
|
482
|
+
fallbackLanguage,
|
|
483
|
+
value,
|
|
484
|
+
matchMode,
|
|
485
|
+
isCaseSensitive
|
|
486
|
+
})
|
|
487
|
+
});
|
|
488
|
+
}
|
|
470
489
|
function buildPropertyDateRangeQueryExpression(query) {
|
|
471
490
|
const rangeQueryExpressions = [];
|
|
472
491
|
if (query.from != null) rangeQueryExpressions.push(`cts:element-attribute-range-query(xs:QName("value"), xs:QName("rawValue"), ">=", ${stringLiteral(query.from)})`);
|
|
@@ -652,11 +671,21 @@ function buildLeafValueQueryExpression(parameters) {
|
|
|
652
671
|
value,
|
|
653
672
|
matchMode
|
|
654
673
|
});
|
|
655
|
-
case "IDREF":
|
|
656
|
-
|
|
657
|
-
|
|
658
|
-
|
|
659
|
-
|
|
674
|
+
case "IDREF":
|
|
675
|
+
if (query.matchMode === "exact") return buildPropertyIdReferenceQueryExpression({
|
|
676
|
+
propertyVariable: query.propertyVariable,
|
|
677
|
+
propertyRelation: query.propertyRelation,
|
|
678
|
+
value
|
|
679
|
+
});
|
|
680
|
+
return buildPropertyIdReferenceTextQueryExpression({
|
|
681
|
+
propertyVariable: query.propertyVariable,
|
|
682
|
+
propertyRelation: query.propertyRelation,
|
|
683
|
+
value,
|
|
684
|
+
matchMode,
|
|
685
|
+
isCaseSensitive: query.isCaseSensitive,
|
|
686
|
+
language: query.language,
|
|
687
|
+
fallbackLanguage: query.fallbackLanguage
|
|
688
|
+
});
|
|
660
689
|
case "string": return buildPropertyStringQueryExpression({
|
|
661
690
|
propertyVariable: query.propertyVariable,
|
|
662
691
|
propertyRelation: query.propertyRelation,
|
|
@@ -749,7 +778,7 @@ function getLeafHelperKey(parameters) {
|
|
|
749
778
|
"leaf",
|
|
750
779
|
matchMode,
|
|
751
780
|
query.target,
|
|
752
|
-
query.dataType,
|
|
781
|
+
query.dataType === "IDREF" && query.matchMode !== "exact" ? "IDREF-text" : query.dataType,
|
|
753
782
|
query.propertyVariable ?? "",
|
|
754
783
|
query.propertyRelation ?? "",
|
|
755
784
|
value,
|
|
@@ -868,18 +897,7 @@ function buildLeafQueryExpression(context, query) {
|
|
|
868
897
|
}
|
|
869
898
|
function getGroupableIncludesValue(query) {
|
|
870
899
|
if (query.matchMode !== "includes" || query.isNegated === true) return null;
|
|
871
|
-
|
|
872
|
-
case "string":
|
|
873
|
-
case "title":
|
|
874
|
-
case "description":
|
|
875
|
-
case "image":
|
|
876
|
-
case "periods":
|
|
877
|
-
case "bibliography":
|
|
878
|
-
case "notes": return query.value;
|
|
879
|
-
case "property":
|
|
880
|
-
if (!("value" in query) || query.value == null || query.dataType === "IDREF") return null;
|
|
881
|
-
return query.value;
|
|
882
|
-
}
|
|
900
|
+
return getLeafSearchValue(query);
|
|
883
901
|
}
|
|
884
902
|
function isQueryLeaf(query) {
|
|
885
903
|
return "target" in query;
|
package/dist/types/index.d.mts
CHANGED
|
@@ -893,6 +893,11 @@ export type SetItemsSort = {
|
|
|
893
893
|
* own word and `exact` matches the terms as an adjacent run of whole words. OCR
|
|
894
894
|
* text carries no language, so `ocr` leaves take no `language`.
|
|
895
895
|
*
|
|
896
|
+
* An `IDREF` property leaf matches by identity under `exact`, where `value` is
|
|
897
|
+
* the UUID of the linked item, and by the linked item's displayed name under
|
|
898
|
+
* `includes`, which OCHRE copies into the value's `content`. The `all` data
|
|
899
|
+
* type searches the text of every value, linked names included.
|
|
900
|
+
*
|
|
896
901
|
* `fallbackLanguage` searches a field in that language only when the field has
|
|
897
902
|
* no content in `language`, so a match follows the text a reader of `language`
|
|
898
903
|
* is shown. Leave it unset to search `language` alone.
|