ochre-sdk 1.0.53 → 1.0.54

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.d.mts CHANGED
@@ -3,7 +3,7 @@ import { Query } from "./types/index.mjs";
3
3
  //#region src/query.d.ts
4
4
  declare function buildAndCtsQueryExpression(queryExpressions: Array<string>): string | null;
5
5
  declare function buildBelongsToCollectionQueryExpression(belongsToCollectionScopeUuids: Array<string>, belongsToCollectionPropertyVariableUuid: string): string | null;
6
- declare function buildQueryPlan(params: {
6
+ declare function buildQueryPlan(parameters: {
7
7
  queries: Query | null;
8
8
  }): {
9
9
  prolog: string;
package/dist/query.mjs CHANGED
@@ -1,6 +1,6 @@
1
- import { stringLiteral } from "./utils.mjs";
1
+ import { stringLiteral } from "./utilities.mjs";
2
2
  //#region src/query.ts
3
- const CTS_INCLUDES_STOP_WORDS = new Set([
3
+ const CTS_INCLUDES_STOP_WORDS = /* @__PURE__ */ new Set([
4
4
  "and",
5
5
  "at",
6
6
  "in",
@@ -40,13 +40,13 @@ const CONTENT_TARGET_CONTENT_ELEMENT_PATHS = {
40
40
  "content"
41
41
  ]
42
42
  };
43
- function tokenizeIncludesSearchValue(params) {
44
- const { value, isCaseSensitive } = params;
43
+ function tokenizeIncludesSearchValue(parameters) {
44
+ const { value, isCaseSensitive } = parameters;
45
45
  const rawTerms = (isCaseSensitive ? value : value.toLowerCase()).match(CTS_INCLUDES_TOKEN_REGEX) ?? [];
46
46
  const terms = [];
47
47
  for (const term of rawTerms) {
48
48
  if (term.includes("*") || term.includes("?")) {
49
- if (term.replaceAll("*", "").replaceAll("?", "") !== "") terms.push(term);
49
+ if (term.replaceAll(/[*?]/g, "") !== "") terms.push(term);
50
50
  continue;
51
51
  }
52
52
  const normalizedTerm = term.toLowerCase();
@@ -54,8 +54,8 @@ function tokenizeIncludesSearchValue(params) {
54
54
  }
55
55
  return terms;
56
56
  }
57
- function tokenizeExactTextSearchValue(params) {
58
- const { value, isCaseSensitive } = params;
57
+ function tokenizeExactTextSearchValue(parameters) {
58
+ const { value, isCaseSensitive } = parameters;
59
59
  const rawTerms = (isCaseSensitive ? value : value.toLowerCase()).match(CTS_EXACT_TEXT_TOKEN_REGEX) ?? [];
60
60
  const terms = [];
61
61
  for (const term of rawTerms) if (term !== "") terms.push(term);
@@ -65,14 +65,14 @@ function hasWildcardCharacters(value) {
65
65
  return value.includes("*") || value.includes("?");
66
66
  }
67
67
  function getWildcardStrippedValue(value) {
68
- return value.replaceAll("*", "").replaceAll("?", "");
68
+ return value.replaceAll(/[*?]/g, "");
69
69
  }
70
70
  function shouldUseStemmedTextSearch(value) {
71
71
  const wildcardStrippedValue = getWildcardStrippedValue(value);
72
72
  return wildcardStrippedValue.length >= 3 && CTS_INCLUDES_TOKEN_WORD_REGEX.test(wildcardStrippedValue);
73
73
  }
74
- function shouldUseFullValueFallbackForIncludes(params) {
75
- const { value, isCaseSensitive, terms } = params;
74
+ function shouldUseFullValueFallbackForIncludes(parameters) {
75
+ const { value, isCaseSensitive, terms } = parameters;
76
76
  if (terms.length <= 1) return false;
77
77
  const tokenSource = isCaseSensitive ? value : value.toLowerCase();
78
78
  if (/[^\p{L}\p{N}\s*?]/u.test(tokenSource)) return true;
@@ -87,9 +87,9 @@ function shouldUseFullValueFallbackForIncludes(params) {
87
87
  for (const [index, rawTerm] of rawSpaceTerms.entries()) if (rawTerm !== (terms[index] ?? "")) return true;
88
88
  return false;
89
89
  }
90
- function buildWordQueryOptionsExpression(params) {
91
- const { matchMode, isCaseSensitive, queryFamily, language, isWildcarded } = params;
92
- const { isStemmed } = params;
90
+ function buildWordQueryOptionsExpression(parameters) {
91
+ const { matchMode, isCaseSensitive, queryFamily, language, isWildcarded } = parameters;
92
+ const { isStemmed } = parameters;
93
93
  const options = [
94
94
  isCaseSensitive ? "case-sensitive" : "case-insensitive",
95
95
  matchMode === "exact" ? "diacritic-sensitive" : "diacritic-insensitive",
@@ -103,8 +103,8 @@ function buildWordQueryOptionsExpression(params) {
103
103
  }
104
104
  return `(${options.map((option) => stringLiteral(option)).join(", ")})`;
105
105
  }
106
- function buildRichTextPhraseOptionsExpression(params) {
107
- const { isCaseSensitive } = params;
106
+ function buildRichTextPhraseOptionsExpression(parameters) {
107
+ const { isCaseSensitive } = parameters;
108
108
  return `(${[
109
109
  isCaseSensitive ? "case-sensitive" : "case-insensitive",
110
110
  "diacritic-sensitive",
@@ -114,8 +114,8 @@ function buildRichTextPhraseOptionsExpression(params) {
114
114
  "unwildcarded"
115
115
  ].map((option) => stringLiteral(option)).join(", ")})`;
116
116
  }
117
- function buildCtsWordQueryExpression(params) {
118
- const { value, matchMode, isCaseSensitive, queryFamily, language } = params;
117
+ function buildCtsWordQueryExpression(parameters) {
118
+ const { value, matchMode, isCaseSensitive, queryFamily, language } = parameters;
119
119
  const isWildcarded = matchMode === "includes" && hasWildcardCharacters(value);
120
120
  const isStemmed = matchMode === "includes" && queryFamily === "text" && !isWildcarded && shouldUseStemmedTextSearch(value);
121
121
  return `cts:word-query(${stringLiteral(value)}, ${buildWordQueryOptionsExpression({
@@ -127,12 +127,12 @@ function buildCtsWordQueryExpression(params) {
127
127
  isStemmed
128
128
  })})`;
129
129
  }
130
- function buildRichTextPhraseQueryExpression(params) {
131
- const { value, isCaseSensitive } = params;
130
+ function buildRichTextPhraseQueryExpression(parameters) {
131
+ const { value, isCaseSensitive } = parameters;
132
132
  return `cts:word-query(${stringLiteral(value)}, ${buildRichTextPhraseOptionsExpression({ isCaseSensitive })})`;
133
133
  }
134
- function buildRichTextExactQueryExpression(params) {
135
- const { value, isCaseSensitive } = params;
134
+ function buildRichTextExactQueryExpression(parameters) {
135
+ const { value, isCaseSensitive } = parameters;
136
136
  const phraseQuery = buildRichTextPhraseQueryExpression({
137
137
  value,
138
138
  isCaseSensitive
@@ -147,8 +147,8 @@ function buildRichTextExactQueryExpression(params) {
147
147
  isCaseSensitive
148
148
  })))]);
149
149
  }
150
- function buildCtsElementWordQueryExpression(params) {
151
- const { elementName, value, matchMode, isCaseSensitive, queryFamily, language } = params;
150
+ function buildCtsElementWordQueryExpression(parameters) {
151
+ const { elementName, value, matchMode, isCaseSensitive, queryFamily, language } = parameters;
152
152
  const isWildcarded = matchMode === "includes" && hasWildcardCharacters(value);
153
153
  const isStemmed = matchMode === "includes" && queryFamily === "text" && !isWildcarded && shouldUseStemmedTextSearch(value);
154
154
  return `cts:element-word-query(xs:QName("${elementName}"), ${stringLiteral(value)}, ${buildWordQueryOptionsExpression({
@@ -160,8 +160,8 @@ function buildCtsElementWordQueryExpression(params) {
160
160
  isStemmed
161
161
  })})`;
162
162
  }
163
- function buildCtsElementAttributeWordQueryExpression(params) {
164
- const { elementName, attributeName, value, matchMode, isCaseSensitive, queryFamily, language } = params;
163
+ function buildCtsElementAttributeWordQueryExpression(parameters) {
164
+ const { elementName, attributeName, value, matchMode, isCaseSensitive, queryFamily, language } = parameters;
165
165
  const isWildcarded = matchMode === "includes" && hasWildcardCharacters(value);
166
166
  const isStemmed = matchMode === "includes" && queryFamily === "text" && !isWildcarded && shouldUseStemmedTextSearch(value);
167
167
  return `cts:element-attribute-word-query(xs:QName("${elementName}"), xs:QName("${attributeName}"), ${stringLiteral(value)}, ${buildWordQueryOptionsExpression({
@@ -173,22 +173,22 @@ function buildCtsElementAttributeWordQueryExpression(params) {
173
173
  isStemmed
174
174
  })})`;
175
175
  }
176
- function buildCtsElementValueQueryExpression(params) {
177
- const { elementName, value, isCaseSensitive } = params;
176
+ function buildCtsElementValueQueryExpression(parameters) {
177
+ const { elementName, value, isCaseSensitive } = parameters;
178
178
  return `cts:element-value-query(xs:QName("${elementName}"), ${stringLiteral(value)}, ${buildWordQueryOptionsExpression({
179
179
  matchMode: "exact",
180
180
  isCaseSensitive
181
181
  })})`;
182
182
  }
183
- function buildCtsElementAttributeValueQueryExpression(params) {
184
- const { elementName, attributeName, value, isCaseSensitive } = params;
183
+ function buildCtsElementAttributeValueQueryExpression(parameters) {
184
+ const { elementName, attributeName, value, isCaseSensitive } = parameters;
185
185
  return `cts:element-attribute-value-query(xs:QName("${elementName}"), xs:QName("${attributeName}"), ${stringLiteral(value)}, ${buildWordQueryOptionsExpression({
186
186
  matchMode: "exact",
187
187
  isCaseSensitive
188
188
  })})`;
189
189
  }
190
- function buildPlainElementAttributeValueQueryExpression(params) {
191
- const { elementName, attributeName, value } = params;
190
+ function buildPlainElementAttributeValueQueryExpression(parameters) {
191
+ const { elementName, attributeName, value } = parameters;
192
192
  return `cts:element-attribute-value-query(xs:QName("${elementName}"), xs:QName("${attributeName}"), ${stringLiteral(value)})`;
193
193
  }
194
194
  function buildNestedElementQuery(elementNames, queryExpression) {
@@ -227,15 +227,15 @@ function buildPropertyLabelQuery(propertyVariable) {
227
227
  value: propertyVariable
228
228
  });
229
229
  }
230
- function buildValueNotIdRefQuery() {
230
+ function buildValueNotIdReferenceQuery() {
231
231
  return buildNotCtsQueryExpression(buildPlainElementAttributeValueQueryExpression({
232
232
  elementName: "value",
233
233
  attributeName: "dataType",
234
234
  value: "IDREF"
235
235
  }));
236
236
  }
237
- function buildRichTextContentQueryExpression(params) {
238
- const { value, matchMode, isCaseSensitive, language } = params;
237
+ function buildRichTextContentQueryExpression(parameters) {
238
+ const { value, matchMode, isCaseSensitive, language } = parameters;
239
239
  return buildAndCtsQueryExpressionInternal([buildContentLanguageQuery(language), matchMode === "exact" ? buildRichTextExactQueryExpression({
240
240
  value,
241
241
  isCaseSensitive,
@@ -248,8 +248,8 @@ function buildRichTextContentQueryExpression(params) {
248
248
  language
249
249
  })]);
250
250
  }
251
- function buildValueContentInnerQuery(params) {
252
- const { language, value, matchMode, isCaseSensitive } = params;
251
+ function buildValueContentInnerQuery(parameters) {
252
+ const { language, value, matchMode, isCaseSensitive } = parameters;
253
253
  return buildNestedElementQuery(["content"], buildRichTextContentQueryExpression({
254
254
  language,
255
255
  value,
@@ -257,16 +257,16 @@ function buildValueContentInnerQuery(params) {
257
257
  isCaseSensitive
258
258
  }));
259
259
  }
260
- function buildValueContentExactInnerQuery(params) {
261
- const { language, value, isCaseSensitive } = params;
260
+ function buildValueContentExactInnerQuery(parameters) {
261
+ const { language, value, isCaseSensitive } = parameters;
262
262
  return buildNestedElementQuery(["content"], buildAndCtsQueryExpressionInternal([buildContentLanguageQuery(language), buildCtsElementValueQueryExpression({
263
263
  elementName: "string",
264
264
  value,
265
265
  isCaseSensitive
266
266
  })]));
267
267
  }
268
- function buildValueDirectTextInnerQuery(params) {
269
- const { value, matchMode, isCaseSensitive } = params;
268
+ function buildValueDirectTextInnerQuery(parameters) {
269
+ const { value, matchMode, isCaseSensitive } = parameters;
270
270
  const directTextQuery = matchMode === "exact" ? buildCtsElementValueQueryExpression({
271
271
  elementName: "value",
272
272
  value,
@@ -280,8 +280,8 @@ function buildValueDirectTextInnerQuery(params) {
280
280
  });
281
281
  return buildAndCtsQueryExpressionInternal([buildNotCtsQueryExpression(buildNestedElementQuery(["content"], "cts:true-query()")), directTextQuery]);
282
282
  }
283
- function buildValueRawValueInnerQuery(params) {
284
- const { value, matchMode, isCaseSensitive } = params;
283
+ function buildValueRawValueInnerQuery(parameters) {
284
+ const { value, matchMode, isCaseSensitive } = parameters;
285
285
  if (matchMode === "exact") return buildCtsElementAttributeValueQueryExpression({
286
286
  elementName: "value",
287
287
  attributeName: "rawValue",
@@ -297,8 +297,8 @@ function buildValueRawValueInnerQuery(params) {
297
297
  queryFamily: "raw"
298
298
  });
299
299
  }
300
- function buildNotesQueryExpression(params) {
301
- const { value, matchMode, isCaseSensitive, language } = params;
300
+ function buildNotesQueryExpression(parameters) {
301
+ const { value, matchMode, isCaseSensitive, language } = parameters;
302
302
  return buildNestedElementQuery([
303
303
  "notes",
304
304
  "note",
@@ -310,8 +310,8 @@ function buildNotesQueryExpression(params) {
310
310
  language
311
311
  }));
312
312
  }
313
- function buildContentTargetQueryExpression(params) {
314
- const { target, value, matchMode, isCaseSensitive, language } = params;
313
+ function buildContentTargetQueryExpression(parameters) {
314
+ const { target, value, matchMode, isCaseSensitive, language } = parameters;
315
315
  const contentElementPath = CONTENT_TARGET_CONTENT_ELEMENT_PATHS[target];
316
316
  return buildNestedElementQuery(contentElementPath, buildRichTextContentQueryExpression({
317
317
  value,
@@ -320,8 +320,8 @@ function buildContentTargetQueryExpression(params) {
320
320
  language
321
321
  }));
322
322
  }
323
- function buildPropertyQueryExpression(params) {
324
- const { propertyVariable, propertyRelation, queryExpression } = params;
323
+ function buildPropertyQueryExpression(parameters) {
324
+ const { propertyVariable, propertyRelation, queryExpression } = parameters;
325
325
  const propertyQueryExpressions = [queryExpression];
326
326
  if (propertyVariable != null) propertyQueryExpressions.unshift(buildPropertyLabelQuery(propertyVariable));
327
327
  if (propertyRelation != null) propertyQueryExpressions.unshift(buildPlainElementAttributeValueQueryExpression({
@@ -331,8 +331,8 @@ function buildPropertyQueryExpression(params) {
331
331
  }));
332
332
  return buildNestedElementQuery(["properties", "property"], buildAndCtsQueryExpressionInternal(propertyQueryExpressions));
333
333
  }
334
- function buildPropertyTextMatchQueryExpression(params) {
335
- const { propertyVariable, propertyRelation, valueFilters = [], contentQueryExpression, rawValueQueryExpression, bareValueQueryExpression } = params;
334
+ function buildPropertyTextMatchQueryExpression(parameters) {
335
+ const { propertyVariable, propertyRelation, valueFilters = [], contentQueryExpression, rawValueQueryExpression, bareValueQueryExpression } = parameters;
336
336
  const letBindings = [];
337
337
  const valueMatchReferences = [];
338
338
  if (contentQueryExpression != null) {
@@ -361,15 +361,15 @@ function buildPropertyTextMatchQueryExpression(params) {
361
361
  if (letBindings.length === 0) return propertyQueryExpression;
362
362
  return `(${letBindings.join("\n ")}\n return ${propertyQueryExpression})`;
363
363
  }
364
- function buildPropertyPresenceQueryExpression(params) {
364
+ function buildPropertyPresenceQueryExpression(parameters) {
365
365
  return buildPropertyQueryExpression({
366
- propertyVariable: params.propertyVariable,
367
- propertyRelation: params.propertyRelation,
366
+ propertyVariable: parameters.propertyVariable,
367
+ propertyRelation: parameters.propertyRelation,
368
368
  queryExpression: "cts:true-query()"
369
369
  });
370
370
  }
371
- function buildPropertyStringQueryExpression(params) {
372
- const { propertyVariable, propertyRelation, value, matchMode, isCaseSensitive, language } = params;
371
+ function buildPropertyStringQueryExpression(parameters) {
372
+ const { propertyVariable, propertyRelation, value, matchMode, isCaseSensitive, language } = parameters;
373
373
  return buildPropertyTextMatchQueryExpression({
374
374
  propertyVariable,
375
375
  propertyRelation,
@@ -395,8 +395,8 @@ function buildPropertyStringQueryExpression(params) {
395
395
  })
396
396
  });
397
397
  }
398
- function buildPropertyScalarQueryExpression(params) {
399
- const { propertyVariable, propertyRelation, value, matchMode, isCaseSensitive } = params;
398
+ function buildPropertyScalarQueryExpression(parameters) {
399
+ const { propertyVariable, propertyRelation, value, matchMode, isCaseSensitive } = parameters;
400
400
  return buildPropertyQueryExpression({
401
401
  propertyVariable,
402
402
  propertyRelation,
@@ -411,12 +411,12 @@ function buildPropertyScalarQueryExpression(params) {
411
411
  })]))
412
412
  });
413
413
  }
414
- function buildPropertyAllQueryExpression(params) {
415
- const { query, value, matchMode } = params;
414
+ function buildPropertyAllQueryExpression(parameters) {
415
+ const { query, value, matchMode } = parameters;
416
416
  return buildPropertyTextMatchQueryExpression({
417
417
  propertyVariable: query.propertyVariable,
418
418
  propertyRelation: query.propertyRelation,
419
- valueFilters: [buildValueNotIdRefQuery()],
419
+ valueFilters: [buildValueNotIdReferenceQuery()],
420
420
  contentQueryExpression: buildValueContentInnerQuery({
421
421
  language: query.language,
422
422
  value,
@@ -435,8 +435,8 @@ function buildPropertyAllQueryExpression(params) {
435
435
  })
436
436
  });
437
437
  }
438
- function buildPropertyIdRefQueryExpression(params) {
439
- const { propertyVariable, propertyRelation, value } = params;
438
+ function buildPropertyIdReferenceQueryExpression(parameters) {
439
+ const { propertyVariable, propertyRelation, value } = parameters;
440
440
  return buildPropertyQueryExpression({
441
441
  propertyVariable,
442
442
  propertyRelation,
@@ -457,8 +457,8 @@ function buildPropertyDateRangeQueryExpression(query) {
457
457
  queryExpression: buildNestedElementQuery(["value"], buildAndCtsQueryExpressionInternal(rangeQueryExpressions))
458
458
  });
459
459
  }
460
- function buildItemStringQueryExpression(params) {
461
- const { value, matchMode, isCaseSensitive, language } = params;
460
+ function buildItemStringQueryExpression(parameters) {
461
+ const { value, matchMode, isCaseSensitive, language } = parameters;
462
462
  return buildOrCtsQueryExpressionInternal([buildContentTargetQueryExpression({
463
463
  target: "title",
464
464
  value,
@@ -484,8 +484,8 @@ function getLeafSearchValue(query) {
484
484
  case "property": return "value" in query && query.value != null ? query.value : null;
485
485
  }
486
486
  }
487
- function buildLeafValueQueryExpression(params) {
488
- const { query, value, matchMode } = params;
487
+ function buildLeafValueQueryExpression(parameters) {
488
+ const { query, value, matchMode } = parameters;
489
489
  switch (query.target) {
490
490
  case "string": return buildItemStringQueryExpression({
491
491
  value,
@@ -516,7 +516,7 @@ function buildLeafValueQueryExpression(params) {
516
516
  value,
517
517
  matchMode
518
518
  });
519
- case "IDREF": return buildPropertyIdRefQueryExpression({
519
+ case "IDREF": return buildPropertyIdReferenceQueryExpression({
520
520
  propertyVariable: query.propertyVariable,
521
521
  propertyRelation: query.propertyRelation,
522
522
  value
@@ -555,8 +555,8 @@ function createQueryCompilerContext() {
555
555
  helperDeclarations: []
556
556
  };
557
557
  }
558
- function registerConstantHelper(params) {
559
- const { context, key, bodyExpression } = params;
558
+ function registerConstantHelper(parameters) {
559
+ const { context, key, bodyExpression } = parameters;
560
560
  const existingName = context.helperNamesByKey.get(key);
561
561
  if (existingName != null) return {
562
562
  name: existingName,
@@ -572,10 +572,10 @@ function registerConstantHelper(params) {
572
572
  };
573
573
  }
574
574
  function replaceSampleValueLiteral(expression, sampleValue, valueReference) {
575
- return expression.replaceAll(stringLiteral(sampleValue), valueReference);
575
+ return expression.replaceAll(stringLiteral(sampleValue), () => valueReference);
576
576
  }
577
- function registerParameterizedHelper(params) {
578
- const { context, key, bodyExpression } = params;
577
+ function registerParameterizedHelper(parameters) {
578
+ const { context, key, bodyExpression } = parameters;
579
579
  const existingName = context.helperNamesByKey.get(key);
580
580
  if (existingName != null) return {
581
581
  name: existingName,
@@ -590,8 +590,8 @@ function registerParameterizedHelper(params) {
590
590
  call: (valueExpression) => `${helperName}(${valueExpression})`
591
591
  };
592
592
  }
593
- function getLeafHelperKey(params) {
594
- const { query, matchMode, value } = params;
593
+ function getLeafHelperKey(parameters) {
594
+ const { query, matchMode, value } = parameters;
595
595
  switch (query.target) {
596
596
  case "string":
597
597
  case "title":
@@ -620,8 +620,8 @@ function getLeafHelperKey(params) {
620
620
  ].join("|");
621
621
  }
622
622
  }
623
- function registerLeafHelper(params) {
624
- const { context, query, matchMode, value } = params;
623
+ function registerLeafHelper(parameters) {
624
+ const { context, query, matchMode, value } = parameters;
625
625
  return registerConstantHelper({
626
626
  context,
627
627
  key: getLeafHelperKey({
@@ -636,8 +636,8 @@ function registerLeafHelper(params) {
636
636
  })
637
637
  });
638
638
  }
639
- function getIncludesLeafHelperKey(params) {
640
- const { query, value } = params;
639
+ function getIncludesLeafHelperKey(parameters) {
640
+ const { query, value } = parameters;
641
641
  const isWildcarded = hasWildcardCharacters(value);
642
642
  const isStemmed = !isWildcarded && shouldUseStemmedTextSearch(value);
643
643
  switch (query.target) {
@@ -668,8 +668,8 @@ function getIncludesLeafHelperKey(params) {
668
668
  ].join("|");
669
669
  }
670
670
  }
671
- function registerIncludesLeafHelper(params) {
672
- const { context, query, sampleValue } = params;
671
+ function registerIncludesLeafHelper(parameters) {
672
+ const { context, query, sampleValue } = parameters;
673
673
  return registerParameterizedHelper({
674
674
  context,
675
675
  key: getIncludesLeafHelperKey({
@@ -821,25 +821,22 @@ function buildQueryNode(context, query) {
821
821
  }
822
822
  const optimizedIncludesGroupQueries = getCompatibleIncludesGroupLeaves(query);
823
823
  if (optimizedIncludesGroupQueries != null) return buildIncludesGroupQueryExpression(context, optimizedIncludesGroupQueries);
824
- const childQueryExpressions = [];
825
- for (const childQuery of getQueryGroupChildren(query)) childQueryExpressions.push(buildQueryNode(context, childQuery));
826
- return getQueryGroupOperator(query) === "and" ? buildAndCtsQueryExpressionInternal(childQueryExpressions) : buildOrCtsQueryExpressionInternal(childQueryExpressions);
824
+ const childQueryExpressions = Array.from(getQueryGroupChildren(query), (childQuery) => buildQueryNode(context, childQuery));
825
+ return (getQueryGroupOperator(query) === "and" ? buildAndCtsQueryExpressionInternal : buildOrCtsQueryExpressionInternal)(childQueryExpressions);
827
826
  }
828
827
  function buildBelongsToCollectionQueryExpression(belongsToCollectionScopeUuids, belongsToCollectionPropertyVariableUuid) {
829
828
  if (belongsToCollectionScopeUuids.length === 0) return null;
830
- const collectionValueQueryExpressions = [];
831
- for (const uuid of belongsToCollectionScopeUuids) collectionValueQueryExpressions.push(buildPlainElementAttributeValueQueryExpression({
832
- elementName: "value",
833
- attributeName: "uuid",
834
- value: uuid
835
- }));
836
829
  return buildPropertyQueryExpression({
837
830
  propertyVariable: belongsToCollectionPropertyVariableUuid,
838
- queryExpression: buildNestedElementQuery(["value"], buildOrCtsQueryExpressionInternal(collectionValueQueryExpressions))
831
+ queryExpression: buildNestedElementQuery(["value"], buildOrCtsQueryExpressionInternal(Array.from(belongsToCollectionScopeUuids, (uuid) => buildPlainElementAttributeValueQueryExpression({
832
+ elementName: "value",
833
+ attributeName: "uuid",
834
+ value: uuid
835
+ }))))
839
836
  });
840
837
  }
841
- function buildQueryPlan(params) {
842
- const { queries } = params;
838
+ function buildQueryPlan(parameters) {
839
+ const { queries } = parameters;
843
840
  if (queries == null) return {
844
841
  prolog: "",
845
842
  queryExpression: null
@@ -36,7 +36,7 @@ declare const renderOptionsSchema: v.SchemaWithPipe<readonly [v.StringSchema<und
36
36
  * Schema for validating the parameters for the Set property values fetching function
37
37
  * @internal
38
38
  */
39
- declare const setPropertyValuesParamsSchema: v.ObjectSchema<{
39
+ declare const setPropertyValuesParametersSchema: v.ObjectSchema<{
40
40
  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">]>;
41
41
  readonly belongsToCollectionScopeUuids: v.OptionalSchema<v.ArraySchema<v.SchemaWithPipe<readonly [v.StringSchema<undefined>, v.CheckAction<string, "Invalid pseudo-UUID">]>, undefined>, readonly []>;
42
42
  readonly queries: v.OptionalSchema<v.NullableSchema<v.GenericSchema<unknown, Query>, undefined>, null>;
@@ -53,7 +53,7 @@ declare const setPropertyValuesParamsSchema: v.ObjectSchema<{
53
53
  * Schema for validating Set items parameters
54
54
  * @internal
55
55
  */
56
- declare const setItemsParamsSchema: v.ObjectSchema<{
56
+ declare const setItemsParametersSchema: v.ObjectSchema<{
57
57
  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">]>;
58
58
  readonly belongsToCollectionScopeUuids: v.OptionalSchema<v.ArraySchema<v.SchemaWithPipe<readonly [v.StringSchema<undefined>, v.CheckAction<string, "Invalid pseudo-UUID">]>, undefined>, readonly []>;
59
59
  readonly queries: v.OptionalSchema<v.NullableSchema<v.GenericSchema<unknown, Query>, undefined>, null>;
@@ -76,4 +76,4 @@ declare const setItemsParamsSchema: v.ObjectSchema<{
76
76
  readonly pageSize: v.OptionalSchema<v.GenericSchema<unknown, number>, 48>;
77
77
  }, undefined>;
78
78
  //#endregion
79
- export { componentSchema, gallerySchema, iso639_3Schema, renderOptionsSchema, setItemsParamsSchema, setPropertyValuesParamsSchema, uuidSchema };
79
+ export { componentSchema, gallerySchema, iso639_3Schema, renderOptionsSchema, setItemsParametersSchema, setPropertyValuesParametersSchema, uuidSchema };
package/dist/schemas.mjs CHANGED
@@ -1,4 +1,4 @@
1
- import { isPseudoUuid } from "./utils.mjs";
1
+ import { isPseudoUuid } from "./utilities.mjs";
2
2
  import "./helpers.mjs";
3
3
  import * as v from "valibot";
4
4
  //#region src/schemas.ts
@@ -57,7 +57,7 @@ const gallerySchema = v.object({
57
57
  * Schema for validating and parsing render options
58
58
  * @internal
59
59
  */
60
- const renderOptionsSchema = v.pipe(v.string(), v.transform((str) => str.split(" ")), v.array(v.picklist([
60
+ const renderOptionsSchema = v.pipe(v.string(), v.transform((string) => string.split(" ")), v.array(v.picklist([
61
61
  "bold",
62
62
  "italic",
63
63
  "underline"
@@ -200,7 +200,7 @@ const setItemsSortSchema = v.optional(v.variant("target", [
200
200
  * Schema for validating the parameters for the Set property values fetching function
201
201
  * @internal
202
202
  */
203
- const setPropertyValuesParamsSchema = v.object({
203
+ const setPropertyValuesParametersSchema = v.object({
204
204
  setScopeUuids: v.pipe(v.array(uuidSchema), v.minLength(1, "At least one set scope UUID is required")),
205
205
  belongsToCollectionScopeUuids: v.optional(v.array(uuidSchema), []),
206
206
  queries: setQueriesSchema,
@@ -217,7 +217,7 @@ const setPropertyValuesParamsSchema = v.object({
217
217
  * Schema for validating Set items parameters
218
218
  * @internal
219
219
  */
220
- const setItemsParamsSchema = v.object({
220
+ const setItemsParametersSchema = v.object({
221
221
  setScopeUuids: v.pipe(v.array(uuidSchema), v.minLength(1, "At least one set scope UUID is required")),
222
222
  belongsToCollectionScopeUuids: v.optional(v.array(uuidSchema), []),
223
223
  queries: setQueriesSchema,
@@ -226,4 +226,4 @@ const setItemsParamsSchema = v.object({
226
226
  pageSize: v.optional(positiveNumber("Page size must be positive"), 48)
227
227
  });
228
228
  //#endregion
229
- export { componentSchema, gallerySchema, iso639_3Schema, renderOptionsSchema, setItemsParamsSchema, setPropertyValuesParamsSchema, uuidSchema };
229
+ export { componentSchema, gallerySchema, iso639_3Schema, renderOptionsSchema, setItemsParametersSchema, setPropertyValuesParametersSchema, uuidSchema };
@@ -492,6 +492,7 @@ type Tree<U extends TreeItemCategory = TreeItemCategory, T extends LanguageCodes
492
492
  type: string | null;
493
493
  containedItemCategory: U | null;
494
494
  links: ItemLinks<T>;
495
+ reverseLinks: ItemLinks<T>;
495
496
  notes: Array<Note<T>>;
496
497
  properties: Array<Property<T>>;
497
498
  bibliographies: Array<Bibliography<T, "embedded">>;
@@ -505,6 +506,7 @@ type Set<U extends SetItemCategory = SetItemCategory, T extends LanguageCodes =
505
506
  isTabularStructure: boolean;
506
507
  isSuppressingBlanks: boolean;
507
508
  links: ItemLinks<T>;
509
+ reverseLinks: ItemLinks<T>;
508
510
  notes: Array<Note<T>>;
509
511
  properties: Array<Property<T>>;
510
512
  items: Array<SetItem<U, T>>;
@@ -514,10 +516,10 @@ type SetBibliography<T extends LanguageCodes = LanguageCodes> = Bibliography<T,
514
516
  } ? Prettify<Omit<U, "properties" | "items"> & {
515
517
  properties: Array<SetItemProperty<T>>;
516
518
  }> : never : never;
517
- type SetConcept<T extends LanguageCodes = LanguageCodes> = Prettify<Omit<Concept<T, "embedded">, "interpretations" | "items"> & {
519
+ type SetConcept<T extends LanguageCodes = LanguageCodes> = Prettify<Omit<Concept<T, "embedded">, "items"> & {
518
520
  properties: Array<SetItemProperty<T>>;
519
521
  }>;
520
- type SetSpatialUnit<T extends LanguageCodes = LanguageCodes> = Prettify<Omit<SpatialUnit<T, "embedded">, "observations" | "items"> & {
522
+ type SetSpatialUnit<T extends LanguageCodes = LanguageCodes> = Prettify<Omit<SpatialUnit<T, "embedded">, "items"> & {
521
523
  properties: Array<SetItemProperty<T>>;
522
524
  }>;
523
525
  type SetPeriod<T extends LanguageCodes = LanguageCodes> = Prettify<Omit<WithSetItemProperties<Period<T, "embedded">, T>, "items">>;
@@ -540,6 +542,7 @@ type Person<T extends LanguageCodes = LanguageCodes, U extends ItemPayloadKind =
540
542
  content: MultilingualString<T> | null;
541
543
  periods: Array<Period<T, "embedded">>;
542
544
  links: ItemLinks<T>;
545
+ reverseLinks: ItemLinks<T>;
543
546
  notes: Array<Note<T>>;
544
547
  properties: Array<Property<T>>;
545
548
  bibliographies: Array<Bibliography<T, "embedded">>;
@@ -551,6 +554,7 @@ type Period<T extends LanguageCodes = LanguageCodes, U extends ItemPayloadKind =
551
554
  type: string | null;
552
555
  coordinates: Array<Coordinates<T>>;
553
556
  links: ItemLinks<T>;
557
+ reverseLinks: ItemLinks<T>;
554
558
  notes: Array<Note<T>>;
555
559
  properties: Array<Property<T>>;
556
560
  bibliographies: Array<Bibliography<T, "embedded">>;
@@ -575,6 +579,7 @@ type Bibliography<T extends LanguageCodes = LanguageCodes, U extends ItemPayload
575
579
  authors: Array<Person<T, "embedded">>;
576
580
  periods: Array<Period<T, "embedded">>;
577
581
  links: ItemLinks<T>;
582
+ reverseLinks: ItemLinks<T>;
578
583
  notes: Array<Note<T>>;
579
584
  properties: Array<Property<T>>;
580
585
  bibliographies: Array<Bibliography<T, "embedded">>;
@@ -601,9 +606,10 @@ type Concept<T extends LanguageCodes = LanguageCodes, U extends ItemPayloadKind
601
606
  type Interpretation<T extends LanguageCodes = LanguageCodes> = {
602
607
  number: number;
603
608
  date: Date | null;
604
- observers: Array<Person<T, "embedded">>;
609
+ interpreters: Array<Person<T, "embedded">>;
605
610
  periods: Array<Period<T, "embedded">>;
606
611
  links: ItemLinks<T>;
612
+ reverseLinks: ItemLinks<T>;
607
613
  notes: Array<Note<T>>;
608
614
  properties: Array<Property<T>>;
609
615
  bibliographies: Array<Bibliography<T, "embedded">>;
@@ -633,6 +639,7 @@ type Observation<T extends LanguageCodes = LanguageCodes> = {
633
639
  observers: Array<string> | Array<Person<T, "embedded">>;
634
640
  periods: Array<Period<T, "embedded">>;
635
641
  links: ItemLinks<T>;
642
+ reverseLinks: ItemLinks<T>;
636
643
  notes: Array<Note<T>>;
637
644
  properties: Array<Property<T>>;
638
645
  bibliographies: Array<Bibliography<T, "embedded">>;
@@ -644,6 +651,7 @@ type PropertyVariable<T extends LanguageCodes = LanguageCodes, U extends ItemPay
644
651
  type: string | null;
645
652
  coordinates: Array<Coordinates<T>>;
646
653
  links: ItemLinks<T>;
654
+ reverseLinks: ItemLinks<T>;
647
655
  notes: Array<Note<T>>;
648
656
  bibliographies: Array<Bibliography<T, "embedded">>;
649
657
  }>;
@@ -653,6 +661,7 @@ type PropertyVariable<T extends LanguageCodes = LanguageCodes, U extends ItemPay
653
661
  type PropertyValue<T extends LanguageCodes = LanguageCodes, U extends ItemPayloadKind = "topLevel"> = Prettify<BaseItem<"propertyValue", T, U> & {
654
662
  coordinates: Array<Coordinates<T>>;
655
663
  links: ItemLinks<T>;
664
+ reverseLinks: ItemLinks<T>;
656
665
  notes: Array<Note<T>>;
657
666
  properties: Array<Property<T>>;
658
667
  bibliographies: Array<Bibliography<T, "embedded">>;
@@ -202,6 +202,10 @@ type Webpage<T extends LanguageCodes = LanguageCodes> = {
202
202
  isSidebarDisplayed: boolean;
203
203
  isDisplayedInNavbar: boolean;
204
204
  isNavbarSearchBarDisplayed: boolean;
205
+ redirect: {
206
+ href: string;
207
+ isExternal: boolean;
208
+ } | null;
205
209
  backgroundImage: WebImage<T> | null;
206
210
  sidebar: WebSidebar<T> | null;
207
211
  cssStyles: {
@@ -1,10 +1,8 @@
1
1
  import { LanguageCodes, Property, SetItemProperty } from "./types/index.mjs";
2
2
  import * as v from "valibot";
3
3
 
4
- //#region src/utils.d.ts
4
+ //#region src/utilities.d.ts
5
5
  type SchemaValidationIssue = v.BaseIssue<unknown>;
6
- declare function getErrorMessage(error: unknown, fallbackMessage: string): string;
7
- declare function getDetailedError(error: unknown, fallbackMessage?: string): string;
8
6
  declare function getErrorOutput(error: unknown, fallbackMessage: string): {
9
7
  error: string;
10
8
  detailedError: string;
@@ -31,4 +29,4 @@ declare function stringLiteral(value: string): string;
31
29
  */
32
30
  declare function flattenProperties<T extends LanguageCodes = LanguageCodes>(properties: ReadonlyArray<Property<T> | SetItemProperty<T>>): Array<SetItemProperty<T>>;
33
31
  //#endregion
34
- export { createSchemaValidationError, flattenProperties, getDetailedError, getErrorMessage, getErrorOutput, isPseudoUuid, stringLiteral };
32
+ export { createSchemaValidationError, flattenProperties, getErrorOutput, isPseudoUuid, stringLiteral };