ochre-sdk 1.3.25 → 1.3.26

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.
Files changed (97) hide show
  1. package/dist/categories.d.mts +56 -56
  2. package/dist/categories.mjs +39 -39
  3. package/dist/constants.d.mts +8 -8
  4. package/dist/constants.mjs +6 -6
  5. package/dist/errors.d.mts +12 -12
  6. package/dist/errors.mjs +22 -23
  7. package/dist/fetchers/container-items.d.mts +28 -28
  8. package/dist/fetchers/container-items.mjs +27 -27
  9. package/dist/fetchers/gallery.d.mts +13 -13
  10. package/dist/fetchers/gallery.mjs +2 -2
  11. package/dist/fetchers/item-children.d.mts +12 -12
  12. package/dist/fetchers/item-children.mjs +2 -2
  13. package/dist/fetchers/item-links.d.mts +10 -10
  14. package/dist/fetchers/item-links.mjs +6 -6
  15. package/dist/fetchers/item-locations.d.mts +20 -20
  16. package/dist/fetchers/item-locations.mjs +3 -3
  17. package/dist/fetchers/item-ocr-data.d.mts +23 -23
  18. package/dist/fetchers/item-ocr-data.mjs +44 -44
  19. package/dist/fetchers/item.d.mts +14 -14
  20. package/dist/fetchers/item.mjs +14 -14
  21. package/dist/fetchers/map-layers.d.mts +15 -15
  22. package/dist/fetchers/map-layers.mjs +12 -11
  23. package/dist/fetchers/request.d.mts +40 -40
  24. package/dist/fetchers/request.mjs +37 -37
  25. package/dist/fetchers/set/items.d.mts +15 -15
  26. package/dist/fetchers/set/items.mjs +1 -1
  27. package/dist/fetchers/set/property-values.d.mts +16 -16
  28. package/dist/fetchers/set/property-values.mjs +43 -43
  29. package/dist/fetchers/tree/items.d.mts +27 -27
  30. package/dist/fetchers/tree/items.mjs +1 -1
  31. package/dist/fetchers/website-metadata.d.mts +4 -4
  32. package/dist/fetchers/website-metadata.mjs +9 -9
  33. package/dist/fetchers/website.d.mts +10 -10
  34. package/dist/fetchers/website.mjs +12 -12
  35. package/dist/getters.d.mts +83 -83
  36. package/dist/getters.mjs +74 -74
  37. package/dist/helpers.d.mts +4 -4
  38. package/dist/helpers.mjs +7 -7
  39. package/dist/index.d.mts +3 -3
  40. package/dist/index.mjs +5 -5
  41. package/dist/languages.d.mts +58 -58
  42. package/dist/languages.mjs +21 -21
  43. package/dist/ocr.d.mts +27 -27
  44. package/dist/ocr.mjs +29 -29
  45. package/dist/parsers/helpers.d.mts +23 -23
  46. package/dist/parsers/helpers.mjs +8 -8
  47. package/dist/parsers/index.d.mts +2 -2
  48. package/dist/parsers/index.mjs +15 -15
  49. package/dist/parsers/languages.d.mts +49 -49
  50. package/dist/parsers/languages.mjs +49 -49
  51. package/dist/parsers/multilingual.d.mts +174 -174
  52. package/dist/parsers/multilingual.mjs +146 -146
  53. package/dist/parsers/partial-date.d.mts +12 -12
  54. package/dist/parsers/partial-date.mjs +11 -11
  55. package/dist/parsers/property-token.d.mts +20 -20
  56. package/dist/parsers/property-token.mjs +16 -16
  57. package/dist/parsers/string.d.mts +33 -33
  58. package/dist/parsers/string.mjs +62 -64
  59. package/dist/parsers/website/bounds.d.mts +6 -6
  60. package/dist/parsers/website/bounds.mjs +5 -5
  61. package/dist/parsers/website/components.d.mts +50 -31
  62. package/dist/parsers/website/components.mjs +79 -51
  63. package/dist/parsers/website/index.d.mts +1 -1
  64. package/dist/parsers/website/index.mjs +43 -47
  65. package/dist/parsers/website/links.d.mts +24 -24
  66. package/dist/parsers/website/links.mjs +18 -18
  67. package/dist/parsers/website/messages.d.mts +16 -16
  68. package/dist/parsers/website/messages.mjs +14 -14
  69. package/dist/parsers/website/options.d.mts +1 -1
  70. package/dist/parsers/website/properties.d.mts +17 -8
  71. package/dist/parsers/website/properties.mjs +22 -10
  72. package/dist/parsers/website/reader.d.mts +55 -46
  73. package/dist/parsers/website/reader.mjs +64 -46
  74. package/dist/parsers/website/slug.d.mts +50 -50
  75. package/dist/parsers/website/slug.mjs +36 -36
  76. package/dist/parsers/website/styles.d.mts +18 -18
  77. package/dist/parsers/website/styles.mjs +19 -19
  78. package/dist/parsers/website/walk.d.mts +46 -46
  79. package/dist/parsers/website/walk.mjs +34 -34
  80. package/dist/query.d.mts +63 -63
  81. package/dist/query.mjs +137 -140
  82. package/dist/reflection.d.mts +51 -51
  83. package/dist/reflection.mjs +45 -45
  84. package/dist/schemas.d.mts +44 -44
  85. package/dist/schemas.mjs +50 -50
  86. package/dist/types/index.d.mts +192 -192
  87. package/dist/types/utilities.d.mts +5 -5
  88. package/dist/types/website.d.mts +67 -62
  89. package/dist/xml/dates.d.mts +9 -9
  90. package/dist/xml/dates.mjs +9 -9
  91. package/dist/xml/metadata.d.mts +14 -14
  92. package/dist/xml/metadata.mjs +18 -18
  93. package/dist/xml/schemas.mjs +24 -24
  94. package/dist/xml/types.d.mts +9 -9
  95. package/dist/xquery.d.mts +49 -49
  96. package/dist/xquery.mjs +50 -50
  97. package/package.json +10 -10
package/dist/xquery.d.mts CHANGED
@@ -1,74 +1,74 @@
1
1
  /**
2
- * Build a string literal for an XQuery string
3
- * @param value - The string value to escape
4
- * @returns The escaped string literal
5
- * @internal
6
- */
2
+ Build a string literal for an XQuery string
3
+ @param value - The string value to escape
4
+ @returns The escaped string literal
5
+ @internal
6
+ */
7
7
  export declare function stringLiteral(value: string): string;
8
8
  /**
9
- * A comment every query puts inside the `<ochre>` element it returns
10
- *
11
- * The API answers a failed query with a bare `<result><ochre/></result>`, and
12
- * sends the same response whenever the returned `<ochre>` element holds fewer
13
- * than 25 characters. Padding keeps an empty or not-found result above that
14
- * cutoff, so the bare response only ever means failure. The XML parser drops
15
- * comments, so no schema sees it.
16
- * @internal
17
- */
9
+ A comment every query puts inside the `<ochre>` element it returns
10
+
11
+ The API answers a failed query with a bare `<result><ochre/></result>`, and
12
+ sends the same response whenever the returned `<ochre>` element holds fewer
13
+ than 25 characters. Padding keeps an empty or not-found result above that
14
+ cutoff, so the bare response only ever means failure. The XML parser drops
15
+ comments, so no schema sees it.
16
+ @internal
17
+ */
18
18
  export declare const OCHRE_RESPONSE_PADDING = "<!--ochre-sdk: keeps an empty result distinct from a failed query-->";
19
19
  /**
20
- * Which language a query should return, and what to show where it is missing
21
- */
20
+ Which language a query should return, and what to show where it is missing
21
+ */
22
22
  export type OchreContentLanguage = {
23
23
  language: string;
24
24
  fallbackLanguage: string;
25
25
  };
26
26
  /**
27
- * Resolve the content language a fetch asked for
28
- * @param options - The fetch options
29
- * @param options.language - The language to keep
30
- * @param options.fallbackLanguage - The language shown where `language` is missing
31
- * @returns The content language, or null to keep every language
32
- * @internal
33
- */
27
+ Resolve the content language a fetch asked for
28
+ @param options - The fetch options
29
+ @param options.language - The language to keep
30
+ @param options.fallbackLanguage - The language shown where `language` is missing
31
+ @returns The content language, or null to keep every language
32
+ @internal
33
+ */
34
34
  export declare function getContentLanguage(options?: {
35
35
  language?: string;
36
36
  fallbackLanguage?: string;
37
37
  }): OchreContentLanguage | null;
38
38
  /**
39
- * What a query body can ask the surrounding document for
40
- *
41
- * Handed to the body rather than imported by it, so a body cannot reference a
42
- * prolog declaration the document did not emit.
43
- */
39
+ What a query body can ask the surrounding document for
40
+
41
+ Handed to the body rather than imported by it, so a body cannot reference a
42
+ prolog declaration the document did not emit.
43
+ */
44
44
  export type OchreQueryContext = {
45
45
  /**
46
- * Wrap a node expression so supplemental nodes are omitted from it
47
- * @param expression - The XQuery expression returning the nodes to filter
48
- * @returns The wrapped XQuery expression
49
- */
46
+ Wrap a node expression so supplemental nodes are omitted from it
47
+ @param expression - The XQuery expression returning the nodes to filter
48
+ @returns The wrapped XQuery expression
49
+ */
50
50
  omitSupplemental: (expression: string) => string;
51
51
  /**
52
- * An XQuery predicate keeping only nodes that are neither supplemental
53
- * themselves nor nested inside a supplemental node. Use it when aggregating
54
- * over nodes instead of returning them.
55
- */
52
+ An XQuery predicate keeping only nodes that are neither supplemental
53
+ themselves nor nested inside a supplemental node. Use it when aggregating
54
+ over nodes instead of returning them.
55
+ */
56
56
  notSupplemental: string;
57
57
  };
58
58
  /**
59
- * Compile a complete XQuery document for the OCHRE API
60
- *
61
- * Owns the version declaration, the prolog ordering, and the
62
- * supplemental-stripping helper. The body receives what it is allowed to call,
63
- * so the helper cannot be invoked without having been declared, and every
64
- * fetcher stops restating the same preamble.
65
- * @param parameters - The document parameters
66
- * @param parameters.declarations - Prolog declarations, emitted in order before the supplemental helper
67
- * @param parameters.body - Builds the query body
68
- * @param parameters.contentLanguage - Keep only this language of every multilingual field in the result
69
- * @returns A complete XQuery document
70
- * @internal
71
- */
59
+ Compile a complete XQuery document for the OCHRE API
60
+
61
+ Owns the version declaration, the prolog ordering, and the
62
+ supplemental-stripping helper. The body receives what it is allowed to call,
63
+ so the helper cannot be invoked without having been declared, and every
64
+ fetcher stops restating the same preamble.
65
+ @param parameters - The document parameters
66
+ @param parameters.declarations - Prolog declarations, emitted in order before the supplemental helper
67
+ @param parameters.body - Builds the query body
68
+ @param parameters.contentLanguage - Keep only this language of every multilingual field in the result
69
+ @returns A complete XQuery document
70
+ @internal
71
+ */
72
72
  export declare function compileOchreQuery(parameters: {
73
73
  declarations?: ReadonlyArray<string>;
74
74
  body: (context: OchreQueryContext) => string;
package/dist/xquery.mjs CHANGED
@@ -1,36 +1,36 @@
1
1
  import { DEFAULT_LANGUAGES } from "./constants.mjs";
2
2
  // src/xquery.ts
3
3
  /**
4
- * Build a string literal for an XQuery string
5
- * @param value - The string value to escape
6
- * @returns The escaped string literal
7
- * @internal
4
+ Build a string literal for an XQuery string
5
+ @param value - The string value to escape
6
+ @returns The escaped string literal
7
+ @internal
8
8
  */
9
9
  function stringLiteral(value) {
10
10
  return `"${value.replaceAll("\"", "\"\"")}"`;
11
11
  }
12
12
  /**
13
- * A comment every query puts inside the `<ochre>` element it returns
14
- *
15
- * The API answers a failed query with a bare `<result><ochre/></result>`, and
16
- * sends the same response whenever the returned `<ochre>` element holds fewer
17
- * than 25 characters. Padding keeps an empty or not-found result above that
18
- * cutoff, so the bare response only ever means failure. The XML parser drops
19
- * comments, so no schema sees it.
20
- * @internal
13
+ A comment every query puts inside the `<ochre>` element it returns
14
+
15
+ The API answers a failed query with a bare `<result><ochre/></result>`, and
16
+ sends the same response whenever the returned `<ochre>` element holds fewer
17
+ than 25 characters. Padding keeps an empty or not-found result above that
18
+ cutoff, so the bare response only ever means failure. The XML parser drops
19
+ comments, so no schema sees it.
20
+ @internal
21
21
  */
22
22
  const OCHRE_RESPONSE_PADDING = "<!--ochre-sdk: keeps an empty result distinct from a failed query-->";
23
23
  /**
24
- * XQuery prolog declaring `local:omit-supplemental`, which drops every element
25
- * carrying `supplemental="true"` from a node sequence, at any depth.
26
- *
27
- * Subtrees without a supplemental descendant are returned by reference, so
28
- * nodes are only copied along the path leading to an omitted element. The
29
- * lookahead walks the attribute axis (`//@supplemental`) rather than testing
30
- * every element, which measures around three times faster on large documents.
31
- *
32
- * Private on purpose: it is only correct when it precedes a body that calls it,
33
- * and {@link compileOchreQuery} is the only thing that can guarantee that.
24
+ XQuery prolog declaring `local:omit-supplemental`, which drops every element
25
+ carrying `supplemental="true"` from a node sequence, at any depth.
26
+
27
+ Subtrees without a supplemental descendant are returned by reference, so
28
+ nodes are only copied along the path leading to an omitted element. The
29
+ lookahead walks the attribute axis (`//@supplemental`) rather than testing
30
+ every element, which measures around three times faster on large documents.
31
+
32
+ Private on purpose: it is only correct when it precedes a body that calls it,
33
+ and {@link compileOchreQuery} is the only thing that can guarantee that.
34
34
  */
35
35
  const SUPPLEMENTAL_XQUERY_PROLOG = `declare function local:omit-supplemental($nodes as node()*) as node()* {
36
36
  for $node in $nodes
@@ -48,16 +48,16 @@ const SUPPLEMENTAL_XQUERY_PROLOG = `declare function local:omit-supplemental($no
48
48
  else $node
49
49
  };`;
50
50
  /**
51
- * XQuery prolog declaring `local:select-language`, which keeps one language of
52
- * every multilingual field in a node sequence
53
- *
54
- * A field's `content` children are reduced to the one in `$language`, else the
55
- * one in `$fallback`, else the first in any language, which is the choice the
56
- * API's own `lang` parameter makes. `zxx` content is always kept, since it holds
57
- * a field's aliases rather than a translation; the API's `lang` parameter drops
58
- * it, which is why the SDK selects languages itself. Leaf elements are
59
- * returned by reference; testing for multilingual descendants before copying a
60
- * subtree measured slower than copying it.
51
+ XQuery prolog declaring `local:select-language`, which keeps one language of
52
+ every multilingual field in a node sequence
53
+
54
+ A field's `content` children are reduced to the one in `$language`, else the
55
+ one in `$fallback`, else the first in any language, which is the choice the
56
+ API's own `lang` parameter makes. `zxx` content is always kept, since it holds
57
+ a field's aliases rather than a translation; the API's `lang` parameter drops
58
+ it, which is why the SDK selects languages itself. Leaf elements are
59
+ returned by reference; testing for multilingual descendants before copying a
60
+ subtree measured slower than copying it.
61
61
  */
62
62
  const LANGUAGE_XQUERY_PROLOG = `declare function local:select-language($nodes as node()*, $language as xs:string, $fallback as xs:string) as node()* {
63
63
  for $node in $nodes
@@ -90,12 +90,12 @@ const LANGUAGE_XQUERY_PROLOG = `declare function local:select-language($nodes as
90
90
  default return $node
91
91
  };`;
92
92
  /**
93
- * Resolve the content language a fetch asked for
94
- * @param options - The fetch options
95
- * @param options.language - The language to keep
96
- * @param options.fallbackLanguage - The language shown where `language` is missing
97
- * @returns The content language, or null to keep every language
98
- * @internal
93
+ Resolve the content language a fetch asked for
94
+ @param options - The fetch options
95
+ @param options.language - The language to keep
96
+ @param options.fallbackLanguage - The language shown where `language` is missing
97
+ @returns The content language, or null to keep every language
98
+ @internal
99
99
  */
100
100
  function getContentLanguage(options) {
101
101
  if (options?.language == null) return null;
@@ -106,18 +106,18 @@ function getContentLanguage(options) {
106
106
  }
107
107
  const NOT_SUPPLEMENTAL_PREDICATE = "[not(ancestor-or-self::*[@supplemental = \"true\"])]";
108
108
  /**
109
- * Compile a complete XQuery document for the OCHRE API
110
- *
111
- * Owns the version declaration, the prolog ordering, and the
112
- * supplemental-stripping helper. The body receives what it is allowed to call,
113
- * so the helper cannot be invoked without having been declared, and every
114
- * fetcher stops restating the same preamble.
115
- * @param parameters - The document parameters
116
- * @param parameters.declarations - Prolog declarations, emitted in order before the supplemental helper
117
- * @param parameters.body - Builds the query body
118
- * @param parameters.contentLanguage - Keep only this language of every multilingual field in the result
119
- * @returns A complete XQuery document
120
- * @internal
109
+ Compile a complete XQuery document for the OCHRE API
110
+
111
+ Owns the version declaration, the prolog ordering, and the
112
+ supplemental-stripping helper. The body receives what it is allowed to call,
113
+ so the helper cannot be invoked without having been declared, and every
114
+ fetcher stops restating the same preamble.
115
+ @param parameters - The document parameters
116
+ @param parameters.declarations - Prolog declarations, emitted in order before the supplemental helper
117
+ @param parameters.body - Builds the query body
118
+ @param parameters.contentLanguage - Keep only this language of every multilingual field in the result
119
+ @returns A complete XQuery document
120
+ @internal
121
121
  */
122
122
  function compileOchreQuery(parameters) {
123
123
  const { declarations = [], body, contentLanguage } = parameters;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "ochre-sdk",
3
- "version": "1.3.25",
3
+ "version": "1.3.26",
4
4
  "type": "module",
5
5
  "license": "MIT",
6
6
  "description": "Node.js library for working with OCHRE (Online Cultural and Historical Research Environment) data",
@@ -46,23 +46,23 @@
46
46
  ],
47
47
  "dependencies": {
48
48
  "@nodable/entities": "^3.1.0",
49
- "fast-equals": "^6.2.1",
50
- "fast-xml-parser": "^5.11.2",
49
+ "fast-equals": "^6.2.2",
50
+ "fast-xml-parser": "^5.12.0",
51
51
  "valibot": "^1.5.0"
52
52
  },
53
53
  "devDependencies": {
54
- "@antfu/eslint-config": "^9.5.1",
55
- "@types/node": "^24.19.2",
54
+ "@antfu/eslint-config": "^10.0.0",
55
+ "@types/node": "^26.6.6",
56
56
  "bumpp": "^12.3.0",
57
- "eslint": "^10.13.0",
57
+ "eslint": "^10.14.0",
58
58
  "eslint-plugin-erasable-syntax-only": "^0.7.2",
59
59
  "eslint-plugin-slop": "^0.1.3",
60
60
  "eslint-plugin-sonarjs": "^4.2.2",
61
- "knip": "^6.42.1",
62
- "oxfmt": "^0.74.0",
63
- "tsdown": "^0.23.1",
61
+ "knip": "^6.45.1",
62
+ "oxfmt": "^0.78.0",
63
+ "tsdown": "^0.23.7",
64
64
  "typescript": "^6.0.3",
65
- "vitest": "^5.0.5"
65
+ "vitest": "^5.1.0"
66
66
  },
67
67
  "scripts": {
68
68
  "dev": "tsdown src/index.ts --watch",