ngrx-entity-crud 12.0.6-beta.2

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.
Files changed (184) hide show
  1. package/README.md +259 -0
  2. package/bundles/ngrx-entity-crud.umd.js +1829 -0
  3. package/bundles/ngrx-entity-crud.umd.js.map +1 -0
  4. package/esm2015/lib/actions.js +88 -0
  5. package/esm2015/lib/base-crud-gql.service.js +71 -0
  6. package/esm2015/lib/base-crud.service.js +136 -0
  7. package/esm2015/lib/create_adapter.js +14 -0
  8. package/esm2015/lib/effect.js +467 -0
  9. package/esm2015/lib/entity_state.js +23 -0
  10. package/esm2015/lib/ibase-crud-service.js +2 -0
  11. package/esm2015/lib/j-ngrx-filter.js +133 -0
  12. package/esm2015/lib/models.js +17 -0
  13. package/esm2015/lib/reducer.js +353 -0
  14. package/esm2015/lib/state_selectors.js +56 -0
  15. package/esm2015/lib/utils.js +19 -0
  16. package/esm2015/ngrx-entity-crud.js +5 -0
  17. package/esm2015/public-api.js +7 -0
  18. package/fesm2015/ngrx-entity-crud.js +1367 -0
  19. package/fesm2015/ngrx-entity-crud.js.map +1 -0
  20. package/lib/actions.d.ts +5 -0
  21. package/lib/actions.d.ts.map +1 -0
  22. package/lib/base-crud-gql.service.d.ts +19 -0
  23. package/lib/base-crud-gql.service.d.ts.map +1 -0
  24. package/lib/base-crud.service.d.ts +34 -0
  25. package/lib/base-crud.service.d.ts.map +1 -0
  26. package/lib/create_adapter.d.ts +6 -0
  27. package/lib/create_adapter.d.ts.map +1 -0
  28. package/lib/effect.d.ts +132 -0
  29. package/lib/effect.d.ts.map +1 -0
  30. package/lib/entity_state.d.ts +9 -0
  31. package/lib/entity_state.d.ts.map +1 -0
  32. package/lib/ibase-crud-service.d.ts +13 -0
  33. package/lib/ibase-crud-service.d.ts.map +1 -0
  34. package/lib/j-ngrx-filter.d.ts +14 -0
  35. package/lib/j-ngrx-filter.d.ts.map +1 -0
  36. package/lib/models.d.ts +494 -0
  37. package/lib/models.d.ts.map +1 -0
  38. package/lib/reducer.d.ts +11 -0
  39. package/lib/reducer.d.ts.map +1 -0
  40. package/lib/state_selectors.d.ts +5 -0
  41. package/lib/state_selectors.d.ts.map +1 -0
  42. package/lib/utils.d.ts +8 -0
  43. package/lib/utils.d.ts.map +1 -0
  44. package/ngrx-entity-crud.d.ts +5 -0
  45. package/ngrx-entity-crud.d.ts.map +1 -0
  46. package/ngrx-entity-crud.metadata.json +1 -0
  47. package/package.json +41 -0
  48. package/public-api.d.ts +7 -0
  49. package/public-api.d.ts.map +1 -0
  50. package/schematics/auth/files/model/auth.ts +17 -0
  51. package/schematics/auth/files/store/auth-store/actions.ts +30 -0
  52. package/schematics/auth/files/store/auth-store/auth-mock.service.ts +95 -0
  53. package/schematics/auth/files/store/auth-store/auth-store.module.ts +34 -0
  54. package/schematics/auth/files/store/auth-store/auth.guard.ts +44 -0
  55. package/schematics/auth/files/store/auth-store/auth.service.ts +28 -0
  56. package/schematics/auth/files/store/auth-store/conf.ts +2 -0
  57. package/schematics/auth/files/store/auth-store/effects.ts +53 -0
  58. package/schematics/auth/files/store/auth-store/index.d.ts +13 -0
  59. package/schematics/auth/files/store/auth-store/index.ts +13 -0
  60. package/schematics/auth/files/store/auth-store/names.ts +3 -0
  61. package/schematics/auth/files/store/auth-store/reducer.ts +16 -0
  62. package/schematics/auth/files/store/auth-store/selectors.ts +51 -0
  63. package/schematics/auth/files/store/auth-store/state.ts +16 -0
  64. package/schematics/auth/files/views/login/components/logout-button/logout-button.component.ts +49 -0
  65. package/schematics/auth/files/views/login/login-main/login-main.component.html +25 -0
  66. package/schematics/auth/files/views/login/login-main/login-main.component.ts +57 -0
  67. package/schematics/auth/files/views/login/login-routing.module.ts +30 -0
  68. package/schematics/auth/files/views/login/login.module.ts +30 -0
  69. package/schematics/auth/index.d.ts +2 -0
  70. package/schematics/auth/index.js +77 -0
  71. package/schematics/auth/index.js.map +1 -0
  72. package/schematics/auth/schema.json +21 -0
  73. package/schematics/auth0/files/store/auth-store/actions.ts +21 -0
  74. package/schematics/auth0/files/store/auth-store/auth-store.module.ts +32 -0
  75. package/schematics/auth0/files/store/auth-store/auth.guard.ts +44 -0
  76. package/schematics/auth0/files/store/auth-store/authentication.service.ts +32 -0
  77. package/schematics/auth0/files/store/auth-store/conf.ts +2 -0
  78. package/schematics/auth0/files/store/auth-store/effects.ts +59 -0
  79. package/schematics/auth0/files/store/auth-store/index.d.ts +13 -0
  80. package/schematics/auth0/files/store/auth-store/index.ts +13 -0
  81. package/schematics/auth0/files/store/auth-store/login.component.ts +75 -0
  82. package/schematics/auth0/files/store/auth-store/names.ts +3 -0
  83. package/schematics/auth0/files/store/auth-store/profile.ts +12 -0
  84. package/schematics/auth0/files/store/auth-store/reducer.ts +23 -0
  85. package/schematics/auth0/files/store/auth-store/selectors.ts +24 -0
  86. package/schematics/auth0/files/store/auth-store/state.ts +11 -0
  87. package/schematics/auth0/index.d.ts +2 -0
  88. package/schematics/auth0/index.js +67 -0
  89. package/schematics/auth0/index.js.map +1 -0
  90. package/schematics/auth0/schema.json +21 -0
  91. package/schematics/collection.json +30 -0
  92. package/schematics/my-utility.d.ts +58 -0
  93. package/schematics/my-utility.js +257 -0
  94. package/schematics/my-utility.js.map +1 -0
  95. package/schematics/ng-add/files/root-store/index.d.ts +8 -0
  96. package/schematics/ng-add/files/root-store/index.ts +8 -0
  97. package/schematics/ng-add/files/root-store/root-reducer.ts +11 -0
  98. package/schematics/ng-add/files/root-store/root-store.module.ts +29 -0
  99. package/schematics/ng-add/files/root-store/router-store/actions.ts +27 -0
  100. package/schematics/ng-add/files/root-store/router-store/effects.ts +65 -0
  101. package/schematics/ng-add/files/root-store/router-store/index.d.ts +11 -0
  102. package/schematics/ng-add/files/root-store/router-store/index.ts +11 -0
  103. package/schematics/ng-add/files/root-store/router-store/pop-up-base.component.ts +83 -0
  104. package/schematics/ng-add/files/root-store/router-store/pop-up-base.module.ts +24 -0
  105. package/schematics/ng-add/files/root-store/router-store/reducer.ts +31 -0
  106. package/schematics/ng-add/files/root-store/router-store/router-store.module.ts +30 -0
  107. package/schematics/ng-add/files/root-store/router-store/selectors.ts +63 -0
  108. package/schematics/ng-add/files/root-store/router-store/state.ts +18 -0
  109. package/schematics/ng-add/files/root-store/selectors.ts +20 -0
  110. package/schematics/ng-add/files/root-store/slide-menu-store/actions.ts +11 -0
  111. package/schematics/ng-add/files/root-store/slide-menu-store/effects.ts +10 -0
  112. package/schematics/ng-add/files/root-store/slide-menu-store/index.d.ts +13 -0
  113. package/schematics/ng-add/files/root-store/slide-menu-store/index.ts +13 -0
  114. package/schematics/ng-add/files/root-store/slide-menu-store/names.ts +3 -0
  115. package/schematics/ng-add/files/root-store/slide-menu-store/operators.ts +24 -0
  116. package/schematics/ng-add/files/root-store/slide-menu-store/reducer.ts +8 -0
  117. package/schematics/ng-add/files/root-store/slide-menu-store/selectors.ts +41 -0
  118. package/schematics/ng-add/files/root-store/slide-menu-store/slide-menu-store.module.ts +27 -0
  119. package/schematics/ng-add/files/root-store/slide-menu-store/state.ts +14 -0
  120. package/schematics/ng-add/files/root-store/state.ts +5 -0
  121. package/schematics/ng-add/index.d.ts +2 -0
  122. package/schematics/ng-add/index.js +78 -0
  123. package/schematics/ng-add/index.js.map +1 -0
  124. package/schematics/ng-add/schema.json +22 -0
  125. package/schematics/section/files/ionic/__clazz@dasherize__/__clazz@dasherize__-edit/__clazz@dasherize__-edit.component.html +52 -0
  126. package/schematics/section/files/ionic/__clazz@dasherize__/__clazz@dasherize__-edit/__clazz@dasherize__-edit.component.ts +57 -0
  127. package/schematics/section/files/ionic/__clazz@dasherize__/__clazz@dasherize__-list/__clazz@dasherize__-list.component.html +7 -0
  128. package/schematics/section/files/ionic/__clazz@dasherize__/__clazz@dasherize__-list/__clazz@dasherize__-list.component.ts +50 -0
  129. package/schematics/section/files/ionic/__clazz@dasherize__/__clazz@dasherize__-main/__clazz@dasherize__-main.component.html +15 -0
  130. package/schematics/section/files/ionic/__clazz@dasherize__/__clazz@dasherize__-main/__clazz@dasherize__-main.component.ts +23 -0
  131. package/schematics/section/files/ionic/__clazz@dasherize__/__clazz@dasherize__-routing.module.ts +36 -0
  132. package/schematics/section/files/ionic/__clazz@dasherize__/__clazz@dasherize__.module.ts +33 -0
  133. package/schematics/section/files/no-libs/__clazz@dasherize__/__clazz@dasherize__-edit/__clazz@dasherize__-edit.component.html +1 -0
  134. package/schematics/section/files/no-libs/__clazz@dasherize__/__clazz@dasherize__-edit/__clazz@dasherize__-edit.component.ts +16 -0
  135. package/schematics/section/files/no-libs/__clazz@dasherize__/__clazz@dasherize__-list/__clazz@dasherize__-list.component.html +1 -0
  136. package/schematics/section/files/no-libs/__clazz@dasherize__/__clazz@dasherize__-list/__clazz@dasherize__-list.component.ts +27 -0
  137. package/schematics/section/files/no-libs/__clazz@dasherize__/__clazz@dasherize__-main/__clazz@dasherize__-main.component.html +1 -0
  138. package/schematics/section/files/no-libs/__clazz@dasherize__/__clazz@dasherize__-main/__clazz@dasherize__-main.component.ts +18 -0
  139. package/schematics/section/files/no-libs/__clazz@dasherize__/__clazz@dasherize__-routing.module.ts +36 -0
  140. package/schematics/section/files/no-libs/__clazz@dasherize__/__clazz@dasherize__.module.ts +26 -0
  141. package/schematics/section/files/primeng/__clazz@dasherize__/__clazz@dasherize__-edit/__clazz@dasherize__-edit.component.html +38 -0
  142. package/schematics/section/files/primeng/__clazz@dasherize__/__clazz@dasherize__-edit/__clazz@dasherize__-edit.component.ts +50 -0
  143. package/schematics/section/files/primeng/__clazz@dasherize__/__clazz@dasherize__-list/__clazz@dasherize__-list.component.html +30 -0
  144. package/schematics/section/files/primeng/__clazz@dasherize__/__clazz@dasherize__-list/__clazz@dasherize__-list.component.ts +101 -0
  145. package/schematics/section/files/primeng/__clazz@dasherize__/__clazz@dasherize__-main/__clazz@dasherize__-main.component.html +12 -0
  146. package/schematics/section/files/primeng/__clazz@dasherize__/__clazz@dasherize__-main/__clazz@dasherize__-main.component.ts +21 -0
  147. package/schematics/section/files/primeng/__clazz@dasherize__/__clazz@dasherize__-routing.module.ts +37 -0
  148. package/schematics/section/files/primeng/__clazz@dasherize__/__clazz@dasherize__.module.ts +49 -0
  149. package/schematics/section/files/primeng/__clazz@dasherize__/components/button-create-many-test-__clazz@dasherize__.component.ts +46 -0
  150. package/schematics/section/files/primeng/__clazz@dasherize__/components/button-delete-__clazz@dasherize__.component.ts +35 -0
  151. package/schematics/section/files/primeng/__clazz@dasherize__/components/button-edit-many-test-__clazz@dasherize__.component.ts +45 -0
  152. package/schematics/section/files/primeng/__clazz@dasherize__/components/button-new-__clazz@dasherize__.component.ts +45 -0
  153. package/schematics/section/index.d.ts +2 -0
  154. package/schematics/section/index.js +56 -0
  155. package/schematics/section/index.js.map +1 -0
  156. package/schematics/section/schema.json +39 -0
  157. package/schematics/store/files/base-model/__clazz@dasherize__.ts +8 -0
  158. package/schematics/store/files/base-store/__clazz@dasherize__-store/__clazz@dasherize__-store.module.ts +26 -0
  159. package/schematics/store/files/base-store/__clazz@dasherize__-store/__clazz@dasherize__.actions.ts +9 -0
  160. package/schematics/store/files/base-store/__clazz@dasherize__-store/__clazz@dasherize__.effects.ts +11 -0
  161. package/schematics/store/files/base-store/__clazz@dasherize__-store/__clazz@dasherize__.names.ts +3 -0
  162. package/schematics/store/files/base-store/__clazz@dasherize__-store/__clazz@dasherize__.reducer.ts +8 -0
  163. package/schematics/store/files/base-store/__clazz@dasherize__-store/__clazz@dasherize__.selectors.ts +18 -0
  164. package/schematics/store/files/base-store/__clazz@dasherize__-store/__clazz@dasherize__.state.ts +6 -0
  165. package/schematics/store/files/base-store/__clazz@dasherize__-store/index.d.ts +13 -0
  166. package/schematics/store/files/base-store/__clazz@dasherize__-store/index.ts +13 -0
  167. package/schematics/store/files/crud-graphql/__clazz@dasherize__-store/__clazz@dasherize__.criteria.ts +39 -0
  168. package/schematics/store/files/crud-graphql/__clazz@dasherize__-store/__clazz@dasherize__.graphql +34 -0
  169. package/schematics/store/files/crud-model/__clazz@dasherize__.ts +8 -0
  170. package/schematics/store/files/crud-service/__clazz@dasherize__.service.ts +11 -0
  171. package/schematics/store/files/crud-service-graphql/__clazz@dasherize__.service.ts +16 -0
  172. package/schematics/store/files/crud-store/__clazz@dasherize__-store/__clazz@dasherize__-store.module.ts +26 -0
  173. package/schematics/store/files/crud-store/__clazz@dasherize__-store/__clazz@dasherize__.actions.ts +55 -0
  174. package/schematics/store/files/crud-store/__clazz@dasherize__-store/__clazz@dasherize__.effects.ts +90 -0
  175. package/schematics/store/files/crud-store/__clazz@dasherize__-store/__clazz@dasherize__.names.ts +3 -0
  176. package/schematics/store/files/crud-store/__clazz@dasherize__-store/__clazz@dasherize__.reducer.ts +103 -0
  177. package/schematics/store/files/crud-store/__clazz@dasherize__-store/__clazz@dasherize__.selectors.ts +26 -0
  178. package/schematics/store/files/crud-store/__clazz@dasherize__-store/__clazz@dasherize__.state.ts +11 -0
  179. package/schematics/store/files/crud-store/__clazz@dasherize__-store/index.d.ts +15 -0
  180. package/schematics/store/files/crud-store/__clazz@dasherize__-store/index.ts +15 -0
  181. package/schematics/store/index.d.ts +2 -0
  182. package/schematics/store/index.js +100 -0
  183. package/schematics/store/index.js.map +1 -0
  184. package/schematics/store/schema.json +45 -0
@@ -0,0 +1,45 @@
1
+ import {ChangeDetectionStrategy, Component, OnInit} from '@angular/core';
2
+ import {select, Store} from '@ngrx/store';
3
+ import {Observable} from 'rxjs';
4
+ import {<%= clazz %>StoreActions, <%= clazz %>StoreSelectors, RootStoreState} from '@root-store/index';
5
+ import {<%= clazz %>} from '@models/vo/<%= dasherize(clazz) %>';
6
+
7
+ @Component({
8
+ selector: 'app-button-edit-many-test-<%= dasherize(clazz) %>',
9
+ template: `
10
+ <button type="button" *ngLet="(itemsSelected$|async) as itemsSelected" pButton icon="pi pi-plus"
11
+ label="Edit many ({{itemsSelected.length}})" (click)="onEditMany(itemsSelected)"
12
+ [disabled]="!(itemsSelected.length > 0)"
13
+ class="p-button-success"></button>
14
+ `,
15
+ styles: [],
16
+ changeDetection: ChangeDetectionStrategy.OnPush
17
+ })
18
+ export class ButtonEditManyTest<%= clazz %>Component implements OnInit {
19
+
20
+ itemsSelected$: Observable<<%= clazz %>[]>;
21
+
22
+ constructor(private readonly store$: Store<RootStoreState.State>) {
23
+ }
24
+
25
+ ngOnInit(): void {
26
+ this.itemsSelected$ = this.store$.pipe(
27
+ select(<%= clazz %>StoreSelectors.selectItemsSelected)
28
+ );
29
+ }
30
+
31
+ onEditMany(values: <%= clazz %>[]): void {
32
+ const items = values.map(value => {
33
+ const keys = Object.keys(value);
34
+ const result = {...value};
35
+ keys.forEach(key => {
36
+ if (key !== 'id' && typeof result[key] === 'string') {
37
+ result[key] = result[key] + ' edited' + new Date().getSeconds();
38
+ }
39
+ });
40
+ return result;
41
+ });
42
+ this.store$.dispatch(<%= clazz %>StoreActions.EditManyRequest({items}));
43
+ }
44
+
45
+ }
@@ -0,0 +1,45 @@
1
+ import {ChangeDetectionStrategy, Component, OnInit} from '@angular/core';
2
+ import {Store} from '@ngrx/store';
3
+ import {Observable, of} from 'rxjs';
4
+ import {RouterStoreActions} from '@root-store/router-store/index';
5
+ import {PopUpData} from '@root-store/router-store/pop-up-base.component';
6
+ import {<%= clazz %>} from '@models/vo/<%= dasherize(clazz) %>';
7
+ import {RootStoreState} from '@root-store/index';
8
+
9
+ @Component({
10
+ selector: 'app-button-new-<%= dasherize(clazz) %>',
11
+ template: `
12
+ <button type="button" pButton icon="pi pi-plus"
13
+ label="New <%= clazz %>" (click)="onCreate()"
14
+ [disabled]="(disabled$ |async)"
15
+ class="p-button-success"></button>
16
+ `,
17
+ styles: [],
18
+ changeDetection: ChangeDetectionStrategy.OnPush
19
+ })
20
+ export class ButtonNew<%= clazz %>Component implements OnInit {
21
+
22
+ disabled$: Observable<boolean>;
23
+
24
+ constructor(private readonly store$: Store<RootStoreState.State>) {
25
+ }
26
+
27
+ ngOnInit() {
28
+ this.disabled$ = of(false);
29
+ }
30
+
31
+ onCreate() {
32
+ const item: <%= clazz %> = new <%= clazz %>();
33
+
34
+ const data: PopUpData<<%= clazz %>> = {
35
+ item,
36
+ props: {title: 'New <%= clazz %>', route: '<%= dasherize(clazz) %>'}
37
+ };
38
+
39
+ this.store$.dispatch(RouterStoreActions.RouterGoPopUp({
40
+ path: ['<%= dasherize(clazz) %>', {outlets: {popUp: ['edit']}}],
41
+ data
42
+ }));
43
+ }
44
+
45
+ }
@@ -0,0 +1,2 @@
1
+ import { Rule } from '@angular-devkit/schematics';
2
+ export declare function crudSection(options: CrudSection): Rule;
@@ -0,0 +1,56 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.crudSection = void 0;
4
+ const schematics_1 = require("@angular-devkit/schematics");
5
+ const core_1 = require("@angular-devkit/core");
6
+ const my_utility_1 = require("../my-utility");
7
+ function crudSection(options) {
8
+ return (tree, _context) => {
9
+ options.clazz = core_1.strings.classify(options.clazz);
10
+ const workspaceConfig = tree.read('/angular.json');
11
+ if (!workspaceConfig) {
12
+ throw new schematics_1.SchematicsException('Could not find Angular workspace configuration');
13
+ }
14
+ // convert workspace to string
15
+ const workspaceContent = workspaceConfig.toString();
16
+ // parse workspace string into JSON object
17
+ const workspace = JSON.parse(workspaceContent);
18
+ if (!options.project) {
19
+ options.project = workspace.defaultProject;
20
+ }
21
+ const projectName = options.project;
22
+ const project = workspace.projects[projectName];
23
+ const projectType = project.projectType === 'application' ? 'app' : 'lib';
24
+ options.path = `${project.sourceRoot}/${projectType}`;
25
+ const lib = options.lib;
26
+ let pathApp = 'src/app';
27
+ let pathStore = 'src/app/root-store';
28
+ let pathView = 'src/app/main/views';
29
+ let pathService = 'src/app/main/services';
30
+ let pathVo = 'src/app/main/models/vo/';
31
+ const conf = tree.read('/ngrx-entity-crud.conf.json');
32
+ if (conf) {
33
+ const confData = JSON.parse(conf.toString());
34
+ pathView = confData.pathView;
35
+ pathStore = confData.pathStore;
36
+ pathApp = confData.pathApp;
37
+ pathService = confData.pathService;
38
+ pathVo = confData.pathVo;
39
+ }
40
+ console.log('pathView', pathView);
41
+ console.log('pathStore', pathStore);
42
+ console.log('pathApp', pathApp);
43
+ console.log('pathService', pathService);
44
+ console.log('pathVo', pathVo);
45
+ console.log('lib: ', lib);
46
+ const _chain = [];
47
+ _chain.push(my_utility_1.render(options, `./files/${lib}`, pathView));
48
+ _chain.push(my_utility_1.addRouteDeclarationToNgModule({
49
+ module: `${pathApp}/app-routing.module.ts`,
50
+ routeLiteral: `{path: '${core_1.strings.dasherize(options.clazz)}', loadChildren: () => import('./main/views/${core_1.strings.dasherize(options.clazz)}/${core_1.strings.dasherize(options.clazz)}.module').then(m => m.${options.clazz}Module)}`
51
+ }));
52
+ return schematics_1.chain(_chain);
53
+ };
54
+ }
55
+ exports.crudSection = crudSection;
56
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../projects/ngrx-entity-crud/schematics/section/index.ts"],"names":[],"mappings":"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"}
@@ -0,0 +1,39 @@
1
+ {
2
+ "$schema": "http://json-schema.org/schema",
3
+ "id": "CrudSection",
4
+ "title": "Crud store schematics",
5
+ "type": "object",
6
+ "properties": {
7
+ "path": {
8
+ "type": "string",
9
+ "format": "path",
10
+ "description": "The path at which to create the component file, relative to the current workspace. Default is a folder with the same name as the component in the project root.",
11
+ "visible": false
12
+ },
13
+ "clazz": {
14
+ "description": "The name of the entity.",
15
+ "type": "string",
16
+ "x-prompt": "Enter the name of the entity:"
17
+ },
18
+ "lib": {
19
+ "description": "choose the library.",
20
+ "type": "string",
21
+ "enum": [
22
+ "primeng",
23
+ "no-libs"
24
+ ],
25
+ "x-prompt": "choose the library."
26
+ },
27
+ "project": {
28
+ "type": "string",
29
+ "description": "The name of the project.",
30
+ "$default": {
31
+ "$source": "projectName"
32
+ }
33
+ }
34
+ },
35
+ "required": [
36
+ "clazz",
37
+ "lib"
38
+ ]
39
+ }
@@ -0,0 +1,8 @@
1
+ export class <%= clazz %> {
2
+ /**
3
+ * example of attribute, to be replaced with whatever you want.
4
+ */
5
+ valueA: string;
6
+ valueB: string;
7
+ }
8
+
@@ -0,0 +1,26 @@
1
+ import {InjectionToken, NgModule} from '@angular/core';
2
+ import {CommonModule} from '@angular/common';
3
+ import {ActionReducer, StoreModule} from '@ngrx/store';
4
+ import {EffectsModule} from '@ngrx/effects';
5
+ import {<%= clazz %>StoreEffects} from './<%= dasherize(clazz) %>.effects';
6
+ import {featureReducer} from './<%= dasherize(clazz) %>.reducer';
7
+ import {<%= clazz %>} from '@models/vo/<%= dasherize(clazz) %>';
8
+ import {Names} from './<%= dasherize(clazz) %>.names';
9
+
10
+ export const INJECTION_TOKEN = new InjectionToken<ActionReducer<<%= clazz %>>>(`${Names.NAME}-store Reducers`);
11
+
12
+ @NgModule({
13
+ imports: [
14
+ CommonModule,
15
+ StoreModule.forFeature(Names.NAME, INJECTION_TOKEN),
16
+ EffectsModule.forFeature([<%= clazz %>StoreEffects]),
17
+ ],
18
+ declarations: [],
19
+ providers: [<%= clazz %>StoreEffects,
20
+ {
21
+ provide: INJECTION_TOKEN,
22
+ useFactory: (): ActionReducer<<%= clazz %>> => featureReducer
23
+ }]
24
+ })
25
+ export class <%= clazz %>StoreModule {
26
+ }
@@ -0,0 +1,9 @@
1
+ import {createAction, props} from '@ngrx/store';
2
+
3
+ export enum ActionTypes {
4
+ CHANGE_A = '[<%= clazz %>] Change A',
5
+ CHANGE_B = '[<%= clazz %>] Change b',
6
+ }
7
+
8
+ export const ChangeA = createAction(ActionTypes.CHANGE_A, props<{ valueA: string }>());
9
+ export const ChangeB = createAction(ActionTypes.CHANGE_B, props<{ valueB: string }>());
@@ -0,0 +1,11 @@
1
+ import {Injectable} from '@angular/core';
2
+ import {Actions} from '@ngrx/effects';
3
+ import {Action} from '@ngrx/store';
4
+ import * as actions from './__clazz@dasherize__.actions';
5
+ import {<%= clazz %>} from '@models/vo/<%= dasherize(clazz) %>';
6
+
7
+ @Injectable()
8
+ export class <%= clazz %>StoreEffects {
9
+ constructor(private readonly actions$: Actions) {
10
+ }
11
+ }
@@ -0,0 +1,3 @@
1
+ export class Names {
2
+ static NAME = '<%= name %>';
3
+ }
@@ -0,0 +1,8 @@
1
+ import {initialState} from './<%= dasherize(clazz) %>.state';
2
+ import {createReducer, on} from '@ngrx/store';
3
+ import * as actions from './<%= dasherize(clazz) %>.actions';
4
+
5
+ export const featureReducer = createReducer(initialState,
6
+ on(actions.ChangeA, (state, {valueA}) => ({...state, ...{valueA}})),
7
+ on(actions.ChangeB, (state, {valueB}) => ({...state, ...{valueB}})),
8
+ );
@@ -0,0 +1,18 @@
1
+ import {createFeatureSelector, createSelector, MemoizedSelector} from '@ngrx/store';
2
+ import {Names} from './<%= dasherize(clazz) %>.names';
3
+ import {<%= clazz %>} from '@models/vo/<%= dasherize(clazz) %>';
4
+
5
+ const getValueA = (state: <%= clazz %>): string => state.valueA;
6
+ const getValueB = (state: <%= clazz %>): string => state.valueB;
7
+
8
+ export const selectState: MemoizedSelector<object, <%= clazz %>> = createFeatureSelector<<%= clazz %>>(Names.NAME);
9
+
10
+ export const selectValueA: MemoizedSelector<object, string> = createSelector(
11
+ selectState,
12
+ getValueA
13
+ );
14
+
15
+ export const selectValueB: MemoizedSelector<object, string> = createSelector(
16
+ selectState,
17
+ getValueB
18
+ );
@@ -0,0 +1,6 @@
1
+ import {<%= clazz %>} from '@models/vo/<%= dasherize(clazz) %>';
2
+
3
+ export const initialState: <%= clazz %> = {
4
+ valueA: 'valueA',
5
+ valueB: 'valueB'
6
+ }
@@ -0,0 +1,13 @@
1
+ import * as <%= clazz %>StoreActions from './<%= dasherize(clazz) %>.actions';
2
+ import * as <%= clazz %>StoreSelectors from './<%= dasherize(clazz) %>.selectors';
3
+ import * as <%= clazz %>StoreState from './<%= dasherize(clazz) %>.state';
4
+
5
+ export {
6
+ <%= clazz %>StoreModule
7
+ } from './<%= dasherize(clazz) %>-store.module';
8
+
9
+ export {
10
+ <%= clazz %>StoreActions,
11
+ <%= clazz %>StoreSelectors,
12
+ <%= clazz %>StoreState
13
+ };
@@ -0,0 +1,13 @@
1
+ import * as <%= clazz %>StoreActions from './<%= dasherize(clazz) %>.actions';
2
+ import * as <%= clazz %>StoreSelectors from './<%= dasherize(clazz) %>.selectors';
3
+ import * as <%= clazz %>StoreState from './<%= dasherize(clazz) %>.state';
4
+
5
+ export {
6
+ <%= clazz %>StoreModule
7
+ } from './<%= dasherize(clazz) %>-store.module';
8
+
9
+ export {
10
+ <%= clazz %>StoreActions,
11
+ <%= clazz %>StoreSelectors,
12
+ <%= clazz %>StoreState
13
+ };
@@ -0,0 +1,39 @@
1
+ import {ICriteria} from 'ngrx-entity-crud';
2
+ import {QueryOptions} from '@apollo/client/core';
3
+ import {<%= clazz %>CreateDocument, <%= clazz %>CreateMutation, <%= clazz %>CreateMutationVariables, <%= clazz %>RemoveDocument, <%= clazz %>RemoveMutation, <%= clazz %>RemoveMutationVariables, <%= clazz %>SearchDocument, <%= clazz %>SearchQuery, <%= clazz %>SearchQueryVariables, <%= clazz %>SelectDocument, <%= clazz %>SelectQuery, <%= clazz %>SelectQueryVariables, <%= clazz %>UpdateDocument, <%= clazz %>UpdateMutation, <%= clazz %>UpdateMutationVariables} from '../graphql';
4
+
5
+ export const search = (variables: <%= clazz %>SearchQueryVariables): ICriteria<QueryOptions<<%= clazz %>SearchQueryVariables, <%= clazz %>SearchQuery>> => ({
6
+ queryParams: {
7
+ query: <%= clazz %>SearchDocument,
8
+ variables,
9
+ }
10
+ })
11
+
12
+ export const select = (variables: <%= clazz %>SelectQueryVariables): ICriteria<QueryOptions<<%= clazz %>SelectQueryVariables, <%= clazz %>SelectQuery>> => ({
13
+ queryParams: {
14
+ query: <%= clazz %>SelectDocument,
15
+ variables,
16
+ }
17
+ })
18
+
19
+ export const create = (variables: <%= clazz %>CreateMutationVariables): ICriteria<QueryOptions<<%= clazz %>CreateMutationVariables, <%= clazz %>CreateMutation>> => ({
20
+ queryParams: {
21
+ query: <%= clazz %>CreateDocument,
22
+ variables,
23
+ }
24
+ })
25
+
26
+ export const update = (variables: <%= clazz %>UpdateMutationVariables): ICriteria<QueryOptions<<%= clazz %>UpdateMutationVariables, <%= clazz %>UpdateMutation>> => ({
27
+ queryParams: {
28
+ query: <%= clazz %>UpdateDocument,
29
+ variables,
30
+ }
31
+ })
32
+
33
+ export const remove = (variables: <%= clazz %>RemoveMutationVariables): ICriteria<QueryOptions<<%= clazz %>RemoveMutationVariables, <%= clazz %>RemoveMutation>> => ({
34
+ queryParams: {
35
+ query: <%= clazz %>RemoveDocument,
36
+ variables,
37
+ }
38
+ })
39
+
@@ -0,0 +1,34 @@
1
+ fragment fieldsBase on <%= clazz %>{<% for(let field of gqlSchema.fields) { %>
2
+ <%= field %><% } %>
3
+ }
4
+
5
+ query <%= dasherize(clazz) %>Search($page: Int, $perPage: Int, $sortField:String, $sortOrder:String, $filter: <%= clazz %>Filter){
6
+ all<%= clazz %>s(page: $page, perPage: $perPage, sortField:$sortField, sortOrder:$sortOrder, filter:$filter) {
7
+ ...fieldsBase
8
+ }
9
+ }
10
+
11
+ query <%= dasherize(clazz) %>Select($id:ID!){
12
+ <%= clazz %>(id: $id) {
13
+ ...fieldsBase
14
+ }
15
+ }
16
+
17
+ mutation <%= dasherize(clazz) %>Create($name:String!, $localized_name:String!){
18
+ create<%= clazz %>(name: $name, localized_name: $localized_name){
19
+ ...fieldsBase
20
+ }
21
+ }
22
+
23
+
24
+ mutation <%= dasherize(clazz) %>Update($id:ID!, $name:String!, $localized_name:String!){
25
+ update<%= clazz %>(id:$id, name: $name, localized_name: $localized_name){
26
+ ...fieldsBase
27
+ }
28
+ }
29
+
30
+ mutation <%= dasherize(clazz) %>Remove($id:ID!){
31
+ remove<%= clazz %>(id:$id){
32
+ id
33
+ }
34
+ }
@@ -0,0 +1,8 @@
1
+ export class <%= clazz %> {
2
+ public id: string = undefined;
3
+ /**
4
+ * metodo statico utilizzato per recuperare l'id dell'entita.
5
+ * @param item
6
+ */
7
+ static selectId: (item: <%= clazz %>) => string = item => item.id;
8
+ }
@@ -0,0 +1,11 @@
1
+ import {Injectable} from '@angular/core';
2
+ import {<%= clazz %>} from '@models/vo/<%= dasherize(clazz) %>';
3
+ import {environment} from '../../../environments/environment';
4
+ import {BaseCrudService} from 'ngrx-entity-crud';
5
+
6
+ @Injectable({
7
+ providedIn: 'root'
8
+ })
9
+ export class <%= clazz %>Service extends BaseCrudService<<%= clazz %>> {
10
+ public service = environment.webServiceUri + '<%= dasherize(clazz) %>';
11
+ }
@@ -0,0 +1,16 @@
1
+ import {Injectable} from '@angular/core';
2
+ import {<%= clazz %>} from '@models/vo/<%= dasherize(clazz) %>';
3
+ import {environment} from '../../../environments/environment';
4
+ import {BaseCrudGqlService} from 'ngrx-entity-crud';
5
+ import {Apollo} from 'apollo-angular';
6
+
7
+ @Injectable({
8
+ providedIn: 'root'
9
+ })
10
+ export class <%= clazz %>Service extends BaseCrudGqlService<<%= clazz %>> {
11
+ public service = environment.webServiceUri + '<%= dasherize(clazz) %>';
12
+
13
+ constructor(private apolloA: Apollo) {
14
+ super.apollo = apollo;
15
+ }
16
+ }
@@ -0,0 +1,26 @@
1
+ import {InjectionToken, NgModule} from '@angular/core';
2
+ import {CommonModule} from '@angular/common';
3
+ import {ActionReducer, StoreModule} from '@ngrx/store';
4
+ import {EffectsModule} from '@ngrx/effects';
5
+ import {<%= clazz %>StoreEffects} from './<%= dasherize(clazz) %>.effects';
6
+ import {featureReducer} from './<%= dasherize(clazz) %>.reducer';
7
+ import {State} from './<%= dasherize(clazz) %>.state';
8
+ import {Names} from './<%= dasherize(clazz) %>.names';
9
+
10
+ export const INJECTION_TOKEN = new InjectionToken<ActionReducer<State>>(`${Names.NAME}-store Reducers`);
11
+
12
+ @NgModule({
13
+ imports: [
14
+ CommonModule,
15
+ StoreModule.forFeature(Names.NAME, INJECTION_TOKEN),
16
+ EffectsModule.forFeature([<%= clazz %>StoreEffects]),
17
+ ],
18
+ declarations: [],
19
+ providers: [<%= clazz %>StoreEffects,
20
+ {
21
+ provide: INJECTION_TOKEN,
22
+ useFactory: (): ActionReducer<State> => featureReducer
23
+ }]
24
+ })
25
+ export class <%= clazz %>StoreModule {
26
+ }
@@ -0,0 +1,55 @@
1
+ import {adapter} from './<%= dasherize(clazz) %>.state';
2
+ import {Names} from './<%= dasherize(clazz) %>.names';
3
+
4
+ export const actions = adapter.createCrudActions(Names.NAME);
5
+
6
+ export const {
7
+ Response,
8
+ ResetResponses,
9
+
10
+ SearchRequest,
11
+ SearchFailure,
12
+ SearchSuccess,
13
+
14
+ DeleteRequest,
15
+ DeleteFailure,
16
+ DeleteSuccess,
17
+
18
+ DeleteManyRequest,
19
+ DeleteManyFailure,
20
+ DeleteManySuccess,
21
+
22
+ CreateRequest,
23
+ CreateFailure,
24
+ CreateSuccess,
25
+
26
+ CreateManyRequest,
27
+ CreateManyFailure,
28
+ CreateManySuccess,
29
+
30
+ SelectRequest,
31
+ SelectFailure,
32
+ SelectSuccess,
33
+
34
+ EditRequest,
35
+ EditFailure,
36
+ EditSuccess,
37
+
38
+ EditManyRequest,
39
+ EditManyFailure,
40
+ EditManySuccess,
41
+
42
+ Reset,
43
+ Filters,
44
+ SelectItems,
45
+ AddManySelected,
46
+ RemoveManySelected,
47
+ RemoveAllSelected,
48
+ SelectItem,
49
+ Edit,
50
+ Create,
51
+ Delete,
52
+ } = actions;
53
+
54
+
55
+
@@ -0,0 +1,90 @@
1
+ import {Injectable} from '@angular/core';
2
+ import {Actions, createEffect, ofType} from '@ngrx/effects';
3
+ import {Observable} from 'rxjs';
4
+ import {Action} from '@ngrx/store';
5
+ import * as actions from './<%= dasherize(clazz) %>.actions';
6
+ import {<%= clazz %>} from '@models/vo/<%= dasherize(clazz) %>';
7
+ import {<%= clazz %>Service} from '@services/<%= dasherize(clazz) %>.service';
8
+ import {
9
+ createCall, createCatchError, createResponse,
10
+ createManyCall, createManyCatchError, createManyResponse,
11
+ deleteCall, deleteCatchError, deleteResponse,
12
+ deleteManyCall, deleteManyCatchError, deleteManyResponse,
13
+ editCall, editCatchError, editResponse,
14
+ editManyCall, editManyCatchError, editManyResponse,
15
+ searchCall, searchCatchError, searchResponse,
16
+ selectCall, selectCatchError, selectResponse
17
+ } from 'ngrx-entity-crud';
18
+ import {repeat} from 'rxjs/operators';
19
+
20
+ @Injectable()
21
+ export class <%= clazz %>StoreEffects {
22
+
23
+ searchRequestEffect$: Observable<Action> = createEffect(() => this.actions$.pipe(
24
+ ofType(actions.SearchRequest),
25
+ searchCall<<%= clazz %>>(this.service),
26
+ searchResponse<<%= clazz %>>(actions, {dispatchResponse: false}),
27
+ searchCatchError<<%= clazz %>>(actions),
28
+ repeat()
29
+ ));
30
+
31
+
32
+ deleteRequestEffect$: Observable<Action> = createEffect(() => this.actions$.pipe(
33
+ ofType(actions.DeleteRequest),
34
+ deleteCall<<%= clazz %>>(this.service),
35
+ deleteResponse<<%= clazz %>>(actions, <%= clazz %>, {dispatchResponse: false}),
36
+ deleteCatchError<<%= clazz %>>(actions),
37
+ repeat()
38
+ ));
39
+
40
+ deleteManyRequestEffect$: Observable<Action> = createEffect(() => this.actions$.pipe(
41
+ ofType(actions.DeleteManyRequest),
42
+ deleteManyCall<<%= clazz %>>(this.service),
43
+ deleteManyResponse<<%= clazz %>>(actions, <%= clazz %>, {dispatchResponse: false}),
44
+ deleteManyCatchError<<%= clazz %>>(actions),
45
+ repeat()
46
+ ));
47
+ createRequestEffect$: Observable<Action> = createEffect(() => this.actions$.pipe(
48
+ ofType(actions.CreateRequest),
49
+ createCall<<%= clazz %>>(this.service),
50
+ createResponse<<%= clazz %>>(actions, {dispatchResponse: false}),
51
+ createCatchError<<%= clazz %>>(actions),
52
+ repeat()
53
+ ));
54
+
55
+ createManyRequestEffect$: Observable<Action> = createEffect(() => this.actions$.pipe(
56
+ ofType(actions.CreateManyRequest),
57
+ createManyCall<<%= clazz %>>(this.service),
58
+ createManyResponse<<%= clazz %>>(actions, {dispatchResponse: false}),
59
+ createManyCatchError<<%= clazz %>>(actions),
60
+ repeat()
61
+ ));
62
+
63
+ editRequestEffect$: Observable<Action> = createEffect(() => this.actions$.pipe(
64
+ ofType(actions.EditRequest),
65
+ editCall<<%= clazz %>>(this.service),
66
+ editResponse<<%= clazz %>>(actions, {dispatchResponse: false}),
67
+ editCatchError<<%= clazz %>>(actions),
68
+ repeat()
69
+ ));
70
+
71
+ editManyRequestEffect$: Observable<Action> = createEffect(() => this.actions$.pipe(
72
+ ofType(actions.EditManyRequest),
73
+ editManyCall<<%= clazz %>>(this.service),
74
+ editManyResponse<<%= clazz %>>(actions, {dispatchResponse: false}),
75
+ editManyCatchError<<%= clazz %>>(actions),
76
+ repeat()
77
+ ));
78
+
79
+ selectRequestEffect$: Observable<Action> = createEffect(() => this.actions$.pipe(
80
+ ofType(actions.SelectRequest),
81
+ selectCall<<%= clazz %>>(this.service),
82
+ selectResponse<<%= clazz %>>(actions, {dispatchResponse: false}),
83
+ selectCatchError<<%= clazz %>>(actions),
84
+ repeat()
85
+ ));
86
+
87
+ constructor(private readonly actions$: Actions, private readonly service: <%= clazz %>Service) {
88
+ }
89
+
90
+ }
@@ -0,0 +1,3 @@
1
+ export class Names {
2
+ static NAME = '<%= name %>';
3
+ }