@builder.io/sdk 6.1.3 → 6.2.1

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.esm.js CHANGED
@@ -950,7 +950,7 @@ function toError(err) {
950
950
 
951
951
  var DEFAULT_API_VERSION = 'v3';
952
952
 
953
- var SDK_VERSION = '6.1.3';
953
+ var SDK_VERSION = '6.2.1';
954
954
 
955
955
  function datePlusMinutes(minutes) {
956
956
  if (minutes === void 0) { minutes = 30; }
@@ -1702,7 +1702,15 @@ var Builder = /** @class */ (function () {
1702
1702
  if (isIframe || !isBrowser || Builder.isPreviewing) {
1703
1703
  return;
1704
1704
  }
1705
- var meta = typeof contentId === 'object' ? contentId : customProperties;
1705
+ var metadata = typeof contentId === 'object'
1706
+ ? __assign({}, contentId) : customProperties && typeof customProperties === 'object'
1707
+ ? __assign({}, customProperties) : undefined;
1708
+ if (amount !== undefined) {
1709
+ if (!metadata) {
1710
+ metadata = {};
1711
+ }
1712
+ metadata.amount = amount;
1713
+ }
1706
1714
  var useContentId = typeof contentId === 'string' ? contentId : undefined;
1707
1715
  if (!useContentId && !contentId && this.contentId) {
1708
1716
  useContentId = this.contentId;
@@ -1716,7 +1724,7 @@ var Builder = /** @class */ (function () {
1716
1724
  variationId: useVariationId && useContentId && useVariationId !== useContentId
1717
1725
  ? useVariationId
1718
1726
  : undefined,
1719
- meta: meta,
1727
+ meta: metadata,
1720
1728
  contentId: useContentId,
1721
1729
  }, context);
1722
1730
  };
@@ -2506,6 +2514,14 @@ var Builder = /** @class */ (function () {
2506
2514
  if (this.apiEndpoint === 'content') {
2507
2515
  queryParams.includeRefs = true;
2508
2516
  }
2517
+ if (this.apiEndpoint === 'query') {
2518
+ if ('enrich' in options && options.enrich !== undefined) {
2519
+ queryParams.enrich = options.enrich;
2520
+ }
2521
+ if (options.enrichOptions) {
2522
+ this.flattenEnrichOptions(options.enrichOptions, 'enrichOptions', queryParams);
2523
+ }
2524
+ }
2509
2525
  var properties = [
2510
2526
  'prerender',
2511
2527
  'extractCss',
@@ -2533,6 +2549,15 @@ var Builder = /** @class */ (function () {
2533
2549
  }
2534
2550
  }
2535
2551
  }
2552
+ // Handle enrich and enrichOptions for content endpoint
2553
+ if (this.apiEndpoint === 'content') {
2554
+ if ('enrich' in options && options.enrich !== undefined) {
2555
+ queryParams.enrich = options.enrich;
2556
+ }
2557
+ if (options.enrichOptions) {
2558
+ this.flattenEnrichOptions(options.enrichOptions, 'enrichOptions', queryParams);
2559
+ }
2560
+ }
2536
2561
  }
2537
2562
  if (this.preview && this.previewingModel === ((_b = queue === null || queue === void 0 ? void 0 : queue[0]) === null || _b === void 0 ? void 0 : _b.model)) {
2538
2563
  queryParams.preview = 'true';
@@ -2691,6 +2716,22 @@ var Builder = /** @class */ (function () {
2691
2716
  }
2692
2717
  return Builder.isBrowser && setCookie(name, value, expires);
2693
2718
  };
2719
+ /**
2720
+ * Recursively flattens enrichOptions object into dot-notation query parameters
2721
+ * @private
2722
+ */
2723
+ Builder.prototype.flattenEnrichOptions = function (obj, prefix, result) {
2724
+ for (var _i = 0, _a = Object.entries(obj); _i < _a.length; _i++) {
2725
+ var _b = _a[_i], key = _b[0], value = _b[1];
2726
+ var newKey = "".concat(prefix, ".").concat(key);
2727
+ if (value && typeof value === 'object' && !Array.isArray(value)) {
2728
+ this.flattenEnrichOptions(value, newKey, result);
2729
+ }
2730
+ else {
2731
+ result[newKey] = value;
2732
+ }
2733
+ }
2734
+ };
2694
2735
  Builder.prototype.getContent = function (modelName, options) {
2695
2736
  if (options === void 0) { options = {}; }
2696
2737
  if (!this.apiKey) {