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.
- package/README.md +259 -0
- package/bundles/ngrx-entity-crud.umd.js +1829 -0
- package/bundles/ngrx-entity-crud.umd.js.map +1 -0
- package/esm2015/lib/actions.js +88 -0
- package/esm2015/lib/base-crud-gql.service.js +71 -0
- package/esm2015/lib/base-crud.service.js +136 -0
- package/esm2015/lib/create_adapter.js +14 -0
- package/esm2015/lib/effect.js +467 -0
- package/esm2015/lib/entity_state.js +23 -0
- package/esm2015/lib/ibase-crud-service.js +2 -0
- package/esm2015/lib/j-ngrx-filter.js +133 -0
- package/esm2015/lib/models.js +17 -0
- package/esm2015/lib/reducer.js +353 -0
- package/esm2015/lib/state_selectors.js +56 -0
- package/esm2015/lib/utils.js +19 -0
- package/esm2015/ngrx-entity-crud.js +5 -0
- package/esm2015/public-api.js +7 -0
- package/fesm2015/ngrx-entity-crud.js +1367 -0
- package/fesm2015/ngrx-entity-crud.js.map +1 -0
- package/lib/actions.d.ts +5 -0
- package/lib/actions.d.ts.map +1 -0
- package/lib/base-crud-gql.service.d.ts +19 -0
- package/lib/base-crud-gql.service.d.ts.map +1 -0
- package/lib/base-crud.service.d.ts +34 -0
- package/lib/base-crud.service.d.ts.map +1 -0
- package/lib/create_adapter.d.ts +6 -0
- package/lib/create_adapter.d.ts.map +1 -0
- package/lib/effect.d.ts +132 -0
- package/lib/effect.d.ts.map +1 -0
- package/lib/entity_state.d.ts +9 -0
- package/lib/entity_state.d.ts.map +1 -0
- package/lib/ibase-crud-service.d.ts +13 -0
- package/lib/ibase-crud-service.d.ts.map +1 -0
- package/lib/j-ngrx-filter.d.ts +14 -0
- package/lib/j-ngrx-filter.d.ts.map +1 -0
- package/lib/models.d.ts +494 -0
- package/lib/models.d.ts.map +1 -0
- package/lib/reducer.d.ts +11 -0
- package/lib/reducer.d.ts.map +1 -0
- package/lib/state_selectors.d.ts +5 -0
- package/lib/state_selectors.d.ts.map +1 -0
- package/lib/utils.d.ts +8 -0
- package/lib/utils.d.ts.map +1 -0
- package/ngrx-entity-crud.d.ts +5 -0
- package/ngrx-entity-crud.d.ts.map +1 -0
- package/ngrx-entity-crud.metadata.json +1 -0
- package/package.json +41 -0
- package/public-api.d.ts +7 -0
- package/public-api.d.ts.map +1 -0
- package/schematics/auth/files/model/auth.ts +17 -0
- package/schematics/auth/files/store/auth-store/actions.ts +30 -0
- package/schematics/auth/files/store/auth-store/auth-mock.service.ts +95 -0
- package/schematics/auth/files/store/auth-store/auth-store.module.ts +34 -0
- package/schematics/auth/files/store/auth-store/auth.guard.ts +44 -0
- package/schematics/auth/files/store/auth-store/auth.service.ts +28 -0
- package/schematics/auth/files/store/auth-store/conf.ts +2 -0
- package/schematics/auth/files/store/auth-store/effects.ts +53 -0
- package/schematics/auth/files/store/auth-store/index.d.ts +13 -0
- package/schematics/auth/files/store/auth-store/index.ts +13 -0
- package/schematics/auth/files/store/auth-store/names.ts +3 -0
- package/schematics/auth/files/store/auth-store/reducer.ts +16 -0
- package/schematics/auth/files/store/auth-store/selectors.ts +51 -0
- package/schematics/auth/files/store/auth-store/state.ts +16 -0
- package/schematics/auth/files/views/login/components/logout-button/logout-button.component.ts +49 -0
- package/schematics/auth/files/views/login/login-main/login-main.component.html +25 -0
- package/schematics/auth/files/views/login/login-main/login-main.component.ts +57 -0
- package/schematics/auth/files/views/login/login-routing.module.ts +30 -0
- package/schematics/auth/files/views/login/login.module.ts +30 -0
- package/schematics/auth/index.d.ts +2 -0
- package/schematics/auth/index.js +77 -0
- package/schematics/auth/index.js.map +1 -0
- package/schematics/auth/schema.json +21 -0
- package/schematics/auth0/files/store/auth-store/actions.ts +21 -0
- package/schematics/auth0/files/store/auth-store/auth-store.module.ts +32 -0
- package/schematics/auth0/files/store/auth-store/auth.guard.ts +44 -0
- package/schematics/auth0/files/store/auth-store/authentication.service.ts +32 -0
- package/schematics/auth0/files/store/auth-store/conf.ts +2 -0
- package/schematics/auth0/files/store/auth-store/effects.ts +59 -0
- package/schematics/auth0/files/store/auth-store/index.d.ts +13 -0
- package/schematics/auth0/files/store/auth-store/index.ts +13 -0
- package/schematics/auth0/files/store/auth-store/login.component.ts +75 -0
- package/schematics/auth0/files/store/auth-store/names.ts +3 -0
- package/schematics/auth0/files/store/auth-store/profile.ts +12 -0
- package/schematics/auth0/files/store/auth-store/reducer.ts +23 -0
- package/schematics/auth0/files/store/auth-store/selectors.ts +24 -0
- package/schematics/auth0/files/store/auth-store/state.ts +11 -0
- package/schematics/auth0/index.d.ts +2 -0
- package/schematics/auth0/index.js +67 -0
- package/schematics/auth0/index.js.map +1 -0
- package/schematics/auth0/schema.json +21 -0
- package/schematics/collection.json +30 -0
- package/schematics/my-utility.d.ts +58 -0
- package/schematics/my-utility.js +257 -0
- package/schematics/my-utility.js.map +1 -0
- package/schematics/ng-add/files/root-store/index.d.ts +8 -0
- package/schematics/ng-add/files/root-store/index.ts +8 -0
- package/schematics/ng-add/files/root-store/root-reducer.ts +11 -0
- package/schematics/ng-add/files/root-store/root-store.module.ts +29 -0
- package/schematics/ng-add/files/root-store/router-store/actions.ts +27 -0
- package/schematics/ng-add/files/root-store/router-store/effects.ts +65 -0
- package/schematics/ng-add/files/root-store/router-store/index.d.ts +11 -0
- package/schematics/ng-add/files/root-store/router-store/index.ts +11 -0
- package/schematics/ng-add/files/root-store/router-store/pop-up-base.component.ts +83 -0
- package/schematics/ng-add/files/root-store/router-store/pop-up-base.module.ts +24 -0
- package/schematics/ng-add/files/root-store/router-store/reducer.ts +31 -0
- package/schematics/ng-add/files/root-store/router-store/router-store.module.ts +30 -0
- package/schematics/ng-add/files/root-store/router-store/selectors.ts +63 -0
- package/schematics/ng-add/files/root-store/router-store/state.ts +18 -0
- package/schematics/ng-add/files/root-store/selectors.ts +20 -0
- package/schematics/ng-add/files/root-store/slide-menu-store/actions.ts +11 -0
- package/schematics/ng-add/files/root-store/slide-menu-store/effects.ts +10 -0
- package/schematics/ng-add/files/root-store/slide-menu-store/index.d.ts +13 -0
- package/schematics/ng-add/files/root-store/slide-menu-store/index.ts +13 -0
- package/schematics/ng-add/files/root-store/slide-menu-store/names.ts +3 -0
- package/schematics/ng-add/files/root-store/slide-menu-store/operators.ts +24 -0
- package/schematics/ng-add/files/root-store/slide-menu-store/reducer.ts +8 -0
- package/schematics/ng-add/files/root-store/slide-menu-store/selectors.ts +41 -0
- package/schematics/ng-add/files/root-store/slide-menu-store/slide-menu-store.module.ts +27 -0
- package/schematics/ng-add/files/root-store/slide-menu-store/state.ts +14 -0
- package/schematics/ng-add/files/root-store/state.ts +5 -0
- package/schematics/ng-add/index.d.ts +2 -0
- package/schematics/ng-add/index.js +78 -0
- package/schematics/ng-add/index.js.map +1 -0
- package/schematics/ng-add/schema.json +22 -0
- package/schematics/section/files/ionic/__clazz@dasherize__/__clazz@dasherize__-edit/__clazz@dasherize__-edit.component.html +52 -0
- package/schematics/section/files/ionic/__clazz@dasherize__/__clazz@dasherize__-edit/__clazz@dasherize__-edit.component.ts +57 -0
- package/schematics/section/files/ionic/__clazz@dasherize__/__clazz@dasherize__-list/__clazz@dasherize__-list.component.html +7 -0
- package/schematics/section/files/ionic/__clazz@dasherize__/__clazz@dasherize__-list/__clazz@dasherize__-list.component.ts +50 -0
- package/schematics/section/files/ionic/__clazz@dasherize__/__clazz@dasherize__-main/__clazz@dasherize__-main.component.html +15 -0
- package/schematics/section/files/ionic/__clazz@dasherize__/__clazz@dasherize__-main/__clazz@dasherize__-main.component.ts +23 -0
- package/schematics/section/files/ionic/__clazz@dasherize__/__clazz@dasherize__-routing.module.ts +36 -0
- package/schematics/section/files/ionic/__clazz@dasherize__/__clazz@dasherize__.module.ts +33 -0
- package/schematics/section/files/no-libs/__clazz@dasherize__/__clazz@dasherize__-edit/__clazz@dasherize__-edit.component.html +1 -0
- package/schematics/section/files/no-libs/__clazz@dasherize__/__clazz@dasherize__-edit/__clazz@dasherize__-edit.component.ts +16 -0
- package/schematics/section/files/no-libs/__clazz@dasherize__/__clazz@dasherize__-list/__clazz@dasherize__-list.component.html +1 -0
- package/schematics/section/files/no-libs/__clazz@dasherize__/__clazz@dasherize__-list/__clazz@dasherize__-list.component.ts +27 -0
- package/schematics/section/files/no-libs/__clazz@dasherize__/__clazz@dasherize__-main/__clazz@dasherize__-main.component.html +1 -0
- package/schematics/section/files/no-libs/__clazz@dasherize__/__clazz@dasherize__-main/__clazz@dasherize__-main.component.ts +18 -0
- package/schematics/section/files/no-libs/__clazz@dasherize__/__clazz@dasherize__-routing.module.ts +36 -0
- package/schematics/section/files/no-libs/__clazz@dasherize__/__clazz@dasherize__.module.ts +26 -0
- package/schematics/section/files/primeng/__clazz@dasherize__/__clazz@dasherize__-edit/__clazz@dasherize__-edit.component.html +38 -0
- package/schematics/section/files/primeng/__clazz@dasherize__/__clazz@dasherize__-edit/__clazz@dasherize__-edit.component.ts +50 -0
- package/schematics/section/files/primeng/__clazz@dasherize__/__clazz@dasherize__-list/__clazz@dasherize__-list.component.html +30 -0
- package/schematics/section/files/primeng/__clazz@dasherize__/__clazz@dasherize__-list/__clazz@dasherize__-list.component.ts +101 -0
- package/schematics/section/files/primeng/__clazz@dasherize__/__clazz@dasherize__-main/__clazz@dasherize__-main.component.html +12 -0
- package/schematics/section/files/primeng/__clazz@dasherize__/__clazz@dasherize__-main/__clazz@dasherize__-main.component.ts +21 -0
- package/schematics/section/files/primeng/__clazz@dasherize__/__clazz@dasherize__-routing.module.ts +37 -0
- package/schematics/section/files/primeng/__clazz@dasherize__/__clazz@dasherize__.module.ts +49 -0
- package/schematics/section/files/primeng/__clazz@dasherize__/components/button-create-many-test-__clazz@dasherize__.component.ts +46 -0
- package/schematics/section/files/primeng/__clazz@dasherize__/components/button-delete-__clazz@dasherize__.component.ts +35 -0
- package/schematics/section/files/primeng/__clazz@dasherize__/components/button-edit-many-test-__clazz@dasherize__.component.ts +45 -0
- package/schematics/section/files/primeng/__clazz@dasherize__/components/button-new-__clazz@dasherize__.component.ts +45 -0
- package/schematics/section/index.d.ts +2 -0
- package/schematics/section/index.js +56 -0
- package/schematics/section/index.js.map +1 -0
- package/schematics/section/schema.json +39 -0
- package/schematics/store/files/base-model/__clazz@dasherize__.ts +8 -0
- package/schematics/store/files/base-store/__clazz@dasherize__-store/__clazz@dasherize__-store.module.ts +26 -0
- package/schematics/store/files/base-store/__clazz@dasherize__-store/__clazz@dasherize__.actions.ts +9 -0
- package/schematics/store/files/base-store/__clazz@dasherize__-store/__clazz@dasherize__.effects.ts +11 -0
- package/schematics/store/files/base-store/__clazz@dasherize__-store/__clazz@dasherize__.names.ts +3 -0
- package/schematics/store/files/base-store/__clazz@dasherize__-store/__clazz@dasherize__.reducer.ts +8 -0
- package/schematics/store/files/base-store/__clazz@dasherize__-store/__clazz@dasherize__.selectors.ts +18 -0
- package/schematics/store/files/base-store/__clazz@dasherize__-store/__clazz@dasherize__.state.ts +6 -0
- package/schematics/store/files/base-store/__clazz@dasherize__-store/index.d.ts +13 -0
- package/schematics/store/files/base-store/__clazz@dasherize__-store/index.ts +13 -0
- package/schematics/store/files/crud-graphql/__clazz@dasherize__-store/__clazz@dasherize__.criteria.ts +39 -0
- package/schematics/store/files/crud-graphql/__clazz@dasherize__-store/__clazz@dasherize__.graphql +34 -0
- package/schematics/store/files/crud-model/__clazz@dasherize__.ts +8 -0
- package/schematics/store/files/crud-service/__clazz@dasherize__.service.ts +11 -0
- package/schematics/store/files/crud-service-graphql/__clazz@dasherize__.service.ts +16 -0
- package/schematics/store/files/crud-store/__clazz@dasherize__-store/__clazz@dasherize__-store.module.ts +26 -0
- package/schematics/store/files/crud-store/__clazz@dasherize__-store/__clazz@dasherize__.actions.ts +55 -0
- package/schematics/store/files/crud-store/__clazz@dasherize__-store/__clazz@dasherize__.effects.ts +90 -0
- package/schematics/store/files/crud-store/__clazz@dasherize__-store/__clazz@dasherize__.names.ts +3 -0
- package/schematics/store/files/crud-store/__clazz@dasherize__-store/__clazz@dasherize__.reducer.ts +103 -0
- package/schematics/store/files/crud-store/__clazz@dasherize__-store/__clazz@dasherize__.selectors.ts +26 -0
- package/schematics/store/files/crud-store/__clazz@dasherize__-store/__clazz@dasherize__.state.ts +11 -0
- package/schematics/store/files/crud-store/__clazz@dasherize__-store/index.d.ts +15 -0
- package/schematics/store/files/crud-store/__clazz@dasherize__-store/index.ts +15 -0
- package/schematics/store/index.d.ts +2 -0
- package/schematics/store/index.js +100 -0
- package/schematics/store/index.js.map +1 -0
- package/schematics/store/schema.json +45 -0
package/schematics/store/files/crud-store/__clazz@dasherize__-store/__clazz@dasherize__.reducer.ts
ADDED
|
@@ -0,0 +1,103 @@
|
|
|
1
|
+
import {actions} from './<%= dasherize(clazz) %>.actions';
|
|
2
|
+
import {adapter, initialState} from './<%= dasherize(clazz) %>.state';
|
|
3
|
+
|
|
4
|
+
export const featureReducer = adapter.createCrudReducer(initialState, actions);
|
|
5
|
+
|
|
6
|
+
/*
|
|
7
|
+
// example code
|
|
8
|
+
const predicate = (criteria: ICriteria) => (value) => {
|
|
9
|
+
const {queryParams} = criteria;
|
|
10
|
+
// return value.companyId === queryParams.companyId;
|
|
11
|
+
return true;
|
|
12
|
+
};
|
|
13
|
+
|
|
14
|
+
// example code
|
|
15
|
+
const customSearchSuccessOn = on(actions.SearchSuccess, (state: State, {type, items, request}) => {
|
|
16
|
+
const newState = adapter.removeMany(
|
|
17
|
+
predicate(request),
|
|
18
|
+
{
|
|
19
|
+
...state,
|
|
20
|
+
isLoaded: true,
|
|
21
|
+
isLoading: false,
|
|
22
|
+
error: null
|
|
23
|
+
}
|
|
24
|
+
);
|
|
25
|
+
|
|
26
|
+
return adapter.addMany(
|
|
27
|
+
items, newState
|
|
28
|
+
);
|
|
29
|
+
});
|
|
30
|
+
|
|
31
|
+
// example code
|
|
32
|
+
const {
|
|
33
|
+
responseOn,
|
|
34
|
+
resetResponsesOn,
|
|
35
|
+
searchRequestOn,
|
|
36
|
+
deleteRequestOn,
|
|
37
|
+
deleteManyRequestOn,
|
|
38
|
+
editRequestOn,
|
|
39
|
+
editManyRequestOn,
|
|
40
|
+
createRequestOn,
|
|
41
|
+
createManyRequestOn,
|
|
42
|
+
selectRequestOn,
|
|
43
|
+
searchSuccessOn,
|
|
44
|
+
deleteSuccessOn,
|
|
45
|
+
deleteManySuccessOn,
|
|
46
|
+
createSuccessOn,
|
|
47
|
+
createManySuccessOn,
|
|
48
|
+
selectSuccessOn,
|
|
49
|
+
editSuccessOn,
|
|
50
|
+
editManySuccessOn,
|
|
51
|
+
searchFailureOn,
|
|
52
|
+
deleteFailureOn,
|
|
53
|
+
deleteManyFailureOn,
|
|
54
|
+
createFailureOn,
|
|
55
|
+
createManyFailureOn,
|
|
56
|
+
selectFailureOn,
|
|
57
|
+
editFailureOn,
|
|
58
|
+
editManyFailureOn,
|
|
59
|
+
resetOn,
|
|
60
|
+
filtersOn,
|
|
61
|
+
selectItemsOn,
|
|
62
|
+
selectItemOn,
|
|
63
|
+
editOn,
|
|
64
|
+
createOn,
|
|
65
|
+
deleteOn
|
|
66
|
+
} = createCrudOns(adapter, initialState, actions);
|
|
67
|
+
|
|
68
|
+
export const featureReducer = createReducer<State>(initialState,
|
|
69
|
+
responseOn,
|
|
70
|
+
resetResponsesOn,
|
|
71
|
+
searchRequestOn,
|
|
72
|
+
deleteRequestOn,
|
|
73
|
+
deleteManyRequestOn,
|
|
74
|
+
editRequestOn,
|
|
75
|
+
editManyRequestOn,
|
|
76
|
+
createRequestOn,
|
|
77
|
+
createManyRequestOn,
|
|
78
|
+
selectRequestOn,
|
|
79
|
+
searchSuccessOn,
|
|
80
|
+
deleteSuccessOn,
|
|
81
|
+
deleteManySuccessOn,
|
|
82
|
+
createSuccessOn,
|
|
83
|
+
createManySuccessOn,
|
|
84
|
+
selectSuccessOn,
|
|
85
|
+
editSuccessOn,
|
|
86
|
+
editManySuccessOn,
|
|
87
|
+
searchFailureOn,
|
|
88
|
+
deleteFailureOn,
|
|
89
|
+
deleteManyFailureOn,
|
|
90
|
+
createFailureOn,
|
|
91
|
+
createManyFailureOn,
|
|
92
|
+
selectFailureOn,
|
|
93
|
+
editFailureOn,
|
|
94
|
+
editManyFailureOn,
|
|
95
|
+
resetOn,
|
|
96
|
+
filtersOn,
|
|
97
|
+
selectItemsOn,
|
|
98
|
+
selectItemOn,
|
|
99
|
+
editOn,
|
|
100
|
+
createOn,
|
|
101
|
+
deleteOn
|
|
102
|
+
);
|
|
103
|
+
*/
|
package/schematics/store/files/crud-store/__clazz@dasherize__-store/__clazz@dasherize__.selectors.ts
ADDED
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import {createFeatureSelector, MemoizedSelector} from '@ngrx/store';
|
|
2
|
+
|
|
3
|
+
import {adapter, State} from './<%= dasherize(clazz) %>.state';
|
|
4
|
+
import {Names} from './<%= dasherize(clazz) %>.names';
|
|
5
|
+
|
|
6
|
+
export const selectState: MemoizedSelector<object, State> = createFeatureSelector<State>(Names.NAME);
|
|
7
|
+
export const {
|
|
8
|
+
selectIds,
|
|
9
|
+
selectEntities,
|
|
10
|
+
selectAll,
|
|
11
|
+
selectTotal,
|
|
12
|
+
selectItemSelected,
|
|
13
|
+
selectItemsSelected,
|
|
14
|
+
selectLastCriteria,
|
|
15
|
+
selectError,
|
|
16
|
+
selectIsLoading,
|
|
17
|
+
selectIsLoaded,
|
|
18
|
+
selectFilters,
|
|
19
|
+
selectFilteredItems,
|
|
20
|
+
selectIdSelected,
|
|
21
|
+
selectIdsSelected,
|
|
22
|
+
selectItemSelectedOrigin,
|
|
23
|
+
selectEntitiesSelected,
|
|
24
|
+
selectItemsSelectedOrigin,
|
|
25
|
+
selectResponses,
|
|
26
|
+
} = adapter.getCrudSelectors(selectState);
|
package/schematics/store/files/crud-store/__clazz@dasherize__-store/__clazz@dasherize__.state.ts
ADDED
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import {createCrudEntityAdapter, EntityCrudAdapter, EntityCrudState} from 'ngrx-entity-crud';
|
|
2
|
+
import {<%= clazz %>} from '@models/vo/<%= dasherize(clazz) %>';
|
|
3
|
+
|
|
4
|
+
export const adapter: EntityCrudAdapter<<%= clazz %>> = createCrudEntityAdapter<<%= clazz %>>({
|
|
5
|
+
selectId: model => <%= clazz %>.selectId(model),
|
|
6
|
+
});
|
|
7
|
+
|
|
8
|
+
export interface State extends EntityCrudState<<%= clazz %>> {
|
|
9
|
+
};
|
|
10
|
+
|
|
11
|
+
export const initialState: State = adapter.getInitialCrudState();
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import * as <%= clazz %>StoreActions from './<%= dasherize(clazz) %>.actions';
|
|
2
|
+
import * as <%= clazz %>StoreSelectors from './<%= dasherize(clazz) %>.selectors';
|
|
3
|
+
import * as <%= clazz %>Criteria from './<%= dasherize(clazz) %>.criteria';
|
|
4
|
+
import * as <%= clazz %>StoreState from './<%= dasherize(clazz) %>.state';
|
|
5
|
+
|
|
6
|
+
export {
|
|
7
|
+
<%= clazz %>StoreModule
|
|
8
|
+
} from './<%= dasherize(clazz) %>-store.module';
|
|
9
|
+
|
|
10
|
+
export {
|
|
11
|
+
<%= clazz %>StoreActions,
|
|
12
|
+
<%= clazz %>StoreSelectors,
|
|
13
|
+
<%= clazz %>Criteria,
|
|
14
|
+
<%= clazz %>StoreState
|
|
15
|
+
};
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import * as <%= clazz %>StoreActions from './<%= dasherize(clazz) %>.actions';
|
|
2
|
+
import * as <%= clazz %>StoreSelectors from './<%= dasherize(clazz) %>.selectors';
|
|
3
|
+
import * as <%= clazz %>Criteria from './<%= dasherize(clazz) %>.criteria';
|
|
4
|
+
import * as <%= clazz %>StoreState from './<%= dasherize(clazz) %>.state';
|
|
5
|
+
|
|
6
|
+
export {
|
|
7
|
+
<%= clazz %>StoreModule
|
|
8
|
+
} from './<%= dasherize(clazz) %>-store.module';
|
|
9
|
+
|
|
10
|
+
export {
|
|
11
|
+
<%= clazz %>StoreActions,
|
|
12
|
+
<%= clazz %>StoreSelectors,
|
|
13
|
+
<%= clazz %>Criteria,
|
|
14
|
+
<%= clazz %>StoreState
|
|
15
|
+
};
|
|
@@ -0,0 +1,100 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.makeStore = 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 makeStore(options) {
|
|
8
|
+
return (tree, _context) => {
|
|
9
|
+
console.log('makeStore(options: CrudStore): Rule');
|
|
10
|
+
options.clazz = core_1.strings.classify(options.clazz);
|
|
11
|
+
options.name = options.name ? core_1.strings.underscore(options.name) : core_1.strings.underscore(options.clazz);
|
|
12
|
+
const workspaceConfig = tree.read('/angular.json');
|
|
13
|
+
if (!workspaceConfig) {
|
|
14
|
+
throw new schematics_1.SchematicsException('Could not find Angular workspace configuration');
|
|
15
|
+
}
|
|
16
|
+
// convert workspace to string
|
|
17
|
+
const workspaceContent = workspaceConfig.toString();
|
|
18
|
+
// parse workspace string into JSON object
|
|
19
|
+
const workspace = JSON.parse(workspaceContent);
|
|
20
|
+
if (!options.project) {
|
|
21
|
+
options.project = workspace.defaultProject;
|
|
22
|
+
}
|
|
23
|
+
let pathApp = 'src/app';
|
|
24
|
+
let pathStore = 'src/app/root-store';
|
|
25
|
+
let pathView = 'src/app/main/views';
|
|
26
|
+
let pathService = 'src/app/main/services';
|
|
27
|
+
let pathVo = 'src/app/main/models/vo/';
|
|
28
|
+
const conf = tree.read('/ngrx-entity-crud.conf.json');
|
|
29
|
+
if (conf) {
|
|
30
|
+
const confData = JSON.parse(conf.toString());
|
|
31
|
+
pathView = confData.pathView;
|
|
32
|
+
pathStore = confData.pathStore;
|
|
33
|
+
pathApp = confData.pathApp;
|
|
34
|
+
pathService = confData.pathService;
|
|
35
|
+
pathVo = confData.pathVo;
|
|
36
|
+
}
|
|
37
|
+
console.log('pathView', pathView);
|
|
38
|
+
console.log('pathStore', pathStore);
|
|
39
|
+
console.log('pathApp', pathApp);
|
|
40
|
+
console.log('pathService', pathService);
|
|
41
|
+
console.log('pathVo', pathVo);
|
|
42
|
+
const genericRules = [
|
|
43
|
+
my_utility_1.addExport(options, core_1.normalize(`${pathStore}/index.ts`)),
|
|
44
|
+
my_utility_1.addExport(options, core_1.normalize(`${pathStore}/index.d.ts`)),
|
|
45
|
+
];
|
|
46
|
+
const crudRules = [
|
|
47
|
+
my_utility_1.addImport(core_1.normalize(`${pathStore}/state.ts`), `import {${options.clazz}StoreState} from '@root-store/${core_1.strings.dasherize(options.clazz)}-store';`),
|
|
48
|
+
my_utility_1.updateState(`${core_1.strings.underscore(options.name)}:${options.clazz}StoreState.State;`, core_1.normalize(`${pathStore}/state.ts`)),
|
|
49
|
+
my_utility_1.addImport(core_1.normalize(`${pathStore}/selectors.ts`), `import {${options.clazz}StoreSelectors} from '@root-store/${core_1.strings.dasherize(options.clazz)}-store';`),
|
|
50
|
+
my_utility_1.addRootSelector(options, core_1.normalize(`${pathStore}/selectors.ts`)),
|
|
51
|
+
my_utility_1.render(options, './files/crud-store', pathStore),
|
|
52
|
+
my_utility_1.render(options, './files/crud-model', pathVo),
|
|
53
|
+
my_utility_1.addDeclarationToNgModule({
|
|
54
|
+
module: `${pathStore}/root-store.module.ts`,
|
|
55
|
+
name: `${options.clazz}Store`,
|
|
56
|
+
path: `@root-store/${core_1.strings.dasherize(options.clazz)}-store`
|
|
57
|
+
})
|
|
58
|
+
];
|
|
59
|
+
const baseRules = [
|
|
60
|
+
my_utility_1.addImport(core_1.normalize(`${pathStore}/state.ts`), `import {${options.clazz}} from '@models/vo/${core_1.strings.dasherize(options.clazz)}';`),
|
|
61
|
+
my_utility_1.updateState(`${core_1.strings.underscore(options.name)}:${options.clazz};`, core_1.normalize(`${pathStore}/state.ts`)),
|
|
62
|
+
my_utility_1.render(options, './files/base-store', pathStore),
|
|
63
|
+
my_utility_1.render(options, './files/base-model', pathVo),
|
|
64
|
+
my_utility_1.addDeclarationToNgModule({
|
|
65
|
+
module: `${pathStore}/root-store.module.ts`,
|
|
66
|
+
name: `${options.clazz}Store`,
|
|
67
|
+
path: `@root-store/${core_1.strings.dasherize(options.clazz)}-store`
|
|
68
|
+
})
|
|
69
|
+
];
|
|
70
|
+
if (options.type === 'CRUD+GRAPHQL') {
|
|
71
|
+
const graphqlSchema = tree.read('/graphql.schema.json');
|
|
72
|
+
if (!graphqlSchema) {
|
|
73
|
+
throw new schematics_1.SchematicsException('Could not find graphql.schema.json configuration');
|
|
74
|
+
}
|
|
75
|
+
const graphqlSchemaString = graphqlSchema.toString();
|
|
76
|
+
const graphqlSchemaJson = JSON.parse(graphqlSchemaString);
|
|
77
|
+
console.log('graphqlSchemaJson', graphqlSchemaJson);
|
|
78
|
+
const types = graphqlSchemaJson.__schema.types;
|
|
79
|
+
const itemType = types.find(value => value.kind === 'OBJECT' && value.name === options.clazz);
|
|
80
|
+
if (!itemType) {
|
|
81
|
+
throw new schematics_1.SchematicsException("Could not find \"" + options.clazz + "\" in graphql.schema.json configuration, update shema");
|
|
82
|
+
}
|
|
83
|
+
const fields = itemType.fields.map(value => value.name);
|
|
84
|
+
console.log('fieldsB', fields);
|
|
85
|
+
const optionsGQL = Object.assign(Object.assign({}, options), { gqlSchema: { fields } });
|
|
86
|
+
return schematics_1.chain([...genericRules, ...crudRules,
|
|
87
|
+
my_utility_1.render(optionsGQL, './files/crud-graphql', pathStore),
|
|
88
|
+
my_utility_1.render(options, './files/crud-service-graphql', pathService),
|
|
89
|
+
]);
|
|
90
|
+
}
|
|
91
|
+
if (options.type === 'CRUD') {
|
|
92
|
+
return schematics_1.chain([...genericRules, ...crudRules, my_utility_1.render(options, './files/crud-service', pathService),]);
|
|
93
|
+
}
|
|
94
|
+
if (options.type === 'BASE') {
|
|
95
|
+
return schematics_1.chain([...genericRules, ...baseRules]);
|
|
96
|
+
}
|
|
97
|
+
};
|
|
98
|
+
}
|
|
99
|
+
exports.makeStore = makeStore;
|
|
100
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../projects/ngrx-entity-crud/schematics/store/index.ts"],"names":[],"mappings":";;;AAAA,2DAAoG;AACpG,+CAAwD;AACxD,8CAAmH;AAEnH,SAAgB,SAAS,CAAC,OAAkB;IAC1C,OAAO,CAAC,IAAU,EAAE,QAA0B,EAAE,EAAE;QAChD,OAAO,CAAC,GAAG,CAAC,qCAAqC,CAAC,CAAC;QACnD,OAAO,CAAC,KAAK,GAAG,cAAO,CAAC,QAAQ,CAAC,OAAO,CAAC,KAAK,CAAC,CAAC;QAChD,OAAO,CAAC,IAAI,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,cAAO,CAAC,UAAU,CAAC,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,cAAO,CAAC,UAAU,CAAC,OAAO,CAAC,KAAK,CAAC,CAAC;QACnG,MAAM,eAAe,GAAG,IAAI,CAAC,IAAI,CAAC,eAAe,CAAC,CAAC;QACnD,IAAI,CAAC,eAAe,EAAE;YACpB,MAAM,IAAI,gCAAmB,CAAC,gDAAgD,CAAC,CAAC;SACjF;QAED,8BAA8B;QAC9B,MAAM,gBAAgB,GAAG,eAAe,CAAC,QAAQ,EAAE,CAAC;QAEpD,0CAA0C;QAC1C,MAAM,SAAS,GAAG,IAAI,CAAC,KAAK,CAAC,gBAAgB,CAAC,CAAC;QAC/C,IAAI,CAAC,OAAO,CAAC,OAAO,EAAE;YACpB,OAAO,CAAC,OAAO,GAAG,SAAS,CAAC,cAAc,CAAC;SAC5C;QAED,IAAI,OAAO,GAAW,SAAS,CAAC;QAChC,IAAI,SAAS,GAAW,oBAAoB,CAAC;QAC7C,IAAI,QAAQ,GAAW,oBAAoB,CAAC;QAC5C,IAAI,WAAW,GAAW,uBAAuB,CAAC;QAClD,IAAI,MAAM,GAAW,yBA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QACD,IAAI,OAAO,CAAC,IAAI,KAAK,MAAM,EAAE;YAC3B,OAAO,kBAAK,CAAC,CAAC,GAAG,YAAY,EAAE,GAAG,SAAS,EAAE,mBAAM,CAAC,OAAO,EAAE,sBAAsB,EAAE,WAAW,CAAC,EAAE,CAAC,CAAC;SACtG;QACD,IAAI,OAAO,CAAC,IAAI,KAAK,MAAM,EAAE;YAC3B,OAAO,kBAAK,CAAC,CAAC,GAAG,YAAY,EAAE,GAAG,SAAS,CAAC,CAAC,CAAC;SAC/C;IAEH,CAAC,CAAC;AACJ,CAAC;AApGD,8BAoGC"}
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
{
|
|
2
|
+
"$schema": "http://json-schema.org/schema",
|
|
3
|
+
"id": "CrudStore",
|
|
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
|
+
"name": {
|
|
19
|
+
"description": "The feature name.",
|
|
20
|
+
"type": "string",
|
|
21
|
+
"x-prompt": "Enter the feature name:"
|
|
22
|
+
},
|
|
23
|
+
"type": {
|
|
24
|
+
"description": "choose the store type, crud or base",
|
|
25
|
+
"type": "string",
|
|
26
|
+
"default": "CRUD",
|
|
27
|
+
"enum": [
|
|
28
|
+
"CRUD",
|
|
29
|
+
"CRUD+GRAPHQL",
|
|
30
|
+
"BASE"
|
|
31
|
+
],
|
|
32
|
+
"x-prompt": "choose the store type, crud or base."
|
|
33
|
+
},
|
|
34
|
+
"project": {
|
|
35
|
+
"type": "string",
|
|
36
|
+
"description": "The name of the project.",
|
|
37
|
+
"$default": {
|
|
38
|
+
"$source": "projectName"
|
|
39
|
+
}
|
|
40
|
+
}
|
|
41
|
+
},
|
|
42
|
+
"required": [
|
|
43
|
+
"name", "clazz", "type"
|
|
44
|
+
]
|
|
45
|
+
}
|