@builder.io/sdk 6.1.3 → 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 +47 -0
- package/dist/index.browser.js +34 -1
- package/dist/index.browser.js.map +1 -1
- package/dist/index.cjs.js +34 -1
- package/dist/index.cjs.js.map +1 -1
- package/dist/index.esm.js +34 -1
- package/dist/index.esm.js.map +1 -1
- package/dist/index.umd.js +34 -1
- 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 +33 -0
- 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,52 @@
|
|
|
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
|
+
|
|
3
50
|
## 6.1.3
|
|
4
51
|
|
|
5
52
|
### 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; }
|
|
@@ -2608,6 +2608,14 @@
|
|
|
2608
2608
|
if (this.apiEndpoint === 'content') {
|
|
2609
2609
|
queryParams.includeRefs = true;
|
|
2610
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
|
+
}
|
|
2611
2619
|
var properties = [
|
|
2612
2620
|
'prerender',
|
|
2613
2621
|
'extractCss',
|
|
@@ -2635,6 +2643,15 @@
|
|
|
2635
2643
|
}
|
|
2636
2644
|
}
|
|
2637
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
|
+
}
|
|
2638
2655
|
}
|
|
2639
2656
|
if (this.preview && this.previewingModel === ((_b = queue === null || queue === void 0 ? void 0 : queue[0]) === null || _b === void 0 ? void 0 : _b.model)) {
|
|
2640
2657
|
queryParams.preview = 'true';
|
|
@@ -2793,6 +2810,22 @@
|
|
|
2793
2810
|
}
|
|
2794
2811
|
return Builder.isBrowser && setCookie(name, value, expires);
|
|
2795
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
|
+
};
|
|
2796
2829
|
Builder.prototype.getContent = function (modelName, options) {
|
|
2797
2830
|
if (options === void 0) { options = {}; }
|
|
2798
2831
|
if (!this.apiKey) {
|