@digitalculture/ochre-sdk 0.2.6 → 0.2.8

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/README.md CHANGED
@@ -5,19 +5,19 @@ This is the OCHRE JavaScript/TypeScript SDK for interacting with OCHRE (Online C
5
5
  ## Installation
6
6
 
7
7
  ```bash
8
- pnpm add @digital-culture/ochre-sdk
8
+ pnpm add @digitalculture/ochre-sdk
9
9
  ```
10
10
 
11
11
  or
12
12
 
13
13
  ```bash
14
- npm install @digital-culture/ochre-sdk
14
+ npm install @digitalculture/ochre-sdk
15
15
  ```
16
16
 
17
17
  or
18
18
 
19
19
  ```bash
20
- bun add @digital-culture/ochre-sdk
20
+ bun add @digitalculture/ochre-sdk
21
21
  ```
22
22
 
23
23
  ## Start development server
package/dist/index.cjs CHANGED
@@ -898,7 +898,7 @@ function parseProperties(properties, language = "eng") {
898
898
  for (const property of properties) {
899
899
  const valuesToParse = "value" in property && property.value ? Array.isArray(property.value) ? property.value : [property.value] : [];
900
900
  const values = valuesToParse.map(
901
- (value) => !["string", "number", "boolean"].includes(typeof value) && typeof value === "object" && "uuid" in value ? {
901
+ (value) => !["string", "number", "boolean"].includes(typeof value) && typeof value === "object" ? {
902
902
  content: parseStringContent(value),
903
903
  type: value.type,
904
904
  category: value.category !== "value" ? value.category ?? null : null,
@@ -1513,6 +1513,13 @@ async function parseWebElementProperties(componentProperty, elementResource) {
1513
1513
  height: imageLink.image?.height ?? 0
1514
1514
  });
1515
1515
  }
1516
+ let variant = getPropertyValueByLabel(
1517
+ componentProperty.properties,
1518
+ "variant"
1519
+ );
1520
+ if (variant === null) {
1521
+ variant = "default";
1522
+ }
1516
1523
  let captionLayout = getPropertyValueByLabel(
1517
1524
  componentProperty.properties,
1518
1525
  "caption-layout"
@@ -1541,40 +1548,39 @@ async function parseWebElementProperties(componentProperty, elementResource) {
1541
1548
  if (altTextSource === null) {
1542
1549
  altTextSource = "name";
1543
1550
  }
1544
- const carousel = images.length > 1 ? {
1545
- secondsPerImage: 5,
1546
- isFullWidth: false,
1547
- isFullHeight: false
1548
- } : null;
1549
- if (carousel !== null) {
1550
- const carouselSecondsPerImage = getPropertyValueByLabel(
1551
- componentProperty.properties,
1552
- "carousel-seconds-per-image"
1553
- );
1554
- if (carouselSecondsPerImage !== null) {
1555
- carousel.secondsPerImage = Number.parseFloat(carouselSecondsPerImage);
1556
- }
1557
- const carouselIsFullWidth = getPropertyValueByLabel(
1558
- componentProperty.properties,
1559
- "carousel-full-width"
1560
- );
1561
- if (carouselIsFullWidth !== null) {
1562
- carousel.isFullWidth = carouselIsFullWidth === "Yes";
1563
- }
1564
- const carouselIsFullHeight = getPropertyValueByLabel(
1565
- componentProperty.properties,
1566
- "carousel-full-height"
1567
- );
1568
- if (carouselIsFullHeight !== null) {
1569
- carousel.isFullHeight = carouselIsFullHeight === "Yes";
1570
- }
1551
+ let secondsPerImage = images.length > 1 ? 5 : null;
1552
+ const secondsPerImageProperty = getPropertyValueByLabel(
1553
+ componentProperty.properties,
1554
+ "seconds-per-image"
1555
+ );
1556
+ if (secondsPerImageProperty !== null) {
1557
+ secondsPerImage = Number.parseFloat(secondsPerImageProperty);
1558
+ }
1559
+ let isFullWidth = false;
1560
+ const isFullWidthProperty = getPropertyValueByLabel(
1561
+ componentProperty.properties,
1562
+ "is-full-width"
1563
+ );
1564
+ if (isFullWidthProperty !== null) {
1565
+ isFullWidth = isFullWidthProperty === "Yes";
1566
+ }
1567
+ let isFullHeight = false;
1568
+ const isFullHeightProperty = getPropertyValueByLabel(
1569
+ componentProperty.properties,
1570
+ "is-full-height"
1571
+ );
1572
+ if (isFullHeightProperty !== null) {
1573
+ isFullHeight = isFullHeightProperty === "Yes";
1571
1574
  }
1572
1575
  properties.images = images;
1576
+ properties.variant = variant;
1573
1577
  properties.imageQuality = imageQuality;
1574
1578
  properties.captionLayout = captionLayout;
1575
1579
  properties.captionSource = captionSource;
1576
1580
  properties.altTextSource = altTextSource;
1577
- properties.carousel = carousel;
1581
+ properties.secondsPerImage = secondsPerImage;
1582
+ properties.isFullWidth = isFullWidth;
1583
+ properties.isFullHeight = isFullHeight;
1578
1584
  break;
1579
1585
  }
1580
1586
  case "image-gallery": {
package/dist/index.d.cts CHANGED
@@ -499,11 +499,9 @@ type WebElementComponent = {
499
499
  captionSource: "name" | "abbreviation" | "description";
500
500
  captionLayout: "top" | "bottom" | "suppress";
501
501
  altTextSource: "name" | "abbreviation" | "description";
502
- carousel: {
503
- secondsPerImage: number;
504
- isFullWidth: boolean;
505
- isFullHeight: boolean;
506
- } | null;
502
+ secondsPerImage: number | null;
503
+ isFullWidth: boolean | null;
504
+ isFullHeight: boolean | null;
507
505
  } | {
508
506
  component: "image-gallery";
509
507
  galleryId: string;
package/dist/index.d.ts CHANGED
@@ -499,11 +499,9 @@ type WebElementComponent = {
499
499
  captionSource: "name" | "abbreviation" | "description";
500
500
  captionLayout: "top" | "bottom" | "suppress";
501
501
  altTextSource: "name" | "abbreviation" | "description";
502
- carousel: {
503
- secondsPerImage: number;
504
- isFullWidth: boolean;
505
- isFullHeight: boolean;
506
- } | null;
502
+ secondsPerImage: number | null;
503
+ isFullWidth: boolean | null;
504
+ isFullHeight: boolean | null;
507
505
  } | {
508
506
  component: "image-gallery";
509
507
  galleryId: string;
package/dist/index.js CHANGED
@@ -820,7 +820,7 @@ function parseProperties(properties, language = "eng") {
820
820
  for (const property of properties) {
821
821
  const valuesToParse = "value" in property && property.value ? Array.isArray(property.value) ? property.value : [property.value] : [];
822
822
  const values = valuesToParse.map(
823
- (value) => !["string", "number", "boolean"].includes(typeof value) && typeof value === "object" && "uuid" in value ? {
823
+ (value) => !["string", "number", "boolean"].includes(typeof value) && typeof value === "object" ? {
824
824
  content: parseStringContent(value),
825
825
  type: value.type,
826
826
  category: value.category !== "value" ? value.category ?? null : null,
@@ -1435,6 +1435,13 @@ async function parseWebElementProperties(componentProperty, elementResource) {
1435
1435
  height: imageLink.image?.height ?? 0
1436
1436
  });
1437
1437
  }
1438
+ let variant = getPropertyValueByLabel(
1439
+ componentProperty.properties,
1440
+ "variant"
1441
+ );
1442
+ if (variant === null) {
1443
+ variant = "default";
1444
+ }
1438
1445
  let captionLayout = getPropertyValueByLabel(
1439
1446
  componentProperty.properties,
1440
1447
  "caption-layout"
@@ -1463,40 +1470,39 @@ async function parseWebElementProperties(componentProperty, elementResource) {
1463
1470
  if (altTextSource === null) {
1464
1471
  altTextSource = "name";
1465
1472
  }
1466
- const carousel = images.length > 1 ? {
1467
- secondsPerImage: 5,
1468
- isFullWidth: false,
1469
- isFullHeight: false
1470
- } : null;
1471
- if (carousel !== null) {
1472
- const carouselSecondsPerImage = getPropertyValueByLabel(
1473
- componentProperty.properties,
1474
- "carousel-seconds-per-image"
1475
- );
1476
- if (carouselSecondsPerImage !== null) {
1477
- carousel.secondsPerImage = Number.parseFloat(carouselSecondsPerImage);
1478
- }
1479
- const carouselIsFullWidth = getPropertyValueByLabel(
1480
- componentProperty.properties,
1481
- "carousel-full-width"
1482
- );
1483
- if (carouselIsFullWidth !== null) {
1484
- carousel.isFullWidth = carouselIsFullWidth === "Yes";
1485
- }
1486
- const carouselIsFullHeight = getPropertyValueByLabel(
1487
- componentProperty.properties,
1488
- "carousel-full-height"
1489
- );
1490
- if (carouselIsFullHeight !== null) {
1491
- carousel.isFullHeight = carouselIsFullHeight === "Yes";
1492
- }
1473
+ let secondsPerImage = images.length > 1 ? 5 : null;
1474
+ const secondsPerImageProperty = getPropertyValueByLabel(
1475
+ componentProperty.properties,
1476
+ "seconds-per-image"
1477
+ );
1478
+ if (secondsPerImageProperty !== null) {
1479
+ secondsPerImage = Number.parseFloat(secondsPerImageProperty);
1480
+ }
1481
+ let isFullWidth = false;
1482
+ const isFullWidthProperty = getPropertyValueByLabel(
1483
+ componentProperty.properties,
1484
+ "is-full-width"
1485
+ );
1486
+ if (isFullWidthProperty !== null) {
1487
+ isFullWidth = isFullWidthProperty === "Yes";
1488
+ }
1489
+ let isFullHeight = false;
1490
+ const isFullHeightProperty = getPropertyValueByLabel(
1491
+ componentProperty.properties,
1492
+ "is-full-height"
1493
+ );
1494
+ if (isFullHeightProperty !== null) {
1495
+ isFullHeight = isFullHeightProperty === "Yes";
1493
1496
  }
1494
1497
  properties.images = images;
1498
+ properties.variant = variant;
1495
1499
  properties.imageQuality = imageQuality;
1496
1500
  properties.captionLayout = captionLayout;
1497
1501
  properties.captionSource = captionSource;
1498
1502
  properties.altTextSource = altTextSource;
1499
- properties.carousel = carousel;
1503
+ properties.secondsPerImage = secondsPerImage;
1504
+ properties.isFullWidth = isFullWidth;
1505
+ properties.isFullHeight = isFullHeight;
1500
1506
  break;
1501
1507
  }
1502
1508
  case "image-gallery": {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@digitalculture/ochre-sdk",
3
- "version": "0.2.6",
3
+ "version": "0.2.8",
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",