@digitalculture/ochre-sdk 0.17.9 → 0.17.11

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 (2) hide show
  1. package/dist/index.mjs +39 -6
  2. package/package.json +1 -1
package/dist/index.mjs CHANGED
@@ -69,6 +69,29 @@ function flattenProperties(properties) {
69
69
  * @internal
70
70
  */
71
71
  const uuidSchema = z.string().refine(isPseudoUuid, { error: "Invalid pseudo-UUID" });
72
+ const richTextStringContentSchema = z.object({
73
+ content: z.union([
74
+ z.string(),
75
+ z.number(),
76
+ z.boolean()
77
+ ]),
78
+ rend: z.string().optional(),
79
+ whitespace: z.string().optional()
80
+ });
81
+ /**
82
+ * Schema for validating rich text string content
83
+ * @internal
84
+ */
85
+ const richTextStringSchema = z.object({
86
+ string: z.union([
87
+ z.string(),
88
+ z.number(),
89
+ z.boolean(),
90
+ richTextStringContentSchema,
91
+ z.array(richTextStringContentSchema)
92
+ ]),
93
+ lang: z.string().optional()
94
+ });
72
95
  /**
73
96
  * Schema for validating filters
74
97
  * @internal
@@ -3620,8 +3643,18 @@ const responseItemSchema = z.object({
3620
3643
  type: z.string().optional(),
3621
3644
  dataType: z.string().optional(),
3622
3645
  publicationDateTime: z.string().optional(),
3623
- content: z.string().optional(),
3624
- rawValue: z.string().optional()
3646
+ content: z.union([
3647
+ z.string(),
3648
+ z.number(),
3649
+ z.boolean(),
3650
+ richTextStringSchema,
3651
+ z.array(richTextStringSchema)
3652
+ ]).optional(),
3653
+ rawValue: z.union([
3654
+ z.string(),
3655
+ z.number(),
3656
+ z.boolean()
3657
+ ]).optional()
3625
3658
  })
3626
3659
  });
3627
3660
  /**
@@ -3682,7 +3715,7 @@ async function fetchPropertyValuesByPropertyVariables(params, options) {
3682
3715
  for (const item of parsedItems) {
3683
3716
  const categoryUuid = item.category.uuid;
3684
3717
  const valueUuid = item.value.uuid;
3685
- const valueContent = item.value.rawValue ?? item.value.content ?? "";
3718
+ const valueContent = item.value.rawValue?.toString() ?? (typeof item.value.content === "string" || typeof item.value.content === "number" || typeof item.value.content === "boolean" ? parseFakeString(item.value.content) : item.value.content != null ? parseStringContent({ content: item.value.content }) : "");
3686
3719
  if (valueContent in items) items[valueContent].resultUuids.push(categoryUuid);
3687
3720
  else items[valueContent] = {
3688
3721
  value: {
@@ -3691,8 +3724,8 @@ async function fetchPropertyValuesByPropertyVariables(params, options) {
3691
3724
  type: item.value.type ?? null,
3692
3725
  dataType: item.value.dataType ?? null,
3693
3726
  publicationDateTime: item.value.publicationDateTime ?? null,
3694
- content: item.value.rawValue ?? item.value.content ?? "",
3695
- label: item.value.rawValue != null && item.value.content != null ? item.value.content : null
3727
+ content: valueContent,
3728
+ label: item.value.rawValue != null && item.value.content != null ? typeof item.value.content === "string" || typeof item.value.content === "number" || typeof item.value.content === "boolean" ? item.value.content.toString() : Array.isArray(item.value.content) ? item.value.content.find((content) => content.lang === "eng")?.string.toString() ?? "" : item.value.content.string.toString() : null
3696
3729
  },
3697
3730
  resultUuids: [categoryUuid]
3698
3731
  };
@@ -3702,7 +3735,7 @@ async function fetchPropertyValuesByPropertyVariables(params, options) {
3702
3735
  const aValue = a.value.label ?? a.value.content;
3703
3736
  const bValue = b.value.label ?? b.value.content;
3704
3737
  return aValue.localeCompare(bValue, "en-US");
3705
- }),
3738
+ }).filter((item) => item.value.content !== ""),
3706
3739
  error: null
3707
3740
  };
3708
3741
  } catch (error) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@digitalculture/ochre-sdk",
3
- "version": "0.17.9",
3
+ "version": "0.17.11",
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",