@builder.io/sdk 6.1.2 → 6.2.0
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 +60 -2
- package/dist/index.browser.js.map +1 -1
- package/dist/index.cjs.js +60 -2
- package/dist/index.cjs.js.map +1 -1
- package/dist/index.esm.js +60 -2
- package/dist/index.esm.js.map +1 -1
- package/dist/index.umd.js +60 -2
- package/dist/index.umd.js.map +1 -1
- package/dist/package.json +1 -1
- package/dist/src/builder.class.d.ts +50 -1
- package/dist/src/builder.class.js +59 -1
- 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.0
|
|
4
|
+
|
|
5
|
+
### Minor Changes
|
|
6
|
+
|
|
7
|
+
- c729e93: Feat: Add support for `enrichOptions` parameter to control reference enrichment depth and field selection when fetching content.
|
|
8
|
+
|
|
9
|
+
This feature allows you to:
|
|
10
|
+
|
|
11
|
+
- Control the depth level of nested reference enrichment (up to 4 levels)
|
|
12
|
+
- Selectively include/exclude fields for each referenced model type
|
|
13
|
+
- Optimize API responses by fetching only the data you need
|
|
14
|
+
|
|
15
|
+
Example usage:
|
|
16
|
+
|
|
17
|
+
```typescript
|
|
18
|
+
// Basic enrichment with depth control
|
|
19
|
+
await builder.getAll("page", {
|
|
20
|
+
enrich: true,
|
|
21
|
+
enrichOptions: {
|
|
22
|
+
enrichLevel: 2, // Fetch 2 levels of nested references
|
|
23
|
+
},
|
|
24
|
+
});
|
|
25
|
+
|
|
26
|
+
// Advanced: Selective field inclusion per model
|
|
27
|
+
await builder.getAll("page", {
|
|
28
|
+
enrich: true,
|
|
29
|
+
enrichOptions: {
|
|
30
|
+
enrichLevel: 3,
|
|
31
|
+
model: {
|
|
32
|
+
product: {
|
|
33
|
+
fields: "id,name,price",
|
|
34
|
+
omit: "data.internalNotes",
|
|
35
|
+
},
|
|
36
|
+
category: {
|
|
37
|
+
fields: "id,name",
|
|
38
|
+
},
|
|
39
|
+
},
|
|
40
|
+
},
|
|
41
|
+
});
|
|
42
|
+
```
|
|
43
|
+
|
|
44
|
+
## 6.1.4
|
|
45
|
+
|
|
46
|
+
### Patch Changes
|
|
47
|
+
|
|
48
|
+
- 1b1b76e: chore: add back `description` support for inputs
|
|
49
|
+
|
|
50
|
+
## 6.1.3
|
|
51
|
+
|
|
52
|
+
### Patch Changes
|
|
53
|
+
|
|
54
|
+
- 3e864ce: fix: incorrect conversion tracking
|
|
55
|
+
|
|
3
56
|
## 6.1.2
|
|
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.
|
|
1055
|
+
var SDK_VERSION = '6.2.0';
|
|
1056
1056
|
|
|
1057
1057
|
function datePlusMinutes(minutes) {
|
|
1058
1058
|
if (minutes === void 0) { minutes = 30; }
|
|
@@ -1210,6 +1210,7 @@
|
|
|
1210
1210
|
this.hasOverriddenCanTrack = false;
|
|
1211
1211
|
this.apiKey$ = new BehaviorSubject(null);
|
|
1212
1212
|
this.authToken$ = new BehaviorSubject(null);
|
|
1213
|
+
this.contentId$ = new BehaviorSubject(null);
|
|
1213
1214
|
this.userAttributesChanged = new BehaviorSubject(null);
|
|
1214
1215
|
this.editingMode$ = new BehaviorSubject(isIframe);
|
|
1215
1216
|
// TODO: decorator to do this stuff with the get/set (how do with typing too? compiler?)
|
|
@@ -1805,7 +1806,21 @@
|
|
|
1805
1806
|
}
|
|
1806
1807
|
var meta = typeof contentId === 'object' ? contentId : customProperties;
|
|
1807
1808
|
var useContentId = typeof contentId === 'string' ? contentId : undefined;
|
|
1808
|
-
|
|
1809
|
+
if (!useContentId && !contentId && this.contentId) {
|
|
1810
|
+
useContentId = this.contentId;
|
|
1811
|
+
}
|
|
1812
|
+
var useVariationId = variationId;
|
|
1813
|
+
if (!useVariationId && useContentId) {
|
|
1814
|
+
useVariationId = this.getTestCookie(useContentId);
|
|
1815
|
+
}
|
|
1816
|
+
this.track('conversion', {
|
|
1817
|
+
amount: amount,
|
|
1818
|
+
variationId: useVariationId && useContentId && useVariationId !== useContentId
|
|
1819
|
+
? useVariationId
|
|
1820
|
+
: undefined,
|
|
1821
|
+
meta: meta,
|
|
1822
|
+
contentId: useContentId,
|
|
1823
|
+
}, context);
|
|
1809
1824
|
};
|
|
1810
1825
|
Object.defineProperty(Builder.prototype, "isDevelopmentEnv", {
|
|
1811
1826
|
// TODO: set this for QA
|
|
@@ -1883,6 +1898,16 @@
|
|
|
1883
1898
|
enumerable: false,
|
|
1884
1899
|
configurable: true
|
|
1885
1900
|
});
|
|
1901
|
+
Object.defineProperty(Builder.prototype, "contentId", {
|
|
1902
|
+
get: function () {
|
|
1903
|
+
return this.contentId$.value;
|
|
1904
|
+
},
|
|
1905
|
+
set: function (id) {
|
|
1906
|
+
this.contentId$.next(id);
|
|
1907
|
+
},
|
|
1908
|
+
enumerable: false,
|
|
1909
|
+
configurable: true
|
|
1910
|
+
});
|
|
1886
1911
|
Object.defineProperty(Builder.prototype, "authToken", {
|
|
1887
1912
|
get: function () {
|
|
1888
1913
|
return this.authToken$.value;
|
|
@@ -2583,6 +2608,14 @@
|
|
|
2583
2608
|
if (this.apiEndpoint === 'content') {
|
|
2584
2609
|
queryParams.includeRefs = true;
|
|
2585
2610
|
}
|
|
2611
|
+
if (this.apiEndpoint === 'query') {
|
|
2612
|
+
if ('enrich' in options && options.enrich !== undefined) {
|
|
2613
|
+
queryParams.enrich = options.enrich;
|
|
2614
|
+
}
|
|
2615
|
+
if (options.enrichOptions) {
|
|
2616
|
+
this.flattenEnrichOptions(options.enrichOptions, 'enrichOptions', queryParams);
|
|
2617
|
+
}
|
|
2618
|
+
}
|
|
2586
2619
|
var properties = [
|
|
2587
2620
|
'prerender',
|
|
2588
2621
|
'extractCss',
|
|
@@ -2610,6 +2643,15 @@
|
|
|
2610
2643
|
}
|
|
2611
2644
|
}
|
|
2612
2645
|
}
|
|
2646
|
+
// Handle enrich and enrichOptions for content endpoint
|
|
2647
|
+
if (this.apiEndpoint === 'content') {
|
|
2648
|
+
if ('enrich' in options && options.enrich !== undefined) {
|
|
2649
|
+
queryParams.enrich = options.enrich;
|
|
2650
|
+
}
|
|
2651
|
+
if (options.enrichOptions) {
|
|
2652
|
+
this.flattenEnrichOptions(options.enrichOptions, 'enrichOptions', queryParams);
|
|
2653
|
+
}
|
|
2654
|
+
}
|
|
2613
2655
|
}
|
|
2614
2656
|
if (this.preview && this.previewingModel === ((_b = queue === null || queue === void 0 ? void 0 : queue[0]) === null || _b === void 0 ? void 0 : _b.model)) {
|
|
2615
2657
|
queryParams.preview = 'true';
|
|
@@ -2768,6 +2810,22 @@
|
|
|
2768
2810
|
}
|
|
2769
2811
|
return Builder.isBrowser && setCookie(name, value, expires);
|
|
2770
2812
|
};
|
|
2813
|
+
/**
|
|
2814
|
+
* Recursively flattens enrichOptions object into dot-notation query parameters
|
|
2815
|
+
* @private
|
|
2816
|
+
*/
|
|
2817
|
+
Builder.prototype.flattenEnrichOptions = function (obj, prefix, result) {
|
|
2818
|
+
for (var _i = 0, _a = Object.entries(obj); _i < _a.length; _i++) {
|
|
2819
|
+
var _b = _a[_i], key = _b[0], value = _b[1];
|
|
2820
|
+
var newKey = "".concat(prefix, ".").concat(key);
|
|
2821
|
+
if (value && typeof value === 'object' && !Array.isArray(value)) {
|
|
2822
|
+
this.flattenEnrichOptions(value, newKey, result);
|
|
2823
|
+
}
|
|
2824
|
+
else {
|
|
2825
|
+
result[newKey] = value;
|
|
2826
|
+
}
|
|
2827
|
+
}
|
|
2828
|
+
};
|
|
2771
2829
|
Builder.prototype.getContent = function (modelName, options) {
|
|
2772
2830
|
if (options === void 0) { options = {}; }
|
|
2773
2831
|
if (!this.apiKey) {
|