Skip to content

Commit

Permalink
fix: Beta 13 - eliminate barrels so can build apps with AOT (#146)
Browse files Browse the repository at this point in the history
closes #145
  • Loading branch information
wardbell authored May 4, 2018
1 parent 0abab7d commit 31690de
Show file tree
Hide file tree
Showing 32 changed files with 258 additions and 209 deletions.
18 changes: 14 additions & 4 deletions lib/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,22 +1,32 @@
# Angular ngrx-data library ChangeLog

<a name="1.0.0-beta.13"></a>
<a name="6.0.0-beta.1"></a>

# 1.0.0-beta.13 (COMING SOON)
# 6.0.0-beta.1 (COMING SOON)

**BREAKING CHANGE: Update to Angular/RxJS/NgRX v6**

* Converted to RxJS v6.0.1 _without the compat library_
* Converted to Angular v6.0.0
* Converted to NgRX v6.0.0-beta.1

<a name="1.0.0-beta.12"></a>
<a name="1.0.0-beta.13"></a>

# 1.0.0-beta.13 (2018-05-04)

<a name="1.0.0-beta.13"></a>

Fix AOT build error (#145) by removing all barrels.

Beta 12 _did not work_. It only seemed to for the one use case (#135).
Removing all barrels from the top level `lib/src/index.ts` seems to work.
Removed all barrels everywhere to prevent future trouble.

# 1.0.0-beta.12 (2018-05-04)

### Utils and Pluralizer

Fix AOT build error (#135) by moving `export * from './utils';` to the top of `/lib/src/index.ts`.
Fix AOT build error (#135) by moving `export * from './utils';` to the top of `/lib/src/index.ts`. (**Did not work; see Beta 13.**)

These fixes should not break library consumers because they cannot reach into these folders.

Expand Down
2 changes: 1 addition & 1 deletion lib/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "ngrx-data",
"version": "1.0.0-beta.12",
"version": "1.0.0-beta.13",
"repository": "https://github.com/johnpapa/angular-ngrx-data.git",
"license": "MIT",
"peerDependencies": {
Expand Down
2 changes: 1 addition & 1 deletion lib/src/actions/entity-action-guard.spec.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { EntityAction } from './entity-action';
import { EntityActionGuard } from './entity-action-guard';
import { IdSelector, Update } from '../utils';
import { IdSelector, Update } from '../utils/ngrx-entity-models';

describe('EntityActionGuard', () => {
// TODO: write some tests
Expand Down
5 changes: 0 additions & 5 deletions lib/src/actions/index.ts

This file was deleted.

2 changes: 1 addition & 1 deletion lib/src/dataservices/default-data.service.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ import {
EntityHttpResourceUrls,
HttpUrlGenerator
} from './http-url-generator';
import { Update } from '../utils';
import { Update } from '../utils/ngrx-entity-models';

class Hero {
id: number;
Expand Down
8 changes: 5 additions & 3 deletions lib/src/dataservices/entity-data.service.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,13 @@ import { Observable } from 'rxjs/Observable';

import {
createEntityDefinition,
EntityDefinition,
EntityDefinition
} from '../entity-metadata/entity-definition';
import {
EntityMetadata,
EntityMetadataMap,
ENTITY_METADATA_TOKEN
} from '../entity-metadata';
} from '../entity-metadata/entity-metadata';

import {
DefaultDataService,
Expand All @@ -21,7 +23,7 @@ import { HttpUrlGenerator, EntityHttpResourceUrls } from './http-url-generator';
import { EntityDataService } from './entity-data.service';
import { EntityCollectionDataService } from './entity-data.service';
import { QueryParams } from './interfaces';
import { Update } from '../utils';
import { Update } from '../utils/ngrx-entity-models';

// region Test Helpers
///// Test Helpers /////
Expand Down
6 changes: 0 additions & 6 deletions lib/src/dataservices/index.ts

This file was deleted.

50 changes: 27 additions & 23 deletions lib/src/dispatchers/entity-dispatcher.spec.ts
Original file line number Diff line number Diff line change
@@ -1,22 +1,22 @@
import { defaultSelectId } from '../utils';
import { EntityAction, EntityActionFactory, EntityOp } from '../actions';
import { defaultSelectId } from '../utils/utilities';
import { EntityAction, EntityActionFactory } from '../actions/entity-action';
import { EntityOp } from '../actions/entity-op';
import { EntityDispatcher, EntityDispatcherBase } from './entity-dispatcher';
import { EntityDispatcherFactory } from './entity-dispatcher-factory';
import { EntityCommands } from './entity-commands';
import { EntityDispatcherOptions } from './entity-dispatcher';
import { Update } from '../utils';
import { Update } from '../utils/ngrx-entity-models';

class Hero {
id: number;
name: string;
saying?: string;
}

const defaultDispatcherOptions =
new EntityDispatcherFactory(null, null).defaultDispatcherOptions;
const defaultDispatcherOptions = new EntityDispatcherFactory(null, null)
.defaultDispatcherOptions;

describe('EntityDispatcher', () => {

commandDispatchTest(entityDispatcherTestSetup);

function entityDispatcherTestSetup() {
Expand All @@ -25,7 +25,13 @@ describe('EntityDispatcher', () => {

const selectId = defaultSelectId;
const entityActionFactory = new EntityActionFactory();
const dispatcher = new EntityDispatcherBase<Hero>('Hero', entityActionFactory, testStore, selectId, defaultDispatcherOptions)
const dispatcher = new EntityDispatcherBase<Hero>(
'Hero',
entityActionFactory,
testStore,
selectId,
defaultDispatcherOptions
);
return { dispatcher, testStore };
}
});
Expand All @@ -34,14 +40,13 @@ describe('EntityDispatcher', () => {

/** Test that implementer of EntityCommands dispatches properly */
export function commandDispatchTest(
setup: () => { dispatcher: EntityDispatcher<Hero>, testStore: any}
) {

setup: () => { dispatcher: EntityDispatcher<Hero>; testStore: any }
) {
let dispatcher: EntityDispatcher<Hero>;
let testStore: { dispatch: jasmine.Spy };

function dispatchedAction() {
return <EntityAction> testStore.dispatch.calls.argsFor(0)[0];
return <EntityAction>testStore.dispatch.calls.argsFor(0)[0];
}

beforeEach(() => {
Expand All @@ -51,17 +56,16 @@ export function commandDispatchTest(
});

it('#entityName is the expected name of the entity type', () => {
expect(dispatcher.entityName).toBe('Hero')
expect(dispatcher.entityName).toBe('Hero');
});

describe('Save actions', () => {

// By default add and update are pessimistic and delete is optimistic.
// Tests override in the dispatcher method calls as necessary.

describe('(optimistic)', () => {
it('#add(hero) dispatches SAVE_ADD_ONE_OPTIMISTIC', () => {
const hero: Hero = {id: 42, name: 'test'};
const hero: Hero = { id: 42, name: 'test' };
dispatcher.add(hero, /* isOptimistic */ true);

expect(dispatchedAction().op).toBe(EntityOp.SAVE_ADD_ONE_OPTIMISTIC);
Expand All @@ -77,7 +81,7 @@ export function commandDispatchTest(

it('#delete(hero) dispatches SAVE_DELETE_ONE_OPTIMISTIC for the hero.id', () => {
const id = 42;
const hero: Hero = {id, name: 'test'};
const hero: Hero = { id, name: 'test' };

dispatcher.delete(hero); // optimistic by default

Expand All @@ -86,7 +90,7 @@ export function commandDispatchTest(
});

it('#update(hero) dispatches SAVE_UPDATE_ONE_OPTIMISTIC with an update payload', () => {
const hero: Hero = {id: 42, name: 'test'}
const hero: Hero = { id: 42, name: 'test' };
const expectedUpdate: Update<Hero> = { id: 42, changes: hero };

dispatcher.update(hero, /* isOptimistic */ true);
Expand All @@ -98,7 +102,7 @@ export function commandDispatchTest(

describe('(pessimistic)', () => {
it('#add(hero) dispatches SAVE_ADD', () => {
const hero: Hero = {id: 42, name: 'test'};
const hero: Hero = { id: 42, name: 'test' };
dispatcher.add(hero); // pessimistic by default

expect(dispatchedAction().op).toBe(EntityOp.SAVE_ADD_ONE);
Expand All @@ -114,7 +118,7 @@ export function commandDispatchTest(

it('#delete(hero) dispatches SAVE_DELETE for the hero.id', () => {
const id = 42;
const hero: Hero = {id, name: 'test'};
const hero: Hero = { id, name: 'test' };

dispatcher.delete(hero, /* isOptimistic */ false); // optimistic by default

Expand All @@ -123,7 +127,7 @@ export function commandDispatchTest(
});

it('#update(hero) dispatches SAVE_UPDATE with an update payload', () => {
const hero: Hero = {id: 42, name: 'test'}
const hero: Hero = { id: 42, name: 'test' };
const expectedUpdate: Update<Hero> = { id: 42, changes: hero };

dispatcher.update(hero); // pessimistic by default
Expand All @@ -150,19 +154,19 @@ export function commandDispatchTest(
});

it('#getWithQuery(QueryParams) dispatches QUERY_MANY', () => {
dispatcher.getWithQuery({name: 'B'});
dispatcher.getWithQuery({ name: 'B' });

expect(dispatchedAction().op).toBe(EntityOp.QUERY_MANY);
expect(dispatchedAction().entityName).toBe('Hero');
expect(dispatchedAction().payload).toEqual({name: 'B'}, 'params')
expect(dispatchedAction().payload).toEqual({ name: 'B' }, 'params');
});

it('#getWithQuery(string) dispatches QUERY_MANY', () => {
dispatcher.getWithQuery('name=B');

expect(dispatchedAction().op).toBe(EntityOp.QUERY_MANY);
expect(dispatchedAction().entityName).toBe('Hero');
expect(dispatchedAction().payload).toEqual('name=B', 'params')
expect(dispatchedAction().payload).toEqual('name=B', 'params');
});
});

Expand Down Expand Up @@ -215,7 +219,7 @@ export function commandDispatchTest(

it('#removeOneFromCache(entity) dispatches REMOVE_ONE', () => {
const id = 42;
const hero: Hero = {id, name: 'test'};
const hero: Hero = { id, name: 'test' };
dispatcher.removeOneFromCache(hero);

expect(dispatchedAction().op).toBe(EntityOp.REMOVE_ONE);
Expand Down
3 changes: 0 additions & 3 deletions lib/src/dispatchers/index.ts

This file was deleted.

27 changes: 14 additions & 13 deletions lib/src/effects/entity-effects.marbles.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,27 +4,28 @@ import { TestBed } from '@angular/core/testing';
import { cold, hot } from 'jasmine-marbles';
import { Observable } from 'rxjs/Observable';

import {
EntityAction,
EntityActionFactory,
EntityActions,
EntityOp,
OP_ERROR
} from '../actions';
import { EntityAction, EntityActionFactory } from '../actions/entity-action';
import { EntityActions } from '../actions/entity-actions';
import { EntityOp, OP_ERROR } from '../actions/entity-op';

import {
DataServiceError,
EntityCollectionDataService,
EntityActionDataServiceError,
EntityDataService,
HttpMethods,
EntityDataService
} from '../dataservices/entity-data.service';
import {
DataServiceError,
EntityActionDataServiceError
} from '../dataservices/data-service-error';
import {
PersistenceResultHandler,
DefaultPersistenceResultHandler
} from '../dataservices';
} from '../dataservices/persistence-result-handler.service';
import { HttpMethods } from '../dataservices/interfaces';

import { EntityEffects } from './entity-effects';

import { Logger, Update } from '../utils';
import { Logger } from '../utils/interfaces';
import { Update } from '../utils/ngrx-entity-models';

export class TestEntityActions extends EntityActions {
set stream(source: Observable<any>) {
Expand Down
27 changes: 14 additions & 13 deletions lib/src/effects/entity-effects.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,27 +6,28 @@ import { ErrorObservable } from 'rxjs/observable/ErrorObservable';
import { Observable } from 'rxjs/Observable';
import { delay, first, merge } from 'rxjs/operators';

import {
EntityAction,
EntityActionFactory,
EntityActions,
EntityOp,
OP_ERROR
} from '../actions';
import { EntityAction, EntityActionFactory } from '../actions/entity-action';
import { EntityActions } from '../actions/entity-actions';
import { EntityOp, OP_ERROR } from '../actions/entity-op';

import {
DataServiceError,
EntityCollectionDataService,
EntityDataService,
EntityActionDataServiceError,
HttpMethods,
EntityDataService
} from '../dataservices/entity-data.service';
import {
DataServiceError,
EntityActionDataServiceError
} from '../dataservices/data-service-error';
import {
PersistenceResultHandler,
DefaultPersistenceResultHandler
} from '../dataservices';
} from '../dataservices/persistence-result-handler.service';
import { HttpMethods } from '../dataservices/interfaces';

import { EntityEffects } from './entity-effects';

import { Logger, Update } from '../utils';
import { Logger } from '../utils/interfaces';
import { Update } from '../utils/ngrx-entity-models';

export class TestEntityActions extends EntityActions {
set stream(source: Observable<any>) {
Expand Down
1 change: 0 additions & 1 deletion lib/src/effects/index.ts

This file was deleted.

4 changes: 2 additions & 2 deletions lib/src/entity-metadata/entity-definition.spec.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { EntityMetadata } from './entity-metadata';
import { EntityFilterFn } from './entity-filters';
import { IdSelector, Comparer } from '../utils';
import { EntitySelectors } from '../selectors';
import { IdSelector, Comparer } from '../utils/ngrx-entity-models';
import { EntitySelectors } from '../selectors/entity-selectors';

import { createEntityDefinition } from './entity-definition';

Expand Down
4 changes: 0 additions & 4 deletions lib/src/entity-metadata/index.ts

This file was deleted.

13 changes: 6 additions & 7 deletions lib/src/entity-service/entity-service.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,12 @@ import { Action, StoreModule, Store } from '@ngrx/store';

import { Subject } from 'rxjs/Subject';

import {
EntityAction,
EntityActions,
EntityActionFactory,
EntityOp
} from '../actions';
import { EntityCache, EntityCollection } from '../reducers';
import { EntityAction, EntityActionFactory } from '../actions/entity-action';
import { EntityActions } from '../actions/entity-actions';
import { EntityOp } from '../actions/entity-op';

import { EntityCache } from '../reducers/entity-cache';
import { EntityCollection } from '../reducers/entity-collection';
import { ENTITY_METADATA_TOKEN } from '../entity-metadata/entity-metadata';
import {
EntityService,
Expand Down
3 changes: 0 additions & 3 deletions lib/src/entity-service/index.ts

This file was deleted.

Loading

0 comments on commit 31690de

Please sign in to comment.