@nrwl/angular 14.7.8 → 14.7.10
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/CHANGELOG.md +1 -1
- package/esm2020/src/runtime/nx/data-persistence.mjs +3 -3
- package/esm2020/src/runtime/nx/nx.module.mjs +4 -4
- package/fesm2015/nrwl-angular.mjs +7 -7
- package/fesm2020/nrwl-angular.mjs +7 -7
- package/package.json +9 -9
- package/src/generators/ngrx/files/{creator-syntax/__directory__ → __directory__}/__fileName__.actions.ts__tmpl__ +0 -0
- package/src/generators/ngrx/files/{creator-syntax/__directory__ → __directory__}/__fileName__.effects.spec.ts__tmpl__ +0 -0
- package/src/generators/ngrx/files/{creator-syntax/__directory__ → __directory__}/__fileName__.effects.ts__tmpl__ +1 -1
- package/src/generators/ngrx/files/{creator-syntax/__directory__ → __directory__}/__fileName__.facade.spec.ts__tmpl__ +0 -0
- package/src/generators/ngrx/files/{creator-syntax/__directory__ → __directory__}/__fileName__.facade.ts__tmpl__ +0 -0
- package/src/generators/ngrx/files/{creator-syntax/__directory__ → __directory__}/__fileName__.models.ts__tmpl__ +0 -0
- package/src/generators/ngrx/files/{creator-syntax/__directory__ → __directory__}/__fileName__.reducer.spec.ts__tmpl__ +0 -0
- package/src/generators/ngrx/files/{creator-syntax/__directory__ → __directory__}/__fileName__.reducer.ts__tmpl__ +0 -0
- package/src/generators/ngrx/files/{creator-syntax/__directory__ → __directory__}/__fileName__.selectors.spec.ts__tmpl__ +0 -0
- package/src/generators/ngrx/files/{creator-syntax/__directory__ → __directory__}/__fileName__.selectors.ts__tmpl__ +0 -0
- package/src/generators/ngrx/lib/add-exports-barrel.js +1 -3
- package/src/generators/ngrx/lib/add-exports-barrel.js.map +1 -1
- package/src/generators/ngrx/lib/generate-files.js +1 -4
- package/src/generators/ngrx/lib/generate-files.js.map +1 -1
- package/src/generators/ngrx/schema.d.ts +0 -5
- package/src/generators/ngrx/schema.json +0 -7
- package/src/generators/ngrx/files/classes-syntax/__directory__/__fileName__.actions.ts__tmpl__ +0 -32
- package/src/generators/ngrx/files/classes-syntax/__directory__/__fileName__.effects.spec.ts__tmpl__ +0 -42
- package/src/generators/ngrx/files/classes-syntax/__directory__/__fileName__.effects.ts__tmpl__ +0 -39
- package/src/generators/ngrx/files/classes-syntax/__directory__/__fileName__.facade.spec.ts__tmpl__ +0 -98
- package/src/generators/ngrx/files/classes-syntax/__directory__/__fileName__.facade.ts__tmpl__ +0 -19
- package/src/generators/ngrx/files/classes-syntax/__directory__/__fileName__.reducer.spec.ts__tmpl__ +0 -32
- package/src/generators/ngrx/files/classes-syntax/__directory__/__fileName__.reducer.ts__tmpl__ +0 -47
- package/src/generators/ngrx/files/classes-syntax/__directory__/__fileName__.selectors.spec.ts__tmpl__ +0 -57
- package/src/generators/ngrx/files/classes-syntax/__directory__/__fileName__.selectors.ts__tmpl__ +0 -24
package/CHANGELOG.md
CHANGED
|
@@ -3,6 +3,6 @@
|
|
|
3
3
|
All notable changes to this project will be documented in this file.
|
|
4
4
|
See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.
|
|
5
5
|
|
|
6
|
-
## [14.7.
|
|
6
|
+
## [14.7.10](https://github.com/nrwl/nx/compare/14.7.9...14.7.10) (2022-09-22)
|
|
7
7
|
|
|
8
8
|
**Note:** Version bump only for package @nrwl/angular
|
|
@@ -370,9 +370,9 @@ export class DataPersistence {
|
|
|
370
370
|
return this.actions.pipe(withLatestFrom(this.store), navigation(component, opts));
|
|
371
371
|
}
|
|
372
372
|
}
|
|
373
|
-
DataPersistence.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "14.2.
|
|
374
|
-
DataPersistence.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "14.2.
|
|
375
|
-
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "14.2.
|
|
373
|
+
DataPersistence.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "14.2.1", ngImport: i0, type: DataPersistence, deps: [{ token: i1.Store }, { token: i2.Actions }], target: i0.ɵɵFactoryTarget.Injectable });
|
|
374
|
+
DataPersistence.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "14.2.1", ngImport: i0, type: DataPersistence });
|
|
375
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "14.2.1", ngImport: i0, type: DataPersistence, decorators: [{
|
|
376
376
|
type: Injectable
|
|
377
377
|
}], ctorParameters: function () { return [{ type: i1.Store }, { type: i2.Actions }]; } });
|
|
378
378
|
function findSnapshot(component, s) {
|
|
@@ -13,10 +13,10 @@ export class NxModule {
|
|
|
13
13
|
return { ngModule: NxModule, providers: [DataPersistence] };
|
|
14
14
|
}
|
|
15
15
|
}
|
|
16
|
-
NxModule.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "14.2.
|
|
17
|
-
NxModule.ɵmod = i0.ɵɵngDeclareNgModule({ minVersion: "14.0.0", version: "14.2.
|
|
18
|
-
NxModule.ɵinj = i0.ɵɵngDeclareInjector({ minVersion: "12.0.0", version: "14.2.
|
|
19
|
-
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "14.2.
|
|
16
|
+
NxModule.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "14.2.1", ngImport: i0, type: NxModule, deps: [], target: i0.ɵɵFactoryTarget.NgModule });
|
|
17
|
+
NxModule.ɵmod = i0.ɵɵngDeclareNgModule({ minVersion: "14.0.0", version: "14.2.1", ngImport: i0, type: NxModule });
|
|
18
|
+
NxModule.ɵinj = i0.ɵɵngDeclareInjector({ minVersion: "12.0.0", version: "14.2.1", ngImport: i0, type: NxModule });
|
|
19
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "14.2.1", ngImport: i0, type: NxModule, decorators: [{
|
|
20
20
|
type: NgModule,
|
|
21
21
|
args: [{}]
|
|
22
22
|
}] });
|
|
@@ -371,9 +371,9 @@ class DataPersistence {
|
|
|
371
371
|
return this.actions.pipe(withLatestFrom(this.store), navigation(component, opts));
|
|
372
372
|
}
|
|
373
373
|
}
|
|
374
|
-
DataPersistence.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "14.2.
|
|
375
|
-
DataPersistence.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "14.2.
|
|
376
|
-
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "14.2.
|
|
374
|
+
DataPersistence.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "14.2.1", ngImport: i0, type: DataPersistence, deps: [{ token: i1.Store }, { token: i2.Actions }], target: i0.ɵɵFactoryTarget.Injectable });
|
|
375
|
+
DataPersistence.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "14.2.1", ngImport: i0, type: DataPersistence });
|
|
376
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "14.2.1", ngImport: i0, type: DataPersistence, decorators: [{
|
|
377
377
|
type: Injectable
|
|
378
378
|
}], ctorParameters: function () { return [{ type: i1.Store }, { type: i2.Actions }]; } });
|
|
379
379
|
function findSnapshot(component, s) {
|
|
@@ -412,10 +412,10 @@ class NxModule {
|
|
|
412
412
|
return { ngModule: NxModule, providers: [DataPersistence] };
|
|
413
413
|
}
|
|
414
414
|
}
|
|
415
|
-
NxModule.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "14.2.
|
|
416
|
-
NxModule.ɵmod = i0.ɵɵngDeclareNgModule({ minVersion: "14.0.0", version: "14.2.
|
|
417
|
-
NxModule.ɵinj = i0.ɵɵngDeclareInjector({ minVersion: "12.0.0", version: "14.2.
|
|
418
|
-
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "14.2.
|
|
415
|
+
NxModule.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "14.2.1", ngImport: i0, type: NxModule, deps: [], target: i0.ɵɵFactoryTarget.NgModule });
|
|
416
|
+
NxModule.ɵmod = i0.ɵɵngDeclareNgModule({ minVersion: "14.0.0", version: "14.2.1", ngImport: i0, type: NxModule });
|
|
417
|
+
NxModule.ɵinj = i0.ɵɵngDeclareInjector({ minVersion: "12.0.0", version: "14.2.1", ngImport: i0, type: NxModule });
|
|
418
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "14.2.1", ngImport: i0, type: NxModule, decorators: [{
|
|
419
419
|
type: NgModule,
|
|
420
420
|
args: [{}]
|
|
421
421
|
}] });
|
|
@@ -371,9 +371,9 @@ class DataPersistence {
|
|
|
371
371
|
return this.actions.pipe(withLatestFrom(this.store), navigation(component, opts));
|
|
372
372
|
}
|
|
373
373
|
}
|
|
374
|
-
DataPersistence.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "14.2.
|
|
375
|
-
DataPersistence.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "14.2.
|
|
376
|
-
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "14.2.
|
|
374
|
+
DataPersistence.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "14.2.1", ngImport: i0, type: DataPersistence, deps: [{ token: i1.Store }, { token: i2.Actions }], target: i0.ɵɵFactoryTarget.Injectable });
|
|
375
|
+
DataPersistence.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "14.2.1", ngImport: i0, type: DataPersistence });
|
|
376
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "14.2.1", ngImport: i0, type: DataPersistence, decorators: [{
|
|
377
377
|
type: Injectable
|
|
378
378
|
}], ctorParameters: function () { return [{ type: i1.Store }, { type: i2.Actions }]; } });
|
|
379
379
|
function findSnapshot(component, s) {
|
|
@@ -412,10 +412,10 @@ class NxModule {
|
|
|
412
412
|
return { ngModule: NxModule, providers: [DataPersistence] };
|
|
413
413
|
}
|
|
414
414
|
}
|
|
415
|
-
NxModule.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "14.2.
|
|
416
|
-
NxModule.ɵmod = i0.ɵɵngDeclareNgModule({ minVersion: "14.0.0", version: "14.2.
|
|
417
|
-
NxModule.ɵinj = i0.ɵɵngDeclareInjector({ minVersion: "12.0.0", version: "14.2.
|
|
418
|
-
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "14.2.
|
|
415
|
+
NxModule.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "14.2.1", ngImport: i0, type: NxModule, deps: [], target: i0.ɵɵFactoryTarget.NgModule });
|
|
416
|
+
NxModule.ɵmod = i0.ɵɵngDeclareNgModule({ minVersion: "14.0.0", version: "14.2.1", ngImport: i0, type: NxModule });
|
|
417
|
+
NxModule.ɵinj = i0.ɵɵngDeclareInjector({ minVersion: "12.0.0", version: "14.2.1", ngImport: i0, type: NxModule });
|
|
418
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "14.2.1", ngImport: i0, type: NxModule, decorators: [{
|
|
419
419
|
type: NgModule,
|
|
420
420
|
args: [{}]
|
|
421
421
|
}] });
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@nrwl/angular",
|
|
3
|
-
"version": "14.7.
|
|
3
|
+
"version": "14.7.10",
|
|
4
4
|
"private": false,
|
|
5
5
|
"description": "The Nx Plugin for Angular contains executors, generators, and utilities for managing Angular applications and libraries within an Nx workspace. It provides: \n\n- Integration with libraries such as Storybook, Jest, ESLint, Tailwind CSS, Cypress, Karma, and Protractor. \n\n- Generators to help scaffold code quickly (like: Micro Frontends, Libraries, both internal to your codebase and publishable to npm) \n\n- Upgrading AngularJS applications \n\n- Single Component Application Modules (SCAMs) \n\n- NgRx helpers. \n\n- Utilities for automatic workspace refactoring.",
|
|
6
6
|
"repository": {
|
|
@@ -67,13 +67,13 @@
|
|
|
67
67
|
},
|
|
68
68
|
"dependencies": {
|
|
69
69
|
"@angular-devkit/schematics": "~14.2.0",
|
|
70
|
-
"@nrwl/cypress": "14.7.
|
|
71
|
-
"@nrwl/devkit": "14.7.
|
|
72
|
-
"@nrwl/jest": "14.7.
|
|
73
|
-
"@nrwl/linter": "14.7.
|
|
74
|
-
"@nrwl/storybook": "14.7.
|
|
75
|
-
"@nrwl/webpack": "14.7.
|
|
76
|
-
"@nrwl/workspace": "14.7.
|
|
70
|
+
"@nrwl/cypress": "14.7.10",
|
|
71
|
+
"@nrwl/devkit": "14.7.10",
|
|
72
|
+
"@nrwl/jest": "14.7.10",
|
|
73
|
+
"@nrwl/linter": "14.7.10",
|
|
74
|
+
"@nrwl/storybook": "14.7.10",
|
|
75
|
+
"@nrwl/webpack": "14.7.10",
|
|
76
|
+
"@nrwl/workspace": "14.7.10",
|
|
77
77
|
"@phenomnomnominal/tsquery": "4.1.1",
|
|
78
78
|
"@schematics/angular": "~14.2.0",
|
|
79
79
|
"chalk": "4.1.0",
|
|
@@ -100,5 +100,5 @@
|
|
|
100
100
|
"fesm2015": "fesm2015/nrwl-angular.mjs",
|
|
101
101
|
"typings": "index.d.ts",
|
|
102
102
|
"sideEffects": false,
|
|
103
|
-
"gitHead": "
|
|
103
|
+
"gitHead": "6cc0cadca13cfcd76e25021951b61054fb335362"
|
|
104
104
|
}
|
|
File without changes
|
|
File without changes
|
|
@@ -7,7 +7,7 @@ import * as <%= className %>Feature from './<%= fileName %>.reducer';
|
|
|
7
7
|
|
|
8
8
|
@Injectable()
|
|
9
9
|
export class <%= className %>Effects {
|
|
10
|
-
<% if (useDataPersistence) { %>init$ = createEffect(() => this.dataPersistence.fetch(<%= className %>Actions
|
|
10
|
+
<% if (useDataPersistence) { %>init$ = createEffect(() => this.dataPersistence.fetch(<%= className %>Actions.init<%= className %>, {
|
|
11
11
|
run: (action: ReturnType<typeof <%= className %>Actions.init<%= className %>>, state: <%= className %>Feature.<%= className %>PartialState) => {
|
|
12
12
|
// Your custom service 'load' logic goes here. For now just return a success action...
|
|
13
13
|
return <%= className %>Actions.load<%= className %>Success({ <%= propertyName %>: [] });
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
@@ -34,9 +34,7 @@ function addExportsToBarrel(tree, options) {
|
|
|
34
34
|
if (options.barrels) {
|
|
35
35
|
sourceFile = (0, ast_utils_1.addGlobal)(tree, sourceFile, indexFilePath, `export { ${className}Actions, ${className}Feature, ${className}Selectors };`);
|
|
36
36
|
}
|
|
37
|
-
|
|
38
|
-
sourceFile = (0, ast_utils_1.addGlobal)(tree, sourceFile, indexFilePath, `export * from '${statePath}.models';`);
|
|
39
|
-
}
|
|
37
|
+
sourceFile = (0, ast_utils_1.addGlobal)(tree, sourceFile, indexFilePath, `export * from '${statePath}.models';`);
|
|
40
38
|
if (options.facade) {
|
|
41
39
|
sourceFile = (0, ast_utils_1.addGlobal)(tree, sourceFile, indexFilePath, `export * from '${statePath}.facade';`);
|
|
42
40
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"add-exports-barrel.js","sourceRoot":"","sources":["../../../../../../../packages/angular/src/generators/ngrx/lib/add-exports-barrel.ts"],"names":[],"mappings":";;;AACA,yCAAwD;AACxD,uEAAoE;AACpE,+BAA+B;AAC/B,2CAA4D;AAG5D;;GAEG;AACH,SAAgB,kBAAkB,CAChC,IAAU,EACV,OAA6B;IAE7B,6EAA6E;IAC7E,IAAI,OAAO,CAAC,IAAI,EAAE;QAChB,OAAO;KACR;IAED,MAAM,aAAa,GAAG,IAAA,0BAAiB,EACrC,IAAA,cAAO,EAAC,OAAO,CAAC,MAAM,CAAC,EACvB,IAAI,EACJ,UAAU,CACX,CAAC;IACF,IAAI,CAAC,IAAI,CAAC,MAAM,CAAC,aAAa,CAAC,EAAE;QAC/B,OAAO;KACR;IAED,MAAM,eAAe,GAAG,IAAI,CAAC,IAAI,CAAC,aAAa,EAAE,OAAO,CAAC,CAAC;IAC1D,IAAI,UAAU,GAAG,IAAA,6BAAgB,EAC/B,aAAa,EACb,eAAe,EACf,yBAAY,CAAC,MAAM,EACnB,IAAI,CACL,CAAC;IAEF,+DAA+D;IAC/D,MAAM,EAAE,SAAS,EAAE,QAAQ,EAAE,GAAG,IAAA,cAAK,EAAC,OAAO,CAAC,IAAI,CAAC,CAAC;IACpD,MAAM,SAAS,GAAG,SAAS,OAAO,CAAC,SAAS,IAAI,QAAQ,EAAE,CAAC;IAE3D,UAAU,GAAG,IAAA,qBAAS,EACpB,IAAI,EACJ,UAAU,EACV,aAAa,EACb,OAAO,CAAC,OAAO;QACb,CAAC,CAAC,eAAe,SAAS,iBAAiB,SAAS,YAAY;QAChE,CAAC,CAAC,kBAAkB,SAAS,YAAY,CAC5C,CAAC;IACF,UAAU,GAAG,IAAA,qBAAS,EACpB,IAAI,EACJ,UAAU,EACV,aAAa,EACb,OAAO,CAAC,OAAO;QACb,CAAC,CAAC,eAAe,SAAS,iBAAiB,SAAS,YAAY;QAChE,CAAC,CAAC,kBAAkB,SAAS,YAAY,CAC5C,CAAC;IACF,UAAU,GAAG,IAAA,qBAAS,EACpB,IAAI,EACJ,UAAU,EACV,aAAa,EACb,OAAO,CAAC,OAAO;QACb,CAAC,CAAC,eAAe,SAAS,mBAAmB,SAAS,cAAc;QACpE,CAAC,CAAC,kBAAkB,SAAS,cAAc,CAC9C,CAAC;IAEF,IAAI,OAAO,CAAC,OAAO,EAAE;QACnB,UAAU,GAAG,IAAA,qBAAS,EACpB,IAAI,EACJ,UAAU,EACV,aAAa,EACb,YAAY,SAAS,YAAY,SAAS,YAAY,SAAS,cAAc,CAC9E,CAAC;KACH;IAED,
|
|
1
|
+
{"version":3,"file":"add-exports-barrel.js","sourceRoot":"","sources":["../../../../../../../packages/angular/src/generators/ngrx/lib/add-exports-barrel.ts"],"names":[],"mappings":";;;AACA,yCAAwD;AACxD,uEAAoE;AACpE,+BAA+B;AAC/B,2CAA4D;AAG5D;;GAEG;AACH,SAAgB,kBAAkB,CAChC,IAAU,EACV,OAA6B;IAE7B,6EAA6E;IAC7E,IAAI,OAAO,CAAC,IAAI,EAAE;QAChB,OAAO;KACR;IAED,MAAM,aAAa,GAAG,IAAA,0BAAiB,EACrC,IAAA,cAAO,EAAC,OAAO,CAAC,MAAM,CAAC,EACvB,IAAI,EACJ,UAAU,CACX,CAAC;IACF,IAAI,CAAC,IAAI,CAAC,MAAM,CAAC,aAAa,CAAC,EAAE;QAC/B,OAAO;KACR;IAED,MAAM,eAAe,GAAG,IAAI,CAAC,IAAI,CAAC,aAAa,EAAE,OAAO,CAAC,CAAC;IAC1D,IAAI,UAAU,GAAG,IAAA,6BAAgB,EAC/B,aAAa,EACb,eAAe,EACf,yBAAY,CAAC,MAAM,EACnB,IAAI,CACL,CAAC;IAEF,+DAA+D;IAC/D,MAAM,EAAE,SAAS,EAAE,QAAQ,EAAE,GAAG,IAAA,cAAK,EAAC,OAAO,CAAC,IAAI,CAAC,CAAC;IACpD,MAAM,SAAS,GAAG,SAAS,OAAO,CAAC,SAAS,IAAI,QAAQ,EAAE,CAAC;IAE3D,UAAU,GAAG,IAAA,qBAAS,EACpB,IAAI,EACJ,UAAU,EACV,aAAa,EACb,OAAO,CAAC,OAAO;QACb,CAAC,CAAC,eAAe,SAAS,iBAAiB,SAAS,YAAY;QAChE,CAAC,CAAC,kBAAkB,SAAS,YAAY,CAC5C,CAAC;IACF,UAAU,GAAG,IAAA,qBAAS,EACpB,IAAI,EACJ,UAAU,EACV,aAAa,EACb,OAAO,CAAC,OAAO;QACb,CAAC,CAAC,eAAe,SAAS,iBAAiB,SAAS,YAAY;QAChE,CAAC,CAAC,kBAAkB,SAAS,YAAY,CAC5C,CAAC;IACF,UAAU,GAAG,IAAA,qBAAS,EACpB,IAAI,EACJ,UAAU,EACV,aAAa,EACb,OAAO,CAAC,OAAO;QACb,CAAC,CAAC,eAAe,SAAS,mBAAmB,SAAS,cAAc;QACpE,CAAC,CAAC,kBAAkB,SAAS,cAAc,CAC9C,CAAC;IAEF,IAAI,OAAO,CAAC,OAAO,EAAE;QACnB,UAAU,GAAG,IAAA,qBAAS,EACpB,IAAI,EACJ,UAAU,EACV,aAAa,EACb,YAAY,SAAS,YAAY,SAAS,YAAY,SAAS,cAAc,CAC9E,CAAC;KACH;IAED,UAAU,GAAG,IAAA,qBAAS,EACpB,IAAI,EACJ,UAAU,EACV,aAAa,EACb,kBAAkB,SAAS,WAAW,CACvC,CAAC;IAEF,IAAI,OAAO,CAAC,MAAM,EAAE;QAClB,UAAU,GAAG,IAAA,qBAAS,EACpB,IAAI,EACJ,UAAU,EACV,aAAa,EACb,kBAAkB,SAAS,WAAW,CACvC,CAAC;KACH;AACH,CAAC;AA/ED,gDA+EC"}
|
|
@@ -9,11 +9,8 @@ const path_1 = require("path");
|
|
|
9
9
|
function generateNgrxFilesFromTemplates(tree, options) {
|
|
10
10
|
const name = options.name;
|
|
11
11
|
const moduleDir = (0, path_1.dirname)(options.module);
|
|
12
|
-
const templatesDir = !options.syntax || options.syntax === 'creators'
|
|
13
|
-
? './files/creator-syntax'
|
|
14
|
-
: './files/classes-syntax';
|
|
15
12
|
const projectNames = (0, devkit_1.names)(name);
|
|
16
|
-
(0, devkit_1.generateFiles)(tree, (0, devkit_1.joinPathFragments)(__dirname, '..',
|
|
13
|
+
(0, devkit_1.generateFiles)(tree, (0, devkit_1.joinPathFragments)(__dirname, '..', 'files'), moduleDir, Object.assign(Object.assign(Object.assign({}, options), projectNames), { tmpl: '' }));
|
|
17
14
|
if (!options.facade) {
|
|
18
15
|
tree.delete((0, devkit_1.joinPathFragments)(moduleDir, options.directory, `${projectNames.fileName}.facade.ts`));
|
|
19
16
|
tree.delete((0, devkit_1.joinPathFragments)(moduleDir, options.directory, `${projectNames.fileName}.facade.spec.ts`));
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"generate-files.js","sourceRoot":"","sources":["../../../../../../../packages/angular/src/generators/ngrx/lib/generate-files.ts"],"names":[],"mappings":";;;AACA,yCAAuE;AACvE,+BAA+B;AAG/B;;GAEG;AACH,SAAgB,8BAA8B,CAC5C,IAAU,EACV,OAA6B;IAE7B,MAAM,IAAI,GAAG,OAAO,CAAC,IAAI,CAAC;IAC1B,MAAM,SAAS,GAAG,IAAA,cAAO,EAAC,OAAO,CAAC,MAAM,CAAC,CAAC;IAC1C,MAAM,YAAY,
|
|
1
|
+
{"version":3,"file":"generate-files.js","sourceRoot":"","sources":["../../../../../../../packages/angular/src/generators/ngrx/lib/generate-files.ts"],"names":[],"mappings":";;;AACA,yCAAuE;AACvE,+BAA+B;AAG/B;;GAEG;AACH,SAAgB,8BAA8B,CAC5C,IAAU,EACV,OAA6B;IAE7B,MAAM,IAAI,GAAG,OAAO,CAAC,IAAI,CAAC;IAC1B,MAAM,SAAS,GAAG,IAAA,cAAO,EAAC,OAAO,CAAC,MAAM,CAAC,CAAC;IAC1C,MAAM,YAAY,GAAG,IAAA,cAAK,EAAC,IAAI,CAAC,CAAC;IAEjC,IAAA,sBAAa,EAAC,IAAI,EAAE,IAAA,0BAAiB,EAAC,SAAS,EAAE,IAAI,EAAE,OAAO,CAAC,EAAE,SAAS,gDACrE,OAAO,GACP,YAAY,KACf,IAAI,EAAE,EAAE,IACR,CAAC;IAEH,IAAI,CAAC,OAAO,CAAC,MAAM,EAAE;QACnB,IAAI,CAAC,MAAM,CACT,IAAA,0BAAiB,EACf,SAAS,EACT,OAAO,CAAC,SAAS,EACjB,GAAG,YAAY,CAAC,QAAQ,YAAY,CACrC,CACF,CAAC;QACF,IAAI,CAAC,MAAM,CACT,IAAA,0BAAiB,EACf,SAAS,EACT,OAAO,CAAC,SAAS,EACjB,GAAG,YAAY,CAAC,QAAQ,iBAAiB,CAC1C,CACF,CAAC;KACH;AACH,CAAC;AA9BD,wEA8BC"}
|
|
@@ -14,9 +14,4 @@ export interface NgRxGeneratorOptions {
|
|
|
14
14
|
* Using the individual operators is recommended.
|
|
15
15
|
*/
|
|
16
16
|
useDataPersistence?: boolean;
|
|
17
|
-
/**
|
|
18
|
-
* @deprecated Always use the `creators` value. The `classes` syntax is
|
|
19
|
-
* deprecated and this option will be removed in v15.
|
|
20
|
-
*/
|
|
21
|
-
syntax?: 'classes' | 'creators';
|
|
22
17
|
}
|
|
@@ -57,13 +57,6 @@
|
|
|
57
57
|
"default": false,
|
|
58
58
|
"description": "Do not update the `package.json` with NgRx dependencies."
|
|
59
59
|
},
|
|
60
|
-
"syntax": {
|
|
61
|
-
"type": "string",
|
|
62
|
-
"enum": ["classes", "creators"],
|
|
63
|
-
"default": "creators",
|
|
64
|
-
"description": "Specifies whether to use class-based or creator functions for actions, reducers, and effects.",
|
|
65
|
-
"x-deprecated": "Classes syntax is deprecated and this option will be removed in v15. Creators syntax will be the default in v15 and this option will be removed."
|
|
66
|
-
},
|
|
67
60
|
"useDataPersistence": {
|
|
68
61
|
"type": "boolean",
|
|
69
62
|
"default": false,
|
package/src/generators/ngrx/files/classes-syntax/__directory__/__fileName__.actions.ts__tmpl__
DELETED
|
@@ -1,32 +0,0 @@
|
|
|
1
|
-
import {Action} from '@ngrx/store';
|
|
2
|
-
import {<%= className %>Entity} from './<%= fileName %>.reducer';
|
|
3
|
-
|
|
4
|
-
export enum <%= className %>ActionTypes {
|
|
5
|
-
Load<%= className %> = '[<%= className %>] Load <%= className %>',
|
|
6
|
-
<%= className %>Loaded = '[<%= className %>] <%= className %> Loaded',
|
|
7
|
-
<%= className %>LoadError = '[<%= className %>] <%= className %> Load Error'
|
|
8
|
-
}
|
|
9
|
-
|
|
10
|
-
export class Load<%= className %> implements Action {
|
|
11
|
-
readonly type = <%= className %>ActionTypes.Load<%= className %>;
|
|
12
|
-
}
|
|
13
|
-
|
|
14
|
-
export class <%= className %>LoadError implements Action {
|
|
15
|
-
readonly type = <%= className %>ActionTypes.<%= className %>LoadError;
|
|
16
|
-
|
|
17
|
-
constructor(public payload: any) {}
|
|
18
|
-
}
|
|
19
|
-
|
|
20
|
-
export class <%= className %>Loaded implements Action {
|
|
21
|
-
readonly type = <%= className %>ActionTypes.<%= className %>Loaded;
|
|
22
|
-
|
|
23
|
-
constructor(public payload: <%= className %>Entity[]) {}
|
|
24
|
-
}
|
|
25
|
-
|
|
26
|
-
export type <%= className %>Action = Load<%= className %> | <%= className %>Loaded | <%= className %>LoadError;
|
|
27
|
-
|
|
28
|
-
export const from<%= className %>Actions = {
|
|
29
|
-
Load<%= className %>,
|
|
30
|
-
<%= className %>Loaded,
|
|
31
|
-
<%= className %>LoadError
|
|
32
|
-
};
|
package/src/generators/ngrx/files/classes-syntax/__directory__/__fileName__.effects.spec.ts__tmpl__
DELETED
|
@@ -1,42 +0,0 @@
|
|
|
1
|
-
import { TestBed } from '@angular/core/testing';
|
|
2
|
-
import { EffectsModule } from '@ngrx/effects';
|
|
3
|
-
import { provideMockActions } from '@ngrx/effects/testing';
|
|
4
|
-
import { Action, StoreModule } from '@ngrx/store';
|
|
5
|
-
import { NxModule<% if (useDataPersistence) { %>, DataPersistence<% } %> } from '@nrwl/angular';
|
|
6
|
-
import { hot } from 'jasmine-marbles';
|
|
7
|
-
import { Observable } from 'rxjs';
|
|
8
|
-
|
|
9
|
-
import { <%= className %>Effects } from './<%= fileName %>.effects';
|
|
10
|
-
import { Load<%= className %>, <%= className %>Loaded } from './<%= fileName %>.actions';
|
|
11
|
-
|
|
12
|
-
describe('<%= className %>Effects', () => {
|
|
13
|
-
let actions: Observable<Action>;
|
|
14
|
-
let effects: <%= className %>Effects;
|
|
15
|
-
|
|
16
|
-
beforeEach(() => {
|
|
17
|
-
TestBed.configureTestingModule({
|
|
18
|
-
imports: [
|
|
19
|
-
NxModule.forRoot(),
|
|
20
|
-
StoreModule.forRoot({}),
|
|
21
|
-
EffectsModule.forRoot([])
|
|
22
|
-
],
|
|
23
|
-
providers: [
|
|
24
|
-
<%= className %>Effects,<% if (useDataPersistence) { %>
|
|
25
|
-
DataPersistence,<% } %>
|
|
26
|
-
provideMockActions(() => actions)
|
|
27
|
-
],
|
|
28
|
-
});
|
|
29
|
-
|
|
30
|
-
effects = TestBed.inject(<%= className %>Effects);
|
|
31
|
-
});
|
|
32
|
-
|
|
33
|
-
describe('load<%= className %>$', () => {
|
|
34
|
-
it('should work', () => {
|
|
35
|
-
actions = hot('-a-|', { a: new Load<%= className %>() });
|
|
36
|
-
|
|
37
|
-
expect(effects.load<%= className %>$).toBeObservable(
|
|
38
|
-
hot('-a-|', { a: new <%= className %>Loaded([]) })
|
|
39
|
-
);
|
|
40
|
-
});
|
|
41
|
-
});
|
|
42
|
-
});
|
package/src/generators/ngrx/files/classes-syntax/__directory__/__fileName__.effects.ts__tmpl__
DELETED
|
@@ -1,39 +0,0 @@
|
|
|
1
|
-
import { Injectable } from '@angular/core';
|
|
2
|
-
import { Effect, Actions<% if (!useDataPersistence) { %>, ofType<% }%> } from '@ngrx/effects';
|
|
3
|
-
import { <% if (useDataPersistence) { %>DataPersistence<% } else { %>fetch<% } %> } from '@nrwl/angular';
|
|
4
|
-
|
|
5
|
-
import { Load<%= className %>, <%= className %>Loaded, <%= className %>LoadError, <%= className %>ActionTypes } from './<%= fileName %>.actions';
|
|
6
|
-
import { <%= className %>PartialState } from './<%= fileName %>.reducer';
|
|
7
|
-
|
|
8
|
-
@Injectable()
|
|
9
|
-
export class <%= className %>Effects {
|
|
10
|
-
@Effect() load<%= className %>$ = <% if (useDataPersistence) { %>this.dataPersistence.fetch(<%= className %>ActionTypes.Load<%= className %>, {
|
|
11
|
-
run: (action: Load<%= className %>, state: <%= className %>PartialState) => {
|
|
12
|
-
// Your custom REST 'load' logic goes here. For now just return an empty list...
|
|
13
|
-
return new <%= className %>Loaded([]);
|
|
14
|
-
},
|
|
15
|
-
|
|
16
|
-
onError: (action: Load<%= className %>, error) => {
|
|
17
|
-
console.error('Error', error);
|
|
18
|
-
return new <%= className %>LoadError(error);
|
|
19
|
-
}
|
|
20
|
-
}); <% } else { %> this.actions$.pipe(
|
|
21
|
-
ofType(<%= className %>ActionTypes.Load<%= className %>),
|
|
22
|
-
fetch({
|
|
23
|
-
run: (action: Load<%= className %>, state: <%= className %>PartialState) => {
|
|
24
|
-
// Your custom REST 'load' logic goes here. For now just return an empty list...
|
|
25
|
-
return new <%= className %>Loaded([]);
|
|
26
|
-
},
|
|
27
|
-
|
|
28
|
-
onError: (action: Load<%= className %>, error) => {
|
|
29
|
-
console.error('Error', error);
|
|
30
|
-
return new <%= className %>LoadError(error);
|
|
31
|
-
}
|
|
32
|
-
})
|
|
33
|
-
);<% } %>
|
|
34
|
-
|
|
35
|
-
constructor(
|
|
36
|
-
private readonly actions$: Actions<% if (useDataPersistence) { %>,
|
|
37
|
-
private readonly dataPersistence: DataPersistence<<%= className %>PartialState><% } %>
|
|
38
|
-
) {}
|
|
39
|
-
}
|
package/src/generators/ngrx/files/classes-syntax/__directory__/__fileName__.facade.spec.ts__tmpl__
DELETED
|
@@ -1,98 +0,0 @@
|
|
|
1
|
-
import { NgModule } from '@angular/core';
|
|
2
|
-
import { TestBed } from '@angular/core/testing';
|
|
3
|
-
import { EffectsModule } from '@ngrx/effects';
|
|
4
|
-
import { StoreModule, Store } from '@ngrx/store';
|
|
5
|
-
import { NxModule } from '@nrwl/angular';
|
|
6
|
-
import { readFirst } from '@nrwl/angular/testing';
|
|
7
|
-
|
|
8
|
-
import { Load<%= className %>, <%= className %>Loaded } from './<%= fileName %>.actions';
|
|
9
|
-
import { <%= className %>Effects } from './<%= fileName %>.effects';
|
|
10
|
-
import { <%= className %>Facade } from './<%= fileName %>.facade';
|
|
11
|
-
import {
|
|
12
|
-
<%= className %>State,
|
|
13
|
-
<%= className %>Entity,
|
|
14
|
-
initial<%= className %>State,
|
|
15
|
-
<%= propertyName %>Reducer
|
|
16
|
-
} from './<%= fileName %>.reducer';
|
|
17
|
-
import { <%= propertyName %>Query } from './<%= fileName %>.selectors';
|
|
18
|
-
|
|
19
|
-
interface TestSchema {
|
|
20
|
-
<%= propertyName %>: <%= className %>State;
|
|
21
|
-
}
|
|
22
|
-
|
|
23
|
-
describe('<%= className %>Facade', () => {
|
|
24
|
-
let facade: <%= className %>Facade;
|
|
25
|
-
let store: Store<TestSchema>;
|
|
26
|
-
const create<%= className %> = (id: string, name?: string): <%= className %>Entity => ({
|
|
27
|
-
id,
|
|
28
|
-
name: name || `name-${id}`
|
|
29
|
-
});
|
|
30
|
-
|
|
31
|
-
describe('used in NgModule', () => {
|
|
32
|
-
beforeEach(() => {
|
|
33
|
-
@NgModule({
|
|
34
|
-
imports: [
|
|
35
|
-
StoreModule.forFeature('<%= propertyName %>', <%= propertyName %>Reducer, { initialState: initial<%= className %>State }),
|
|
36
|
-
EffectsModule.forFeature([<%= className %>Effects])
|
|
37
|
-
],
|
|
38
|
-
providers: [<%= className %>Facade]
|
|
39
|
-
})
|
|
40
|
-
class CustomFeatureModule {}
|
|
41
|
-
|
|
42
|
-
@NgModule({
|
|
43
|
-
imports: [
|
|
44
|
-
NxModule.forRoot(),
|
|
45
|
-
StoreModule.forRoot({}),
|
|
46
|
-
EffectsModule.forRoot([]),
|
|
47
|
-
CustomFeatureModule,
|
|
48
|
-
]
|
|
49
|
-
})
|
|
50
|
-
class RootModule {}
|
|
51
|
-
TestBed.configureTestingModule({ imports: [RootModule] });
|
|
52
|
-
|
|
53
|
-
store = TestBed.inject(Store);
|
|
54
|
-
facade = TestBed.inject(<%= className %>Facade);
|
|
55
|
-
});
|
|
56
|
-
|
|
57
|
-
/**
|
|
58
|
-
* The initially generated facade::loadAll() returns empty array
|
|
59
|
-
*/
|
|
60
|
-
it('loadAll() should return empty list with loaded == true', async () => {
|
|
61
|
-
let list = await readFirst(facade.all<%= className %>$);
|
|
62
|
-
let isLoaded = await readFirst(facade.loaded$);
|
|
63
|
-
|
|
64
|
-
expect(list.length).toBe(0);
|
|
65
|
-
expect(isLoaded).toBe(false);
|
|
66
|
-
|
|
67
|
-
facade.loadAll();
|
|
68
|
-
|
|
69
|
-
list = await readFirst(facade.all<%= className %>$);
|
|
70
|
-
isLoaded = await readFirst(facade.loaded$);
|
|
71
|
-
|
|
72
|
-
expect(list.length).toBe(0);
|
|
73
|
-
expect(isLoaded).toBe(true);
|
|
74
|
-
});
|
|
75
|
-
|
|
76
|
-
/**
|
|
77
|
-
* Use `<%= className %>Loaded` to manually submit list for state management
|
|
78
|
-
*/
|
|
79
|
-
it('all<%= className %>$ should return the loaded list; and loaded flag == true', async () => {
|
|
80
|
-
let list = await readFirst(facade.all<%= className %>$);
|
|
81
|
-
let isLoaded = await readFirst(facade.loaded$);
|
|
82
|
-
|
|
83
|
-
expect(list.length).toBe(0);
|
|
84
|
-
expect(isLoaded).toBe(false);
|
|
85
|
-
|
|
86
|
-
store.dispatch(new <%= className %>Loaded([
|
|
87
|
-
create<%= className %>('AAA'),
|
|
88
|
-
create<%= className %>('BBB')
|
|
89
|
-
]));
|
|
90
|
-
|
|
91
|
-
list = await readFirst(facade.all<%= className %>$);
|
|
92
|
-
isLoaded = await readFirst(facade.loaded$);
|
|
93
|
-
|
|
94
|
-
expect(list.length).toBe(2);
|
|
95
|
-
expect(isLoaded).toBe(true);
|
|
96
|
-
});
|
|
97
|
-
});
|
|
98
|
-
});
|
package/src/generators/ngrx/files/classes-syntax/__directory__/__fileName__.facade.ts__tmpl__
DELETED
|
@@ -1,19 +0,0 @@
|
|
|
1
|
-
import { Injectable } from '@angular/core';
|
|
2
|
-
import { select, Store } from '@ngrx/store';
|
|
3
|
-
|
|
4
|
-
import { <%= className %>PartialState } from './<%= fileName %>.reducer';
|
|
5
|
-
import { <%= propertyName %>Query } from './<%= fileName %>.selectors';
|
|
6
|
-
import { Load<%= className %> } from './<%= fileName %>.actions';
|
|
7
|
-
|
|
8
|
-
@Injectable()
|
|
9
|
-
export class <%= className %>Facade {
|
|
10
|
-
loaded$ = this.store.pipe(select(<%= propertyName %>Query.getLoaded));
|
|
11
|
-
all<%= className %>$ = this.store.pipe(select(<%= propertyName %>Query.getAll<%= className %>));
|
|
12
|
-
selected<%= className %>$ = this.store.pipe(select(<%= propertyName %>Query.getSelected<%= className %>));
|
|
13
|
-
|
|
14
|
-
constructor(private readonly store: Store<<%= className %>PartialState>) {}
|
|
15
|
-
|
|
16
|
-
loadAll() {
|
|
17
|
-
this.store.dispatch(new Load<%= className %>());
|
|
18
|
-
}
|
|
19
|
-
}
|
package/src/generators/ngrx/files/classes-syntax/__directory__/__fileName__.reducer.spec.ts__tmpl__
DELETED
|
@@ -1,32 +0,0 @@
|
|
|
1
|
-
import { <%= className %>Loaded } from './<%= fileName %>.actions';
|
|
2
|
-
import { <%= className %>State, <%= className %>Entity, initial<%= className %>State, <%= propertyName %>Reducer } from './<%= fileName %>.reducer';
|
|
3
|
-
|
|
4
|
-
describe('<%= className %> Reducer', () => {
|
|
5
|
-
const get<%= className %>Id = (it: <%= className %>Entity) => it.id;
|
|
6
|
-
const create<%= className %> = (id: string, name = ''): <%= className %>Entity => ({
|
|
7
|
-
id,
|
|
8
|
-
name: name || `name-${id}`
|
|
9
|
-
});
|
|
10
|
-
|
|
11
|
-
describe('valid <%= className %> actions', () => {
|
|
12
|
-
it('should return the list of known <%= className %>', () => {
|
|
13
|
-
const <%= propertyName %> = [create<%= className %>('PRODUCT-AAA'), create<%= className %>('PRODUCT-zzz')];
|
|
14
|
-
const action = new <%= className %>Loaded(<%= propertyName %>);
|
|
15
|
-
const result: <%= className %>State = <%= propertyName %>Reducer(initial<%= className %>State, action);
|
|
16
|
-
const selId: string = get<%= className %>Id(result.list[1]);
|
|
17
|
-
|
|
18
|
-
expect(result.loaded).toBe(true);
|
|
19
|
-
expect(result.list.length).toBe(2);
|
|
20
|
-
expect(selId).toBe('PRODUCT-zzz');
|
|
21
|
-
});
|
|
22
|
-
});
|
|
23
|
-
|
|
24
|
-
describe('unknown action', () => {
|
|
25
|
-
it('should return the previous state', () => {
|
|
26
|
-
const action = {} as any;
|
|
27
|
-
const result = <%= propertyName %>Reducer(initial<%= className %>State, action);
|
|
28
|
-
|
|
29
|
-
expect(result).toBe(initial<%= className %>State);
|
|
30
|
-
});
|
|
31
|
-
});
|
|
32
|
-
});
|
package/src/generators/ngrx/files/classes-syntax/__directory__/__fileName__.reducer.ts__tmpl__
DELETED
|
@@ -1,47 +0,0 @@
|
|
|
1
|
-
import { <%= className %>Action, <%= className %>ActionTypes } from './<%= fileName %>.actions';
|
|
2
|
-
|
|
3
|
-
export const <%= constantName %>_FEATURE_KEY = '<%= propertyName %>';
|
|
4
|
-
|
|
5
|
-
/**
|
|
6
|
-
* Interface for the '<%= className %>' data used in
|
|
7
|
-
* - <%= className %>State, and the reducer function
|
|
8
|
-
*
|
|
9
|
-
* Note: replace if already defined in another module
|
|
10
|
-
*/
|
|
11
|
-
export interface <%= className %>Entity {
|
|
12
|
-
id: string;
|
|
13
|
-
name: string;
|
|
14
|
-
}
|
|
15
|
-
|
|
16
|
-
export interface <%= className %>State {
|
|
17
|
-
list: <%= className %>Entity[]; // list of <%= className %>; analogous to a sql normalized table
|
|
18
|
-
selectedId?: string | number; // which <%= className %> record has been selected
|
|
19
|
-
loaded: boolean; // has the <%= className %> list been loaded
|
|
20
|
-
error?: any; // last none error (if any)
|
|
21
|
-
};
|
|
22
|
-
|
|
23
|
-
export interface <%= className %>PartialState {
|
|
24
|
-
readonly [<%= constantName %>_FEATURE_KEY]: <%= className %>State;
|
|
25
|
-
}
|
|
26
|
-
|
|
27
|
-
export const initial<%= className %>State: <%= className %>State = {
|
|
28
|
-
list: [],
|
|
29
|
-
loaded: false
|
|
30
|
-
};
|
|
31
|
-
|
|
32
|
-
export function <%= propertyName %>Reducer(
|
|
33
|
-
state: <%= className %>State = initial<%= className %>State,
|
|
34
|
-
action: <%= className %>Action): <%= className %>State
|
|
35
|
-
{
|
|
36
|
-
switch (action.type) {
|
|
37
|
-
case <%= className %>ActionTypes.<%= className %>Loaded: {
|
|
38
|
-
state = {
|
|
39
|
-
...state,
|
|
40
|
-
list: action.payload,
|
|
41
|
-
loaded: true
|
|
42
|
-
};
|
|
43
|
-
break;
|
|
44
|
-
}
|
|
45
|
-
}
|
|
46
|
-
return state;
|
|
47
|
-
}
|
|
@@ -1,57 +0,0 @@
|
|
|
1
|
-
import { <%= className %>Entity, <%= className %>PartialState } from './<%= fileName %>.reducer';
|
|
2
|
-
import { <%= propertyName %>Query } from './<%= fileName %>.selectors';
|
|
3
|
-
|
|
4
|
-
describe('<%= className %> Selectors', () => {
|
|
5
|
-
const ERROR_MSG = 'No Error Available';
|
|
6
|
-
const get<%= className %>Id = (it: <%= className %>Entity) => it.id;
|
|
7
|
-
|
|
8
|
-
let storeState: <%= className %>PartialState;
|
|
9
|
-
|
|
10
|
-
beforeEach(() => {
|
|
11
|
-
const create<%= className %> = (id: string, name = ''): <%= className %>Entity => ({
|
|
12
|
-
id,
|
|
13
|
-
name: name || `name-${id}`
|
|
14
|
-
});
|
|
15
|
-
storeState = {
|
|
16
|
-
<%= propertyName %>: {
|
|
17
|
-
list : [
|
|
18
|
-
create<%= className %>('PRODUCT-AAA'),
|
|
19
|
-
create<%= className %>('PRODUCT-BBB'),
|
|
20
|
-
create<%= className %>('PRODUCT-CCC')
|
|
21
|
-
],
|
|
22
|
-
selectedId: 'PRODUCT-BBB',
|
|
23
|
-
error: ERROR_MSG,
|
|
24
|
-
loaded: true
|
|
25
|
-
}
|
|
26
|
-
};
|
|
27
|
-
});
|
|
28
|
-
|
|
29
|
-
describe('<%= className %> Selectors', () => {
|
|
30
|
-
it('getAll<%= className %>() should return the list of <%= className %>', () => {
|
|
31
|
-
const results = <%= propertyName %>Query.getAll<%= className %>(storeState);
|
|
32
|
-
const selId = get<%= className %>Id(results[1]);
|
|
33
|
-
|
|
34
|
-
expect(results.length).toBe(3);
|
|
35
|
-
expect(selId).toBe('PRODUCT-BBB');
|
|
36
|
-
});
|
|
37
|
-
|
|
38
|
-
it('getSelected<%= className %>() should return the selected <%= className %>Entity', () => {
|
|
39
|
-
const result = <%= propertyName %>Query.getSelected<%= className %>(storeState) as <%= className %>Entity;
|
|
40
|
-
const selId = get<%= className %>Id(result);
|
|
41
|
-
|
|
42
|
-
expect(selId).toBe('PRODUCT-BBB');
|
|
43
|
-
});
|
|
44
|
-
|
|
45
|
-
it('getLoaded() should return the current "loaded" status', () => {
|
|
46
|
-
const result = <%= propertyName %>Query.getLoaded(storeState);
|
|
47
|
-
|
|
48
|
-
expect(result).toBe(true);
|
|
49
|
-
});
|
|
50
|
-
|
|
51
|
-
it('getError() should return the current "error" storeState', () => {
|
|
52
|
-
const result = <%= propertyName %>Query.getError(storeState);
|
|
53
|
-
|
|
54
|
-
expect(result).toBe(ERROR_MSG);
|
|
55
|
-
});
|
|
56
|
-
});
|
|
57
|
-
});
|
package/src/generators/ngrx/files/classes-syntax/__directory__/__fileName__.selectors.ts__tmpl__
DELETED
|
@@ -1,24 +0,0 @@
|
|
|
1
|
-
import { createFeatureSelector, createSelector } from '@ngrx/store';
|
|
2
|
-
import { <%= constantName %>_FEATURE_KEY, <%= className %>State } from './<%= fileName %>.reducer';
|
|
3
|
-
|
|
4
|
-
// Lookup the '<%= className %>' feature state managed by NgRx
|
|
5
|
-
const get<%= className %>State = createFeatureSelector<<%= className %>State>(<%= constantName %>_FEATURE_KEY);
|
|
6
|
-
|
|
7
|
-
const getLoaded = createSelector( get<%= className %>State, (state:<%= className %>State) => state.loaded );
|
|
8
|
-
const getError = createSelector( get<%= className %>State, (state:<%= className %>State) => state.error );
|
|
9
|
-
|
|
10
|
-
const getAll<%= className %> = createSelector( get<%= className %>State, getLoaded, (state:<%= className %>State, isLoaded) => {
|
|
11
|
-
return isLoaded ? state.list : [ ];
|
|
12
|
-
});
|
|
13
|
-
const getSelectedId = createSelector( get<%= className %>State, (state:<%= className %>State) => state.selectedId );
|
|
14
|
-
const getSelected<%= className %> = createSelector( getAll<%= className %>, getSelectedId, (<%= propertyName %>, id) => {
|
|
15
|
-
const result = <%= propertyName %>.find(it => it['id'] === id);
|
|
16
|
-
return result ? Object.assign({}, result) : undefined;
|
|
17
|
-
});
|
|
18
|
-
|
|
19
|
-
export const <%= propertyName %>Query = {
|
|
20
|
-
getLoaded,
|
|
21
|
-
getError,
|
|
22
|
-
getAll<%= className %>,
|
|
23
|
-
getSelected<%= className %>
|
|
24
|
-
};
|