@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/CHANGELOG.md +53 -0
- package/dist/index.browser.js +44 -3
- package/dist/index.browser.js.map +1 -1
- package/dist/index.cjs.js +44 -3
- package/dist/index.cjs.js.map +1 -1
- package/dist/index.esm.js +44 -3
- package/dist/index.esm.js.map +1 -1
- package/dist/index.umd.js +44 -3
- package/dist/index.umd.js.map +1 -1
- package/dist/package.json +1 -1
- package/dist/src/builder.class.d.ts +47 -1
- package/dist/src/builder.class.js +43 -2
- package/dist/src/builder.class.js.map +1 -1
- package/dist/src/builder.class.test.js +108 -0
- package/dist/src/builder.class.test.js.map +1 -1
- package/dist/src/sdk-version.d.ts +1 -1
- package/dist/src/sdk-version.js +1 -1
- package/dist/tsconfig.tsbuildinfo +1 -1
- package/package.json +1 -1
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,58 @@
|
|
|
1
1
|
# @builder.io/sdk
|
|
2
2
|
|
|
3
|
+
## 6.2.1
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- fffde77: fix trackConversion method for sdks
|
|
8
|
+
|
|
9
|
+
## 6.2.0
|
|
10
|
+
|
|
11
|
+
### Minor Changes
|
|
12
|
+
|
|
13
|
+
- c729e93: Feat: Add support for `enrichOptions` parameter to control reference enrichment depth and field selection when fetching content.
|
|
14
|
+
|
|
15
|
+
This feature allows you to:
|
|
16
|
+
|
|
17
|
+
- Control the depth level of nested reference enrichment (up to 4 levels)
|
|
18
|
+
- Selectively include/exclude fields for each referenced model type
|
|
19
|
+
- Optimize API responses by fetching only the data you need
|
|
20
|
+
|
|
21
|
+
Example usage:
|
|
22
|
+
|
|
23
|
+
```typescript
|
|
24
|
+
// Basic enrichment with depth control
|
|
25
|
+
await builder.getAll("page", {
|
|
26
|
+
enrich: true,
|
|
27
|
+
enrichOptions: {
|
|
28
|
+
enrichLevel: 2, // Fetch 2 levels of nested references
|
|
29
|
+
},
|
|
30
|
+
});
|
|
31
|
+
|
|
32
|
+
// Advanced: Selective field inclusion per model
|
|
33
|
+
await builder.getAll("page", {
|
|
34
|
+
enrich: true,
|
|
35
|
+
enrichOptions: {
|
|
36
|
+
enrichLevel: 3,
|
|
37
|
+
model: {
|
|
38
|
+
product: {
|
|
39
|
+
fields: "id,name,price",
|
|
40
|
+
omit: "data.internalNotes",
|
|
41
|
+
},
|
|
42
|
+
category: {
|
|
43
|
+
fields: "id,name",
|
|
44
|
+
},
|
|
45
|
+
},
|
|
46
|
+
},
|
|
47
|
+
});
|
|
48
|
+
```
|
|
49
|
+
|
|
50
|
+
## 6.1.4
|
|
51
|
+
|
|
52
|
+
### Patch Changes
|
|
53
|
+
|
|
54
|
+
- 1b1b76e: chore: add back `description` support for inputs
|
|
55
|
+
|
|
3
56
|
## 6.1.3
|
|
4
57
|
|
|
5
58
|
### Patch Changes
|
package/dist/index.browser.js
CHANGED
|
@@ -1052,7 +1052,7 @@
|
|
|
1052
1052
|
|
|
1053
1053
|
var DEFAULT_API_VERSION = 'v3';
|
|
1054
1054
|
|
|
1055
|
-
var SDK_VERSION = '6.1
|
|
1055
|
+
var SDK_VERSION = '6.2.1';
|
|
1056
1056
|
|
|
1057
1057
|
function datePlusMinutes(minutes) {
|
|
1058
1058
|
if (minutes === void 0) { minutes = 30; }
|
|
@@ -1804,7 +1804,15 @@
|
|
|
1804
1804
|
if (isIframe || !isBrowser || Builder.isPreviewing) {
|
|
1805
1805
|
return;
|
|
1806
1806
|
}
|
|
1807
|
-
var
|
|
1807
|
+
var metadata = typeof contentId === 'object'
|
|
1808
|
+
? __assign({}, contentId) : customProperties && typeof customProperties === 'object'
|
|
1809
|
+
? __assign({}, customProperties) : undefined;
|
|
1810
|
+
if (amount !== undefined) {
|
|
1811
|
+
if (!metadata) {
|
|
1812
|
+
metadata = {};
|
|
1813
|
+
}
|
|
1814
|
+
metadata.amount = amount;
|
|
1815
|
+
}
|
|
1808
1816
|
var useContentId = typeof contentId === 'string' ? contentId : undefined;
|
|
1809
1817
|
if (!useContentId && !contentId && this.contentId) {
|
|
1810
1818
|
useContentId = this.contentId;
|
|
@@ -1818,7 +1826,7 @@
|
|
|
1818
1826
|
variationId: useVariationId && useContentId && useVariationId !== useContentId
|
|
1819
1827
|
? useVariationId
|
|
1820
1828
|
: undefined,
|
|
1821
|
-
meta:
|
|
1829
|
+
meta: metadata,
|
|
1822
1830
|
contentId: useContentId,
|
|
1823
1831
|
}, context);
|
|
1824
1832
|
};
|
|
@@ -2608,6 +2616,14 @@
|
|
|
2608
2616
|
if (this.apiEndpoint === 'content') {
|
|
2609
2617
|
queryParams.includeRefs = true;
|
|
2610
2618
|
}
|
|
2619
|
+
if (this.apiEndpoint === 'query') {
|
|
2620
|
+
if ('enrich' in options && options.enrich !== undefined) {
|
|
2621
|
+
queryParams.enrich = options.enrich;
|
|
2622
|
+
}
|
|
2623
|
+
if (options.enrichOptions) {
|
|
2624
|
+
this.flattenEnrichOptions(options.enrichOptions, 'enrichOptions', queryParams);
|
|
2625
|
+
}
|
|
2626
|
+
}
|
|
2611
2627
|
var properties = [
|
|
2612
2628
|
'prerender',
|
|
2613
2629
|
'extractCss',
|
|
@@ -2635,6 +2651,15 @@
|
|
|
2635
2651
|
}
|
|
2636
2652
|
}
|
|
2637
2653
|
}
|
|
2654
|
+
// Handle enrich and enrichOptions for content endpoint
|
|
2655
|
+
if (this.apiEndpoint === 'content') {
|
|
2656
|
+
if ('enrich' in options && options.enrich !== undefined) {
|
|
2657
|
+
queryParams.enrich = options.enrich;
|
|
2658
|
+
}
|
|
2659
|
+
if (options.enrichOptions) {
|
|
2660
|
+
this.flattenEnrichOptions(options.enrichOptions, 'enrichOptions', queryParams);
|
|
2661
|
+
}
|
|
2662
|
+
}
|
|
2638
2663
|
}
|
|
2639
2664
|
if (this.preview && this.previewingModel === ((_b = queue === null || queue === void 0 ? void 0 : queue[0]) === null || _b === void 0 ? void 0 : _b.model)) {
|
|
2640
2665
|
queryParams.preview = 'true';
|
|
@@ -2793,6 +2818,22 @@
|
|
|
2793
2818
|
}
|
|
2794
2819
|
return Builder.isBrowser && setCookie(name, value, expires);
|
|
2795
2820
|
};
|
|
2821
|
+
/**
|
|
2822
|
+
* Recursively flattens enrichOptions object into dot-notation query parameters
|
|
2823
|
+
* @private
|
|
2824
|
+
*/
|
|
2825
|
+
Builder.prototype.flattenEnrichOptions = function (obj, prefix, result) {
|
|
2826
|
+
for (var _i = 0, _a = Object.entries(obj); _i < _a.length; _i++) {
|
|
2827
|
+
var _b = _a[_i], key = _b[0], value = _b[1];
|
|
2828
|
+
var newKey = "".concat(prefix, ".").concat(key);
|
|
2829
|
+
if (value && typeof value === 'object' && !Array.isArray(value)) {
|
|
2830
|
+
this.flattenEnrichOptions(value, newKey, result);
|
|
2831
|
+
}
|
|
2832
|
+
else {
|
|
2833
|
+
result[newKey] = value;
|
|
2834
|
+
}
|
|
2835
|
+
}
|
|
2836
|
+
};
|
|
2796
2837
|
Builder.prototype.getContent = function (modelName, options) {
|
|
2797
2838
|
if (options === void 0) { options = {}; }
|
|
2798
2839
|
if (!this.apiKey) {
|