@ngrx/data 15.3.0 → 15.4.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/esm2020/src/dataservices/default-data.service.mjs +24 -21
- package/fesm2015/ngrx-data.mjs +20 -21
- package/fesm2015/ngrx-data.mjs.map +1 -1
- package/fesm2020/ngrx-data.mjs +23 -20
- package/fesm2020/ngrx-data.mjs.map +1 -1
- package/package.json +4 -4
- package/schematics-core/utility/libs-version.js +1 -1
- package/schematics-core/utility/libs-version.js.map +1 -1
package/fesm2020/ngrx-data.mjs
CHANGED
|
@@ -702,26 +702,26 @@ class DefaultDataService {
|
|
|
702
702
|
}
|
|
703
703
|
add(entity, options) {
|
|
704
704
|
const entityOrError = entity || new Error(`No "${this.entityName}" entity to add`);
|
|
705
|
-
return this.execute('POST', this.entityUrl, entityOrError, options);
|
|
705
|
+
return this.execute('POST', this.entityUrl, entityOrError, null, options);
|
|
706
706
|
}
|
|
707
707
|
delete(key, options) {
|
|
708
708
|
let err;
|
|
709
709
|
if (key == null) {
|
|
710
710
|
err = new Error(`No "${this.entityName}" key to delete`);
|
|
711
711
|
}
|
|
712
|
-
return this.execute('DELETE', this.entityUrl + key, err, options).pipe(
|
|
712
|
+
return this.execute('DELETE', this.entityUrl + key, err, null, options).pipe(
|
|
713
713
|
// forward the id of deleted entity as the result of the HTTP DELETE
|
|
714
714
|
map((result) => key));
|
|
715
715
|
}
|
|
716
716
|
getAll(options) {
|
|
717
|
-
return this.execute('GET', this.entitiesUrl, options);
|
|
717
|
+
return this.execute('GET', this.entitiesUrl, null, options);
|
|
718
718
|
}
|
|
719
719
|
getById(key, options) {
|
|
720
720
|
let err;
|
|
721
721
|
if (key == null) {
|
|
722
722
|
err = new Error(`No "${this.entityName}" key to get`);
|
|
723
723
|
}
|
|
724
|
-
return this.execute('GET', this.entityUrl + key, err, options);
|
|
724
|
+
return this.execute('GET', this.entityUrl + key, err, null, options);
|
|
725
725
|
}
|
|
726
726
|
getWithQuery(queryParams, options) {
|
|
727
727
|
const qParams = typeof queryParams === 'string'
|
|
@@ -735,20 +735,20 @@ class DefaultDataService {
|
|
|
735
735
|
const updateOrError = id == null
|
|
736
736
|
? new Error(`No "${this.entityName}" update data or id`)
|
|
737
737
|
: update.changes;
|
|
738
|
-
return this.execute('PUT', this.entityUrl + id, updateOrError, options);
|
|
738
|
+
return this.execute('PUT', this.entityUrl + id, updateOrError, null, options);
|
|
739
739
|
}
|
|
740
740
|
// Important! Only call if the backend service supports upserts as a POST to the target URL
|
|
741
741
|
upsert(entity, options) {
|
|
742
742
|
const entityOrError = entity || new Error(`No "${this.entityName}" entity to upsert`);
|
|
743
|
-
return this.execute('POST', this.entityUrl, entityOrError, options);
|
|
743
|
+
return this.execute('POST', this.entityUrl, entityOrError, null, options);
|
|
744
744
|
}
|
|
745
745
|
execute(method, url, data, // data, error, or undefined/null
|
|
746
746
|
options, // options or undefined/null
|
|
747
747
|
httpOptions // these override any options passed via options
|
|
748
748
|
) {
|
|
749
|
-
let
|
|
749
|
+
let entityActionHttpClientOptions = undefined;
|
|
750
750
|
if (httpOptions) {
|
|
751
|
-
|
|
751
|
+
entityActionHttpClientOptions = {
|
|
752
752
|
headers: httpOptions?.httpHeaders
|
|
753
753
|
? new HttpHeaders(httpOptions?.httpHeaders)
|
|
754
754
|
: undefined,
|
|
@@ -757,21 +757,24 @@ class DefaultDataService {
|
|
|
757
757
|
: undefined,
|
|
758
758
|
};
|
|
759
759
|
}
|
|
760
|
+
// Now we may have:
|
|
761
|
+
// options: containing headers, params, or any other allowed http options already in angular's api
|
|
762
|
+
// entityActionHttpClientOptions: headers and params in angular's api
|
|
763
|
+
// We therefore need to merge these so that the action ones override the
|
|
764
|
+
// existing keys where applicable.
|
|
760
765
|
// If any options have been specified, pass them to http client. Note
|
|
761
766
|
// the new http options, if specified, will override any options passed
|
|
762
767
|
// from the deprecated options parameter
|
|
763
768
|
let mergedOptions = undefined;
|
|
764
|
-
if (options ||
|
|
765
|
-
if (isDevMode() && options &&
|
|
769
|
+
if (options || entityActionHttpClientOptions) {
|
|
770
|
+
if (isDevMode() && options && entityActionHttpClientOptions) {
|
|
766
771
|
console.warn('@ngrx/data: options.httpParams will be merged with queryParams when both are are provided to getWithQuery(). In the event of a conflict HttpOptions.httpParams will override queryParams`. The queryParams parameter of getWithQuery() will be removed in next major release.');
|
|
767
772
|
}
|
|
768
|
-
mergedOptions = {
|
|
769
|
-
|
|
770
|
-
|
|
771
|
-
|
|
772
|
-
|
|
773
|
-
mergedOptions.params = ngHttpClientOptions?.params ?? options?.params;
|
|
774
|
-
}
|
|
773
|
+
mergedOptions = {
|
|
774
|
+
...options,
|
|
775
|
+
headers: entityActionHttpClientOptions?.headers ?? options?.headers,
|
|
776
|
+
params: entityActionHttpClientOptions?.params ?? options?.params,
|
|
777
|
+
};
|
|
775
778
|
}
|
|
776
779
|
const req = {
|
|
777
780
|
method,
|
|
@@ -785,7 +788,7 @@ class DefaultDataService {
|
|
|
785
788
|
let result$;
|
|
786
789
|
switch (method) {
|
|
787
790
|
case 'DELETE': {
|
|
788
|
-
result$ = this.http.delete(url,
|
|
791
|
+
result$ = this.http.delete(url, mergedOptions);
|
|
789
792
|
if (this.saveDelay) {
|
|
790
793
|
result$ = result$.pipe(delay(this.saveDelay));
|
|
791
794
|
}
|
|
@@ -799,7 +802,7 @@ class DefaultDataService {
|
|
|
799
802
|
break;
|
|
800
803
|
}
|
|
801
804
|
case 'POST': {
|
|
802
|
-
result$ = this.http.post(url, data,
|
|
805
|
+
result$ = this.http.post(url, data, mergedOptions);
|
|
803
806
|
if (this.saveDelay) {
|
|
804
807
|
result$ = result$.pipe(delay(this.saveDelay));
|
|
805
808
|
}
|
|
@@ -807,7 +810,7 @@ class DefaultDataService {
|
|
|
807
810
|
}
|
|
808
811
|
// N.B.: It must return an Update<T>
|
|
809
812
|
case 'PUT': {
|
|
810
|
-
result$ = this.http.put(url, data,
|
|
813
|
+
result$ = this.http.put(url, data, mergedOptions);
|
|
811
814
|
if (this.saveDelay) {
|
|
812
815
|
result$ = result$.pipe(delay(this.saveDelay));
|
|
813
816
|
}
|