File tree Expand file tree Collapse file tree 4 files changed +48
-9
lines changed Expand file tree Collapse file tree 4 files changed +48
-9
lines changed Original file line number Diff line number Diff line change @@ -1584,16 +1584,28 @@ class BaseService extends RequestBuilder {
1584
1584
} ;
1585
1585
}
1586
1586
async create ( model , params ) {
1587
- if ( params ) { }
1587
+ if ( params ) {
1588
+ }
1588
1589
const jsonApiSerializer = new JsonApiSerializer ( this . hydrator . getModelMap ( ) ) ;
1589
1590
const payload = jsonApiSerializer . buildCreatePayload ( model ) ;
1590
- return await this . client . makePostRequest ( this . endpoint , payload ) ;
1591
+ let resp = await this . client . makePostRequest ( this . endpoint , payload ) ;
1592
+ const hydratedData = this . hydrator . hydrateResponse ( resp . data , resp . included || [ ] ) ;
1593
+ return {
1594
+ ...resp ,
1595
+ data : hydratedData
1596
+ } ;
1591
1597
}
1592
1598
async update ( id , model , params ) {
1593
- if ( params ) { }
1599
+ if ( params ) {
1600
+ }
1594
1601
const jsonApiSerializer = new JsonApiSerializer ( this . hydrator . getModelMap ( ) ) ;
1595
1602
const payload = jsonApiSerializer . buildUpdatePayload ( model ) ;
1596
- return await this . client . makePatchRequest ( `${ this . endpoint } /${ id } ` , payload ) ;
1603
+ let resp = await this . client . makePatchRequest ( `${ this . endpoint } /${ id } ` , payload ) ;
1604
+ const hydratedData = this . hydrator . hydrateResponse ( resp . data , resp . included || [ ] ) ;
1605
+ return {
1606
+ ...resp ,
1607
+ data : hydratedData
1608
+ } ;
1597
1609
}
1598
1610
async stats ( options ) {
1599
1611
const statsEndpoint = `${ this . endpoint } /stats` ;
@@ -2286,6 +2298,9 @@ class ClientConfig {
2286
2298
}
2287
2299
// src/models/Organisation.ts
2288
2300
class Organisation extends BaseModel {
2301
+ constructor ( ) {
2302
+ super ( ...arguments ) ;
2303
+ }
2289
2304
type = "organisations" ;
2290
2305
static relationships = [ ] ;
2291
2306
}
Original file line number Diff line number Diff line change @@ -31,14 +31,24 @@ export class BaseService extends RequestBuilder {
31
31
}
32
32
const jsonApiSerializer = new JsonApiSerializer ( this . hydrator . getModelMap ( ) ) ;
33
33
const payload = jsonApiSerializer . buildCreatePayload ( model ) ;
34
- return await this . client . makePostRequest ( this . endpoint , payload ) ;
34
+ let resp = await this . client . makePostRequest ( this . endpoint , payload ) ;
35
+ const hydratedData = this . hydrator . hydrateResponse ( resp . data , resp . included || [ ] ) ;
36
+ return {
37
+ ...resp ,
38
+ data : hydratedData ,
39
+ } ;
35
40
}
36
41
async update ( id , model , params ) {
37
42
if ( params ) {
38
43
}
39
44
const jsonApiSerializer = new JsonApiSerializer ( this . hydrator . getModelMap ( ) ) ;
40
45
const payload = jsonApiSerializer . buildUpdatePayload ( model ) ;
41
- return await this . client . makePatchRequest ( `${ this . endpoint } /${ id } ` , payload ) ;
46
+ let resp = await this . client . makePatchRequest ( `${ this . endpoint } /${ id } ` , payload ) ;
47
+ const hydratedData = this . hydrator . hydrateResponse ( resp . data , resp . included || [ ] ) ;
48
+ return {
49
+ ...resp ,
50
+ data : hydratedData ,
51
+ } ;
42
52
}
43
53
async stats ( options ) {
44
54
const statsEndpoint = `${ this . endpoint } /stats` ;
Original file line number Diff line number Diff line change 4
4
"type" : " git" ,
5
5
"url" : " https://github.com/ctrl-hub/sdk.ts"
6
6
},
7
- "version" : " 0.1.142 " ,
7
+ "version" : " 0.1.143 " ,
8
8
"main" : " dist/index.js" ,
9
9
"types" : " dist/index.d.ts" ,
10
10
"type" : " module" ,
Original file line number Diff line number Diff line change @@ -46,15 +46,29 @@ export class BaseService<T extends Model> extends RequestBuilder {
46
46
}
47
47
const jsonApiSerializer = new JsonApiSerializer ( this . hydrator . getModelMap ( ) ) ;
48
48
const payload = jsonApiSerializer . buildCreatePayload ( model ) ;
49
- return await this . client . makePostRequest ( this . endpoint , payload ) ;
49
+ let resp = await this . client . makePostRequest ( this . endpoint , payload ) ;
50
+
51
+ const hydratedData = this . hydrator . hydrateResponse < T > ( resp . data as JsonData | JsonData [ ] , resp . included || [ ] ) ;
52
+
53
+ return {
54
+ ...resp ,
55
+ data : hydratedData ,
56
+ } as InternalResponse < T > ;
50
57
}
51
58
52
59
async update ( id : string , model : Model , params ?: unknown ) : Promise < InternalResponse < T > > {
53
60
if ( params ) {
54
61
}
55
62
const jsonApiSerializer = new JsonApiSerializer ( this . hydrator . getModelMap ( ) ) ;
56
63
const payload = jsonApiSerializer . buildUpdatePayload ( model ) ;
57
- return await this . client . makePatchRequest ( `${ this . endpoint } /${ id } ` , payload ) ;
64
+ let resp = await this . client . makePatchRequest ( `${ this . endpoint } /${ id } ` , payload ) ;
65
+
66
+ const hydratedData = this . hydrator . hydrateResponse < T > ( resp . data as JsonData | JsonData [ ] , resp . included || [ ] ) ;
67
+
68
+ return {
69
+ ...resp ,
70
+ data : hydratedData ,
71
+ } as InternalResponse < T > ;
58
72
}
59
73
60
74
async stats < R = any > ( options ?: RequestOptionsType ) : Promise < InternalResponse < R > > {
You can’t perform that action at this time.
0 commit comments