1- import { HttpMethod } from '../enums/httpMethod' ;
2- import { Model } from '../../../model' ;
3- import { ModelConstructor } from '../../../contracts/modelConstructor' ;
4- import { Scope } from '../scope' ;
5- import { Filter } from '../filter' ;
6- import { FilterOperator } from '../enums/filterOperator' ;
7- import { FilterType } from '../enums/filterType' ;
8- import { Sorter } from '../sorter' ;
9- import { SortDirection } from '../enums/sortDirection' ;
10- import { UrlBuilder } from '../../../builders/urlBuilder' ;
11- import { ExtractModelAttributesType } from '../../../types/extractModelAttributesType' ;
12- import { ExtractModelPersistedAttributesType } from '../../../types/extractModelPersistedAttributesType' ;
13- import { ExtractModelRelationsType } from '../../../types/extractModelRelationsType' ;
14- import { HttpClient } from '../../../httpClient' ;
15- import { AxiosResponse } from 'axios' ;
16- import { Orion } from '../../../orion' ;
17- import { ExtractModelKeyType } from '../../../types/extractModelKeyType' ;
1+ import { HttpMethod } from '../enums/httpMethod' ;
2+ import { Model } from '../../../model' ;
3+ import { ModelConstructor } from '../../../contracts/modelConstructor' ;
4+ import { Scope } from '../scope' ;
5+ import { Filter } from '../filter' ;
6+ import { FilterOperator } from '../enums/filterOperator' ;
7+ import { FilterType } from '../enums/filterType' ;
8+ import { Sorter } from '../sorter' ;
9+ import { SortDirection } from '../enums/sortDirection' ;
10+ import { UrlBuilder } from '../../../builders/urlBuilder' ;
11+ import { ExtractModelAttributesType } from '../../../types/extractModelAttributesType' ;
12+ import {
13+ ExtractModelPersistedAttributesType
14+ } from '../../../types/extractModelPersistedAttributesType' ;
15+ import { ExtractModelRelationsType } from '../../../types/extractModelRelationsType' ;
16+ import { HttpClient } from '../../../httpClient' ;
17+ import { AxiosResponse } from 'axios' ;
18+ import { Orion } from '../../../orion' ;
19+ import { ExtractModelKeyType } from '../../../types/extractModelKeyType' ;
1820
1921export class QueryBuilder <
2022 M extends Model ,
@@ -52,10 +54,10 @@ export class QueryBuilder<
5254 }
5355
5456 public async get ( limit : number = 15 , page : number = 1 ) : Promise < Array < M > > {
55- const response = await this . httpClient . request < { data : Array < AllAttributes & Relations > } > (
57+ const response = await this . httpClient . request < { data : Array < AllAttributes & Relations > } > (
5658 '' ,
5759 HttpMethod . GET ,
58- this . prepareQueryParams ( { limit, page } )
60+ this . prepareQueryParams ( { limit, page} )
5961 ) ;
6062
6163 return response . data . data . map ( ( attributes : AllAttributes & Relations ) => {
@@ -64,14 +66,14 @@ export class QueryBuilder<
6466 }
6567
6668 public async search ( limit : number = 15 , page : number = 1 ) : Promise < Array < M > > {
67- const response = await this . httpClient . request < { data : Array < AllAttributes & Relations > } > (
69+ const response = await this . httpClient . request < { data : Array < AllAttributes & Relations > } > (
6870 '/search' ,
6971 HttpMethod . POST ,
70- this . prepareQueryParams ( { limit, page } ) ,
72+ this . prepareQueryParams ( { limit, page} ) ,
7173 {
7274 scopes : this . scopes ,
7375 filters : this . filters ,
74- search : { value : this . searchValue } ,
76+ search : { value : this . searchValue } ,
7577 sort : this . sorters ,
7678 }
7779 ) ;
@@ -82,7 +84,7 @@ export class QueryBuilder<
8284 }
8385
8486 public async find ( key : Key ) : Promise < M > {
85- const response = await this . httpClient . request < { data : AllAttributes & Relations } > (
87+ const response = await this . httpClient . request < { data : AllAttributes & Relations } > (
8688 `/${ key } ` ,
8789 HttpMethod . GET ,
8890 this . prepareQueryParams ( )
@@ -92,7 +94,7 @@ export class QueryBuilder<
9294 }
9395
9496 public async store ( attributes : Attributes ) : Promise < M > {
95- const response = await this . httpClient . request < { data : AllAttributes & Relations } > (
97+ const response = await this . httpClient . request < { data : AllAttributes & Relations } > (
9698 '' ,
9799 HttpMethod . POST ,
98100 this . prepareQueryParams ( ) ,
@@ -103,7 +105,7 @@ export class QueryBuilder<
103105 }
104106
105107 public async update ( key : Key , attributes : Attributes ) : Promise < M > {
106- const response = await this . httpClient . request < { data : AllAttributes & Relations } > (
108+ const response = await this . httpClient . request < { data : AllAttributes & Relations } > (
107109 `/${ key } ` ,
108110 HttpMethod . PATCH ,
109111 this . prepareQueryParams ( ) ,
@@ -114,17 +116,17 @@ export class QueryBuilder<
114116 }
115117
116118 public async destroy ( key : Key , force : boolean = false ) : Promise < M > {
117- const response = await this . httpClient . request < { data : AllAttributes & Relations } > (
119+ const response = await this . httpClient . request < { data : AllAttributes & Relations } > (
118120 `/${ key } ` ,
119121 HttpMethod . DELETE ,
120- this . prepareQueryParams ( { force } )
122+ this . prepareQueryParams ( { force} )
121123 ) ;
122124
123125 return this . hydrate ( response . data . data , response ) ;
124126 }
125127
126128 public async restore ( key : Key ) : Promise < M > {
127- const response = await this . httpClient . request < { data : AllAttributes & Relations } > (
129+ const response = await this . httpClient . request < { data : AllAttributes & Relations } > (
128130 `/${ key } /restore` ,
129131 HttpMethod . POST ,
130132 this . prepareQueryParams ( )
@@ -189,7 +191,7 @@ export class QueryBuilder<
189191 return relationQueryBuilder . hydrate ( rawRelation , response ) ;
190192 } ) ;
191193 } else {
192- if ( rawValue ) {
194+ if ( rawValue ) {
193195 model . $relations [ field ] = relationQueryBuilder . hydrate ( rawValue , response ) ;
194196 } else {
195197 model . $relations [ field ] = rawValue ;
@@ -205,6 +207,10 @@ export class QueryBuilder<
205207 return model ;
206208 }
207209
210+ public getHttpClient ( ) : HttpClient {
211+ return this . httpClient ;
212+ }
213+
208214 protected prepareQueryParams ( operationParams : any = { } ) : any {
209215 if ( this . fetchOnlyTrashed ) {
210216 operationParams . only_trashed = true ;
0 commit comments