@@ -57,14 +57,16 @@ export type Duration = { type: 'duration'; value: any; }
5757export type Binary = { type : 'binary' ; value : any ; }
5858export type Json = { type : 'json' ; value : any ; }
5959export type Alias = { type : 'alias' ; name : string ; value : any ; }
60- export type Value = string | Date | number | boolean | Raw | Guid | Duration | Binary | Json | Alias ;
60+ export type Decimal = { type : 'decimal' ; value : any ; }
61+ export type Value = string | Date | number | boolean | Raw | Guid | Duration | Binary | Json | Alias | Decimal ;
6162
6263export const raw = ( value : string ) : Raw => ( { type : 'raw' , value } ) ;
6364export const guid = ( value : string ) : Guid => ( { type : 'guid' , value } ) ;
6465export const duration = ( value : string ) : Duration => ( { type : 'duration' , value } ) ;
6566export const binary = ( value : string ) : Binary => ( { type : 'binary' , value } ) ;
6667export const json = ( value : PlainObject ) : Json => ( { type : 'json' , value } ) ;
6768export const alias = ( name : string , value : PlainObject ) : Alias => ( { type : 'alias' , name, value } ) ;
69+ export const decimal = ( value : string ) : Decimal => ( { type : 'decimal' , value } ) ;
6870
6971export type QueryOptions < T > = ExpandOptions < T > & {
7072 search : string ;
@@ -368,29 +370,31 @@ function handleValue(value: Value, aliases?: Alias[]): any {
368370 } else if ( value === null ) {
369371 return value ;
370372 } else if ( typeof value === 'object' ) {
371- if ( value . type === 'raw' ) {
372- return value . value ;
373- } else if ( value . type === 'guid' ) {
373+ switch ( value . type ) {
374+ case 'raw' :
375+ case 'guid' :
374376 return value . value ;
375- } else if ( value . type === 'duration' ) {
377+ case 'duration' :
376378 return `duration'${ value . value } '` ;
377- } else if ( value . type === 'binary' ) {
379+ case 'binary' :
378380 return `binary'${ value . value } '` ;
379- } else if ( value . type === 'alias' ) {
380- // Store
381- if ( Array . isArray ( aliases ) )
382- aliases . push ( value as Alias ) ;
383- return `@${ ( value as Alias ) . name } ` ;
384- } else if ( value . type === 'json' ) {
381+ case 'alias' :
382+ // Store
383+ if ( Array . isArray ( aliases ) )
384+ aliases . push ( value as Alias ) ;
385+ return `@${ ( value as Alias ) . name } ` ;
386+ case 'json' :
385387 return escape ( JSON . stringify ( value . value ) ) ;
386- } else {
387- return Object . entries ( value )
388- . filter ( ( [ , v ] ) => v !== undefined )
389- . map ( ( [ k , v ] ) => `${ k } =${ handleValue ( v as Value , aliases ) } ` ) . join ( ',' ) ;
390- }
388+ case 'decimal' :
389+ return `${ value . value } M` ;
390+ default :
391+ return Object . entries ( value )
392+ . filter ( ( [ , v ] ) => v !== undefined )
393+ . map ( ( [ k , v ] ) => `${ k } =${ handleValue ( v as Value , aliases ) } ` ) . join ( ',' ) ;
391394 }
392- return value ;
393395 }
396+ return value ;
397+ }
394398
395399function buildExpand < T > ( expands : Expand < T > ) : string {
396400 if ( typeof expands === 'number' ) {
0 commit comments