@ngrx/data 13.0.1 → 13.2.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.
@@ -620,10 +620,10 @@ class DefaultHttpUrlGenerator {
620
620
  * @param entityName {string} Name of the entity type, e.g, 'Hero'
621
621
  * @param root {string} Root path to the resource, e.g., 'some-api`
622
622
  */
623
- getResourceUrls(entityName, root) {
623
+ getResourceUrls(entityName, root, trailingSlashEndpoints = false) {
624
624
  let resourceUrls = this.knownHttpResourceUrls[entityName];
625
625
  if (!resourceUrls) {
626
- const nRoot = normalizeRoot(root);
626
+ const nRoot = trailingSlashEndpoints ? root : normalizeRoot(root);
627
627
  resourceUrls = {
628
628
  entityResourceUrl: `${nRoot}/${entityName}/`.toLowerCase(),
629
629
  collectionResourceUrl: `${nRoot}/${this.pluralizer.pluralize(entityName)}/`.toLowerCase(),
@@ -638,8 +638,8 @@ class DefaultHttpUrlGenerator {
638
638
  * @param root {string} Root path to the resource, e.g., 'some-api`
639
639
  * @returns complete path to resource, e.g, 'some-api/hero'
640
640
  */
641
- entityResource(entityName, root) {
642
- return this.getResourceUrls(entityName, root).entityResourceUrl;
641
+ entityResource(entityName, root, trailingSlashEndpoints) {
642
+ return this.getResourceUrls(entityName, root, trailingSlashEndpoints).entityResourceUrl;
643
643
  }
644
644
  /**
645
645
  * Create the path to a multiple entity (collection) resource
@@ -685,11 +685,12 @@ class DefaultDataService {
685
685
  this.getDelay = 0;
686
686
  this.saveDelay = 0;
687
687
  this.timeout = 0;
688
+ this.trailingSlashEndpoints = false;
688
689
  this._name = `${entityName} DefaultDataService`;
689
690
  this.entityName = entityName;
690
- const { root = 'api', delete404OK = true, getDelay = 0, saveDelay = 0, timeout: to = 0, } = config || {};
691
+ const { root = 'api', delete404OK = true, getDelay = 0, saveDelay = 0, timeout: to = 0, trailingSlashEndpoints = false, } = config || {};
691
692
  this.delete404OK = delete404OK;
692
- this.entityUrl = httpUrlGenerator.entityResource(entityName, root);
693
+ this.entityUrl = httpUrlGenerator.entityResource(entityName, root, trailingSlashEndpoints);
693
694
  this.entitiesUrl = httpUrlGenerator.collectionResource(entityName, root);
694
695
  this.getDelay = getDelay;
695
696
  this.saveDelay = saveDelay;
@@ -779,7 +780,7 @@ class DefaultDataService {
779
780
  }
780
781
  default: {
781
782
  const error = new Error('Unimplemented HTTP method, ' + method);
782
- result$ = throwError(error);
783
+ result$ = throwError(() => error);
783
784
  }
784
785
  }
785
786
  if (this.timeout) {
@@ -794,7 +795,7 @@ class DefaultDataService {
794
795
  return ok;
795
796
  }
796
797
  const error = new DataServiceError(err, reqData);
797
- return throwError(error);
798
+ return throwError(() => error);
798
799
  };
799
800
  }
800
801
  handleDelete404(error, reqData) {
@@ -1004,7 +1005,7 @@ class EntityCacheDataService {
1004
1005
  handleError(reqData) {
1005
1006
  return (err) => {
1006
1007
  const error = new DataServiceError(err, reqData);
1007
- return throwError(error);
1008
+ return throwError(() => error);
1008
1009
  };
1009
1010
  }
1010
1011
  /**
@@ -1079,8 +1080,8 @@ class EntityCacheDataService {
1079
1080
  getIdSelector(entityName) {
1080
1081
  let idSelector = this.idSelectors[entityName];
1081
1082
  if (!idSelector) {
1082
- idSelector = this.entityDefinitionService.getDefinition(entityName)
1083
- .selectId;
1083
+ idSelector =
1084
+ this.entityDefinitionService.getDefinition(entityName).selectId;
1084
1085
  this.idSelectors[entityName] = idSelector;
1085
1086
  }
1086
1087
  return idSelector;
@@ -1399,10 +1400,10 @@ class EntityCacheDispatcher {
1399
1400
  act.type === EntityCacheAction.SAVE_ENTITIES_ERROR ||
1400
1401
  act.type === EntityCacheAction.SAVE_ENTITIES_CANCEL), filter((act) => crid === act.payload.correlationId), take(1), mergeMap((act) => {
1401
1402
  return act.type === EntityCacheAction.SAVE_ENTITIES_CANCEL
1402
- ? throwError(new PersistanceCanceled(act.payload.reason))
1403
+ ? throwError(() => new PersistanceCanceled(act.payload.reason))
1403
1404
  : act.type === EntityCacheAction.SAVE_ENTITIES_SUCCESS
1404
1405
  ? of(act.payload.changeSet)
1405
- : throwError(act.payload);
1406
+ : throwError(() => act.payload);
1406
1407
  }));
1407
1408
  }
1408
1409
  }
@@ -1788,10 +1789,10 @@ class EntityDispatcherBase {
1788
1789
  }), take(1), mergeMap((act) => {
1789
1790
  const { entityOp } = act.payload;
1790
1791
  return entityOp === EntityOp.CANCEL_PERSIST
1791
- ? throwError(new PersistanceCanceled(act.payload.data))
1792
+ ? throwError(() => new PersistanceCanceled(act.payload.data))
1792
1793
  : entityOp.endsWith(OP_SUCCESS)
1793
1794
  ? of(act.payload.data)
1794
- : throwError(act.payload.data.error);
1795
+ : throwError(() => act.payload.data.error);
1795
1796
  }));
1796
1797
  }
1797
1798
  setQueryEntityActionOptions(options) {
@@ -4934,3 +4935,4 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "13.0.0", ngImpor
4934
4935
  */
4935
4936
 
4936
4937
  export { ChangeSetItemFactory, ChangeSetOperation, ChangeType, ClearCollections, CorrelationIdGenerator, DataServiceError, DefaultDataService, DefaultDataServiceConfig, DefaultDataServiceFactory, DefaultHttpUrlGenerator, DefaultLogger, DefaultPersistenceResultHandler, DefaultPluralizer, ENTITY_CACHE_META_REDUCERS, ENTITY_CACHE_NAME, ENTITY_CACHE_NAME_TOKEN, ENTITY_CACHE_SELECTOR_TOKEN, ENTITY_COLLECTION_META_REDUCERS, ENTITY_METADATA_TOKEN, EntityActionFactory, EntityActionGuard, EntityCacheAction, EntityCacheDataService, EntityCacheDispatcher, EntityCacheEffects, EntityCacheReducerFactory, EntityChangeTrackerBase, EntityCollectionCreator, EntityCollectionReducerFactory, EntityCollectionReducerMethods, EntityCollectionReducerMethodsFactory, EntityCollectionReducerRegistry, EntityCollectionServiceBase, EntityCollectionServiceElementsFactory, EntityCollectionServiceFactory, EntityDataModule, EntityDataModuleWithoutEffects, EntityDataService, EntityDefinitionService, EntityDispatcherBase, EntityDispatcherDefaultOptions, EntityDispatcherFactory, EntityEffects, EntityHttpResourceUrls, EntityOp, EntitySelectors$Factory, EntitySelectorsFactory, EntityServices, EntityServicesBase, EntityServicesElements, HttpUrlGenerator, INITIAL_ENTITY_CACHE_STATE, LoadCollections, Logger, MergeQuerySet, MergeStrategy, OP_ERROR, OP_SUCCESS, PLURAL_NAMES_TOKEN, PersistanceCanceled, PersistenceResultHandler, Pluralizer, PropsFilterFnFactory, SaveEntities, SaveEntitiesCancel, SaveEntitiesCanceled, SaveEntitiesError, SaveEntitiesSuccess, SetEntityCache, changeSetItemFactory, createEmptyEntityCollection, createEntityCacheSelector, createEntityDefinition, defaultSelectId, entityCacheSelectorProvider, excludeEmptyChangeSetItems, flattenArgs, getGuid, getGuidComb, guidComparer, makeErrorOp, makeSuccessOp, normalizeRoot, ofEntityOp, ofEntityType, persistOps, toUpdateFactory };
4938
+ //# sourceMappingURL=ngrx-data.mjs.map