@@ -3,7 +3,7 @@ import { IncomingMessage, ServerResponse } from 'http';
33import { nextTick } from './functions/next-tick.function' ;
44import { QueryString } from './classes/query-string.class' ;
55import { BehaviorSubject } from './classes/observable.class' ;
6- import { getFetch , SimplifiedFetchOptions } from './functions/fetch.function' ;
6+ import { getFetch } from './functions/fetch.function' ;
77import { assign } from './functions/assign.function' ;
88import { throttle } from './functions/throttle.function' ;
99import { Animator } from './classes/animator.class' ;
@@ -495,6 +495,20 @@ export type GetContentOptions = AllowEnrich & {
495495 * draft mode and un-archived. Default is false.
496496 */
497497 includeUnpublished ?: boolean ;
498+
499+ /**
500+ * Options to configure how enrichment works.
501+ * @see {@link https://www.builder.io/c/docs/content-api#code-enrich-options-code }
502+ */
503+ enrichOptions ?: {
504+ /**
505+ * The depth level for enriching references. For example, an enrichLevel of 1
506+ * would return one additional nested model within the original response.
507+ * The maximum level is 4.
508+ */
509+ enrichLevel ?: number ;
510+ [ key : string ] : any ;
511+ } ;
498512} ;
499513
500514export type Class = {
@@ -2698,6 +2712,19 @@ export class Builder {
26982712 queryParams . includeRefs = true ;
26992713 }
27002714
2715+ if ( this . apiEndpoint === 'query' ) {
2716+ for ( const options of queue ) {
2717+ if ( 'enrich' in options && options . enrich !== undefined ) {
2718+ queryParams . enrich = options . enrich ;
2719+ }
2720+ if ( options . enrichOptions ) {
2721+ for ( const [ subKey , subValue ] of Object . entries ( options . enrichOptions ) ) {
2722+ queryParams [ `enrichOptions.${ subKey } ` ] = subValue ;
2723+ }
2724+ }
2725+ }
2726+ }
2727+
27012728 const properties : ( keyof GetContentOptions ) [ ] = [
27022729 'prerender' ,
27032730 'extractCss' ,
@@ -2724,6 +2751,18 @@ export class Builder {
27242751 }
27252752 }
27262753 }
2754+
2755+ // Handle enrich and enrichOptions for content endpoint (add after properties loop)
2756+ if ( this . apiEndpoint === 'content' ) {
2757+ if ( 'enrich' in options && options . enrich !== undefined ) {
2758+ queryParams . enrich = options . enrich ;
2759+ }
2760+ if ( options . enrichOptions ) {
2761+ for ( const [ subKey , subValue ] of Object . entries ( options . enrichOptions ) ) {
2762+ queryParams [ `enrichOptions.${ subKey } ` ] = subValue ;
2763+ }
2764+ }
2765+ }
27272766 }
27282767 if ( this . preview && this . previewingModel === queue ?. [ 0 ] ?. model ) {
27292768 queryParams . preview = 'true' ;
0 commit comments