import { Observable } from 'rxjs' ; import { ODataApi } from '../../api' ; import { $VALUE } from '../../constants' ; import { ODataStructuredType } from '../../schema/structured-type' ; import { PathSegmentNames } from '../../types' ; import { ODataPathSegments } from '../path' ; import { ODataQueryOptions } from '../query' ; import { ODataResource } from '../resource' ; import { ODataOptions } from './options' ; export class ODataValueResource < T > extends ODataResource < T > { static factory < V > ( api , { type , schema , segments , query , } ) { const baseType = type ; const bindingType = schema ?. type ( ) ; const segment = segments . add ( PathSegmentNames . value , $VALUE ) ; if ( schema !== undefined ) segment . type ( schema . type ( ) ) ; else if ( type !== undefined ) segment . type ( type ) ; query ?. clear ( ) ; const value = new ODataValueResource < V > ( api , { segments , query , schema } ) ; if ( bindingType !== undefined && bindingType !== baseType ) { let entitySet = api . findEntitySetForType ( bindingType ) ; if ( entitySet !== undefined ) { value . segment ( ( s ) => s . entitySet ( ) . path ( entitySet ! . name ) ) ; } } return value ; } protected override get ( options ? ) { return super . get ( { responseType : 'value' , ... options } ) ; } param options returns fetch ( options ? ) { return this . get ( options ) ; } }