ochre-sdk 0.22.5 → 0.22.7

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 CHANGED
@@ -776,7 +776,11 @@ type LevelContext = {
776
776
  type PropertyContexts = {
777
777
  flatten: Array<LevelContext>;
778
778
  suppress: Array<LevelContext>;
779
- filter: Array<LevelContext>;
779
+ filter: Array<LevelContext & {
780
+ isInlineDisplayed: boolean;
781
+ isSidebarDisplayed: boolean;
782
+ isSidebarOpen: boolean;
783
+ }>;
780
784
  sort: Array<LevelContext>;
781
785
  detail: Array<LevelContext>;
782
786
  download: Array<LevelContext>;
package/dist/index.mjs CHANGED
@@ -919,7 +919,6 @@ const setItemsParamsSchema = z.object({
919
919
  });
920
920
  //#endregion
921
921
  //#region src/utils/parse/index.ts
922
- const TRAILING_ELLIPSIS_REGEX = /\s*\.{3}$/;
923
922
  /**
924
923
  * Parses raw identification data into the standardized Identification type
925
924
  *
@@ -1018,7 +1017,7 @@ function parseMetadata(metadata) {
1018
1017
  * @param contextItem - Raw context item data from OCHRE format
1019
1018
  * @returns Parsed ContextItem object
1020
1019
  */
1021
- function parseContextItem(contextItem) {
1020
+ function parseContextItem$1(contextItem) {
1022
1021
  return {
1023
1022
  uuid: contextItem.uuid,
1024
1023
  publicationDateTime: parseOptionalDate(contextItem.publicationDateTime),
@@ -1035,9 +1034,9 @@ function parseContextItem(contextItem) {
1035
1034
  function parseContext(context) {
1036
1035
  return {
1037
1036
  nodes: ensureArray(context.context).map((ctx) => ({
1038
- tree: parseContextItem(ctx.tree),
1039
- project: parseContextItem(ctx.project),
1040
- spatialUnit: "spatialUnit" in ctx && ctx.spatialUnit ? ensureArray(ctx.spatialUnit).map((element) => parseContextItem(element)) : []
1037
+ tree: parseContextItem$1(ctx.tree),
1038
+ project: parseContextItem$1(ctx.project),
1039
+ spatialUnit: "spatialUnit" in ctx && ctx.spatialUnit ? ensureArray(ctx.spatialUnit).map((element) => parseContextItem$1(element)) : []
1041
1040
  })),
1042
1041
  displayPath: context.displayPath
1043
1042
  };
@@ -1426,7 +1425,7 @@ function parseProperty(property, language = "eng") {
1426
1425
  });
1427
1426
  return {
1428
1427
  uuid: property.label.uuid,
1429
- label: parseStringContent(property.label, language).replace(TRAILING_ELLIPSIS_REGEX, "").trim(),
1428
+ label: parseStringContent(property.label, language).trim(),
1430
1429
  values,
1431
1430
  comment: property.comment != null ? parseStringContent(property.comment) : null,
1432
1431
  properties: property.property ? parseProperties(ensureArray(property.property)) : []
@@ -3713,10 +3712,13 @@ function parseAllOptionContexts(options) {
3713
3712
  function handleContexts(v) {
3714
3713
  return parseContexts(v != null ? ensureArray(v) : []);
3715
3714
  }
3715
+ function handleFilterContexts(v) {
3716
+ return parseFilterContexts(v != null ? ensureArray(v) : []);
3717
+ }
3716
3718
  return {
3717
3719
  flatten: handleContexts(options.flattenContexts),
3718
3720
  suppress: handleContexts(options.suppressContexts),
3719
- filter: handleContexts(options.filterContexts),
3721
+ filter: handleFilterContexts(options.filterContexts),
3720
3722
  sort: handleContexts(options.sortContexts),
3721
3723
  detail: handleContexts(options.detailContexts),
3722
3724
  download: handleContexts(options.downloadContexts),
@@ -4919,12 +4921,11 @@ function parseWebsiteProperties(properties, websiteTree, sidebar) {
4919
4921
  if ("styleOptions" in websiteTree && websiteTree.styleOptions != null) returnProperties.options.stylesheets.properties = parseStylesheets(ensureArray(websiteTree.styleOptions.style));
4920
4922
  return returnProperties;
4921
4923
  }
4922
- function parseContexts(contexts) {
4923
- const contextsParsed = [];
4924
- for (const mainContext of contexts) for (const contextItemToParse of ensureArray(mainContext.context)) {
4925
- const levelsToParse = ensureArray(contextItemToParse.levels.level);
4926
- let type = "";
4927
- const levels = levelsToParse.map((level) => {
4924
+ function parseContextItem(contextItemToParse) {
4925
+ const levelsToParse = ensureArray(contextItemToParse.levels.level);
4926
+ let type = "";
4927
+ return {
4928
+ context: levelsToParse.map((level) => {
4928
4929
  let variableUuid = "";
4929
4930
  let valueUuid = null;
4930
4931
  if (typeof level === "string") {
@@ -4941,13 +4942,56 @@ function parseContexts(contexts) {
4941
4942
  variableUuid,
4942
4943
  valueUuid
4943
4944
  };
4944
- });
4945
- contextsParsed.push({
4946
- context: levels,
4947
- type,
4948
- identification: parseIdentification(contextItemToParse.identification)
4949
- });
4945
+ }),
4946
+ type,
4947
+ identification: parseIdentification(contextItemToParse.identification)
4948
+ };
4949
+ }
4950
+ function parseFilterContextDisplay(filterOption) {
4951
+ switch (filterOption) {
4952
+ case "inline-displayed": return {
4953
+ isInlineDisplayed: true,
4954
+ isSidebarDisplayed: false,
4955
+ isSidebarOpen: false
4956
+ };
4957
+ case "inline-sidebar-displayed-closed": return {
4958
+ isInlineDisplayed: true,
4959
+ isSidebarDisplayed: true,
4960
+ isSidebarOpen: false
4961
+ };
4962
+ case "inline-sidebar-displayed-open": return {
4963
+ isInlineDisplayed: true,
4964
+ isSidebarDisplayed: true,
4965
+ isSidebarOpen: true
4966
+ };
4967
+ case "sidebar-displayed-closed": return {
4968
+ isInlineDisplayed: false,
4969
+ isSidebarDisplayed: true,
4970
+ isSidebarOpen: false
4971
+ };
4972
+ case "sidebar-displayed-open": return {
4973
+ isInlineDisplayed: false,
4974
+ isSidebarDisplayed: true,
4975
+ isSidebarOpen: true
4976
+ };
4977
+ default: return {
4978
+ isInlineDisplayed: false,
4979
+ isSidebarDisplayed: false,
4980
+ isSidebarOpen: false
4981
+ };
4950
4982
  }
4983
+ }
4984
+ function parseContexts(contexts) {
4985
+ const contextsParsed = [];
4986
+ for (const mainContext of contexts) for (const contextItemToParse of ensureArray(mainContext.context)) contextsParsed.push(parseContextItem(contextItemToParse));
4987
+ return contextsParsed;
4988
+ }
4989
+ function parseFilterContexts(contexts) {
4990
+ const contextsParsed = [];
4991
+ for (const mainContext of contexts) for (const contextItemToParse of ensureArray(mainContext.context)) contextsParsed.push({
4992
+ ...parseContextItem(contextItemToParse),
4993
+ ...parseFilterContextDisplay(contextItemToParse.filterOption)
4994
+ });
4951
4995
  return contextsParsed;
4952
4996
  }
4953
4997
  function parseWebsite(websiteTree, metadata, belongsTo, { version = 2 } = {}) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "ochre-sdk",
3
- "version": "0.22.5",
3
+ "version": "0.22.7",
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",
@@ -49,12 +49,12 @@
49
49
  "zod": "^4.3.6"
50
50
  },
51
51
  "devDependencies": {
52
- "@antfu/eslint-config": "^8.1.0",
52
+ "@antfu/eslint-config": "^8.2.0",
53
53
  "@types/node": "^24.12.2",
54
54
  "bumpp": "^11.0.1",
55
55
  "eslint": "^10.2.0",
56
- "prettier": "^3.8.1",
57
- "tsdown": "^0.21.7",
56
+ "prettier": "^3.8.2",
57
+ "tsdown": "^0.21.8",
58
58
  "typescript": "^6.0.2",
59
59
  "vitest": "^4.1.4"
60
60
  },