Skip to content

Commit cd19510

Browse files
Jon Ristajrista
authored andcommitted
fix: removed uuidv4 dep and resolved umd duplicate code warnings
- Removed uuidv4 as dependency (export mechanism broken since first used in Nov, 2019!) + Added small, fast built-in uuid function * Resolved duplicate dropped variable warnings for umd bundle
1 parent d4329b4 commit cd19510

File tree

11 files changed

+142
-96
lines changed

11 files changed

+142
-96
lines changed

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77

88
# dependencies
99
/node_modules
10+
/projects/ngrx-auto-entity/node_modules
1011

1112
# IDEs and editors
1213
/.idea

CHANGELOG.md

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,19 @@
1+
<a name="0.3.1"></a>
2+
3+
# [0.3.1](https://github.com/briebug/ngrx-auto-entity/compare/0.3.0...0.3.1) Beta (2020-01-07)
4+
5+
Bug fix release! We apologize for any inconvenience the v0.3.0 release may have caused. We introduced
6+
a correlation Id into our actions, and relied on `uuidv4` to handle their generation. Turned out, uuidv4
7+
just recently went through a breaking change, and the default import was removed. This caused problems,
8+
dependent upon which version of uuidv4 was used by the application using ngrx-ae.
9+
10+
We have replaced uuidv4 with internal code. Fast, small uuid function acquired from the following gist:
11+
12+
https://gist.github.com/LeverOne/1308368
13+
14+
### Bug Fix
15+
- **[uuidv4](https://www.npmjs.com/package/uuidv4):** Removed in favor of small, fast built in function
16+
117
<a name="0.3.0"></a>
218

319
# [0.3.0](https://github.com/briebug/ngrx-auto-entity/compare/0.2.8...0.3.0) Beta (2019-11-26)

README.md

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,13 @@ Automatic entities for [@ngrx](https://github.com/ngrx/platform)! Simplifying re
1414
enhance it's functionality, identify and eliminate bugs, optimize it's performance. If you
1515
find any errors in this documentation, or bugs within the library, please let us know!**
1616

17+
**APOLOGIES: For those using NgRx Auto-Entity, we apologize for issues with the recent v0.3.0
18+
release! We used an npm module, uuidv4, and back in november our usage of it was working. It
19+
appears as though that library was changed fairly significantly since then, with the default
20+
import removed. That lead to issues for some people, depending on the version of uuidv4 they
21+
installed/had installed. We have dropped uuidv4 and are now using a small, fast built-in function
22+
instead in v0.3.1 and onward, which should resolve the issues. Again, we apologize for the inconvenience!**
23+
1724
## What is it?
1825

1926
NgRX Auto-Entity aims to provide a seamless means of dealing with standard entity actions and

package-lock.json

Lines changed: 9 additions & 3 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

projects/ngrx-auto-entity/README.md

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,13 @@ Automatic entities for [@ngrx](https://github.com/ngrx/platform)! Simplifying re
1414
enhance it's functionality, identify and eliminate bugs, optimize it's performance. If you
1515
find any errors in this documentation, or bugs within the library, please let us know!**
1616

17+
**APOLOGIES: For those using NgRx Auto-Entity, we apologize for issues with the recent v0.3.0
18+
release! We used an npm module, uuidv4, and back in november our usage of it was working. It
19+
appears as though that library was changed fairly significantly since then, with the default
20+
import removed. That lead to issues for some people, depending on the version of uuidv4 they
21+
installed/had installed. We have dropped uuidv4 and are now using a small, fast built-in function
22+
instead in v0.3.1 and onward, which should resolve the issues. Again, we apologize for the inconvenience!**
23+
1724
## What is it?
1825

1926
NgRX Auto-Entity aims to provide a seamless means of dealing with standard entity actions and

projects/ngrx-auto-entity/package.json

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
{
2-
"version": "0.3.0",
2+
"version": "0.3.1",
33
"name": "@briebug/ngrx-auto-entity",
44
"description": "Automatic Entity State and Facades for NgRx. Simplifying reactive state!",
55
"keywords": [
@@ -24,7 +24,6 @@
2424
"@angular/core": "8.x",
2525
"@ngrx/effects": "8.x",
2626
"@ngrx/store": "8.x",
27-
"rxjs": "6.x",
28-
"uuidv4": ">=4.x <=6.x"
27+
"rxjs": "6.x"
2928
}
3029
}

projects/ngrx-auto-entity/src/lib/actions.spec.ts

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@ import { TestBed } from '@angular/core/testing';
22
import { provideMockActions } from '@ngrx/effects/testing';
33
import { hot } from 'jasmine-marbles';
44
import { Observable } from 'rxjs';
5-
import uuid from 'uuidv4';
65
import {
76
Clear,
87
Create,
@@ -103,6 +102,15 @@ const testError = {
103102

104103
const criteria = { criteria: 'test' };
105104

105+
const regex = {
106+
v4: /^(?:[a-f0-9]{8}-[a-f0-9]{4}-4[a-f0-9]{3}-[a-f0-9]{4}-[a-f0-9]{12})|(?:0{8}-0{4}-0{4}-0{4}-0{12})$/u,
107+
v5: /^(?:[a-f0-9]{8}-[a-f0-9]{4}-5[a-f0-9]{3}-[a-f0-9]{4}-[a-f0-9]{12})|(?:0{8}-0{4}-0{4}-0{4}-0{12})$/u
108+
};
109+
110+
const isUuid = (value: string): boolean => {
111+
return regex.v4.test(value) || regex.v5.test(value);
112+
};
113+
106114
describe('NgRX Auto-Entity: Actions', () => {
107115
let actions: Observable<any>;
108116

@@ -116,7 +124,7 @@ describe('NgRX Auto-Entity: Actions', () => {
116124
it('should construct EntityAction with correlationId initialized to a random uuid', () => {
117125
const action = new Load(TestEntity, 1);
118126

119-
expect(uuid.is(action.correlationId)).toEqual(true);
127+
expect(isUuid(action.correlationId)).toEqual(true);
120128
});
121129
});
122130

projects/ngrx-auto-entity/src/lib/actions.ts

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@ import { Actions } from '@ngrx/effects';
22
import { Action } from '@ngrx/store';
33
import { merge, Observable, OperatorFunction } from 'rxjs';
44
import { filter } from 'rxjs/operators';
5-
import uuid from 'uuidv4';
65
import { pascalCase } from '../util/case';
76
import { checkKeyName } from './decorators';
87
import { IPageInfo, IRangeInfo, Page, Range } from './models';
@@ -109,6 +108,13 @@ export interface IEntityAction extends Action, ICorrelatedAction {
109108
info: IEntityInfo;
110109
}
111110

111+
// tslint:disable
112+
const uuid = (a?, b?) => {
113+
for (b = a = ''; a++ < 36; b += a * 51 & 52 ? (a ^ 15 ? 8 ^ Math.random() * (a ^ 20 ? 16 : 4) : 4).toString(16) : '-') ;
114+
return b;
115+
};
116+
// tslint:enable
117+
112118
/**
113119
* Structure for all of this library's actions
114120
*/

projects/ngrx-auto-entity/src/lib/module.ts

Lines changed: 2 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -25,12 +25,7 @@ export interface NgRxAutoEntityModuleConfig {
2525
]
2626
})
2727
export class NgRxAutoEntityRootModuleWithEffects {
28-
constructor(
29-
private effectSources: EffectSources,
30-
entityEffects: EntityEffects,
31-
extraEffects: ExtraEffects,
32-
injector: Injector
33-
) {
28+
constructor(private effectSources: EffectSources, entityEffects: EntityEffects, extraEffects: ExtraEffects) {
3429
// NOTE: The following trick learned from @ngrx/data!
3530

3631
// Warning: this alternative approach relies on an undocumented API
@@ -58,7 +53,7 @@ export class NgRxAutoEntityRootModuleWithEffects {
5853
]
5954
})
6055
export class NgRxAutoEntityRootModuleNoEntityEffects {
61-
constructor(private effectSources: EffectSources, extraEffects: ExtraEffects, injector: Injector) {
56+
constructor(private effectSources: EffectSources, extraEffects: ExtraEffects) {
6257
// NOTE: The following trick learned from @ngrx/data!
6358

6459
// Warning: this alternative approach relies on an undocumented API

projects/ngrx-auto-entity/src/lib/operators.ts

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -71,15 +71,14 @@ export const handleError = <TModel, TErrorAction>(
7171
error: IEntityError<TModel>,
7272
errorAction: TErrorAction
7373
): Observable<TErrorAction> => {
74+
const serviceName = `${pascalCase(error.info.modelName)}Service`;
7475
if (error.err instanceof TypeError) {
75-
const serviceName = `${pascalCase(error.info.modelName)}Service`;
7676
console.error(
7777
`[NGRX-AE] ! NgRxAutoEntityService Error: Unable to locate load method in the ${serviceName}`,
7878
'\nReason: ',
7979
error.err
8080
);
8181
} else if (error.info && error.message) {
82-
const serviceName = `${pascalCase(error.info.modelName)}Service`;
8382
console.error(
8483
`[NGRX-AE] ! NgRxAutoEntityService Error: Unable to invoke required operations on the ${serviceName}`,
8584
'\nReason: ',

0 commit comments

Comments
 (0)