@tech4good/angular-schematics 17.0.4 → 18.0.0
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 +8 -0
- package/package.json +4 -4
- package/src/collection.json +0 -16
- package/src/component/files/__name@dasherize__/__name@dasherize__.component.ts.template +22 -8
- package/src/component/index.js +2 -45
- package/src/component/index.js.map +1 -1
- package/src/component/schema.json +0 -5
- package/src/entity/files/__name@dasherize__/__name@dasherize__.mock.ts.template +12 -0
- package/src/entity/files/__name@dasherize__/__name@dasherize__.model.ts.template +1 -0
- package/src/entity/files/__name@dasherize__/__name@dasherize__.store.ts.template +41 -0
- package/src/entity/index.js +29 -50
- package/src/entity/index.js.map +1 -1
- package/src/init/files/.firebaserc.template +8 -0
- package/src/init/files/README.md.template +6 -6
- package/src/init/files/angular.json.template +18 -11
- package/src/init/files/package.json.template +29 -30
- package/src/init/files/src/app/admin/{waitlist/waitlist.animations.ts.template → admin-panel/admin-panel.animations.ts.template} +1 -1
- package/src/init/files/src/app/admin/{waitlist/waitlist.component.html.template → admin-panel/admin-panel.component.html.template} +3 -3
- package/src/init/files/src/app/admin/{waitlist/waitlist.component.scss.template → admin-panel/admin-panel.component.scss.template} +1 -1
- package/src/init/files/src/app/admin/admin-panel/admin-panel.component.spec.ts.template +25 -0
- package/src/init/files/src/app/admin/admin-panel/admin-panel.component.ts.template +99 -0
- package/src/init/files/src/app/app.component.html.template +1 -0
- package/src/init/files/src/app/app.component.ts.template +14 -8
- package/src/init/files/src/app/app.config.ts.template +63 -0
- package/src/init/files/src/app/app.routes.ts.template +32 -0
- package/src/init/files/src/app/core/analytics/log.service.ts.template +122 -89
- package/src/init/files/src/app/core/analytics/time-analytics.service.ts.template +9 -17
- package/src/init/files/src/app/core/auth/auth.guard.ts.template +25 -22
- package/src/init/files/src/app/core/firebase/cached-listeners.service.ts.template +291 -0
- package/src/init/files/src/app/core/firebase/database.service.ts.template +56 -0
- package/src/init/files/src/app/core/firebase/firebase.mock.service.ts.template +276 -0
- package/src/init/files/src/app/core/firebase/firebase.service.ts.template +265 -215
- package/src/init/files/src/app/core/local-storage/session.service.ts.template +3 -4
- package/src/init/files/src/app/core/store/app.model.ts.template +19 -0
- package/src/init/files/src/app/core/store/app.store.ts.template +1074 -0
- package/src/init/files/src/app/core/store/auth/auth.mock.ts.template +20 -0
- package/src/init/files/src/app/core/store/auth/auth.store.ts.template +136 -0
- package/src/init/files/src/app/core/store/batch-write.firebase.service.ts.template +58 -0
- package/src/init/files/src/app/core/store/batch-write.mock.service.ts.template +105 -0
- package/src/init/files/src/app/core/store/batch-write.service.ts.template +126 -0
- package/src/init/files/src/app/core/store/user/user.mock.ts.template +24 -0
- package/src/init/files/src/app/core/store/user/user.model.ts.template +1 -1
- package/src/init/files/src/app/core/store/user/user.store.ts.template +41 -0
- package/src/init/files/src/app/core/store/user-context/user-context.mock.ts.template +24 -0
- package/src/init/files/src/app/core/store/user-context/user-context.model.ts.template +1 -0
- package/src/init/files/src/app/core/store/user-context/user-context.store.ts.template +41 -0
- package/src/init/files/src/app/core/utils/rand.utils.ts.template +13 -0
- package/src/init/files/src/app/{onboarding → first-time}/consent/consent.component.html.template +8 -13
- package/src/init/files/src/app/first-time/consent/consent.component.ts.template +90 -0
- package/src/init/files/src/app/first-time/early-access/early-access.animations.ts.template +4 -0
- package/src/init/files/src/app/first-time/early-access/early-access.component.html.template +69 -0
- package/src/init/files/src/app/{onboarding/waiting/waiting.component.scss.template → first-time/early-access/early-access.component.scss.template} +1 -1
- package/src/init/files/src/app/first-time/early-access/early-access.component.spec.ts.template +25 -0
- package/src/init/files/src/app/first-time/early-access/early-access.component.ts.template +194 -0
- package/src/init/files/src/app/first-time/early-access/early-access.model.ts.template +7 -0
- package/src/init/files/src/app/{general → first-time}/landing/landing.component.html.template +1 -1
- package/src/init/files/src/app/first-time/landing/landing.component.ts.template +44 -0
- package/src/init/files/src/app/first-time/login/login.component.html.template +10 -0
- package/src/init/files/src/app/first-time/login/login.component.ts.template +45 -0
- package/src/init/files/src/app/first-time/onboarding/onboarding.animations.ts.template +4 -0
- package/src/init/files/src/app/first-time/onboarding/onboarding.component.html.template +2 -0
- package/src/init/files/src/app/first-time/onboarding/onboarding.component.scss.template +5 -0
- package/src/init/files/src/app/{admin/waitlist/waitlist.component.spec.ts.template → first-time/onboarding/onboarding.component.spec.ts.template} +6 -6
- package/src/init/files/src/app/first-time/onboarding/onboarding.component.ts.template +41 -0
- package/src/init/files/src/app/main/home/home.component.html.template +5 -0
- package/src/init/files/src/app/main/home/home.component.ts.template +51 -0
- package/src/init/files/src/app/shared/navbar/navbar.component.html.template +15 -0
- package/src/init/files/src/app/shared/navbar/navbar.component.scss.template +43 -0
- package/src/init/files/src/app/shared/navbar/navbar.component.spec.ts.template +25 -0
- package/src/init/files/src/app/shared/navbar/navbar.component.ts.template +40 -0
- package/src/init/files/src/app/shared/redeployment-warning/redeployment-warning.component.html.template +9 -0
- package/src/init/files/src/app/shared/{components/redeployment-warning → redeployment-warning}/redeployment-warning.component.ts.template +17 -6
- package/src/init/files/src/app/shared/{components/redeployment-warning → redeployment-warning}/redeployment-warning.service.ts.template +2 -2
- package/src/init/files/src/assets/images/close-x.svg +3 -0
- package/src/init/files/src/environments/environment.ts.template +1 -0
- package/src/init/files/src/index.html.template +1 -1
- package/src/init/files/tsconfig.json.template +0 -1
- package/src/container/files/__name@dasherize__/+state/__name@dasherize__.actions.ts.template +0 -26
- package/src/container/files/__name@dasherize__/+state/__name@dasherize__.effects.ts.template +0 -48
- package/src/container/files/__name@dasherize__/+state/__name@dasherize__.model.ts.template +0 -0
- package/src/container/files/__name@dasherize__/+state/__name@dasherize__.selectors.ts.template +0 -20
- package/src/container/files/__name@dasherize__/+state/__name@dasherize__.state.ts.template +0 -13
- package/src/container/files/__name@dasherize__/__name@dasherize__.animations.ts.template +0 -4
- package/src/container/files/__name@dasherize__/__name@dasherize__.component.html.template +0 -3
- package/src/container/files/__name@dasherize__/__name@dasherize__.component.scss.template +0 -5
- package/src/container/files/__name@dasherize__/__name@dasherize__.component.spec.ts.template +0 -25
- package/src/container/files/__name@dasherize__/__name@dasherize__.component.ts.template +0 -90
- package/src/container/index.d.ts +0 -2
- package/src/container/index.js +0 -127
- package/src/container/index.js.map +0 -1
- package/src/container/index_spec.d.ts +0 -1
- package/src/container/index_spec.js +0 -23
- package/src/container/index_spec.js.map +0 -1
- package/src/container/schema.json +0 -50
- package/src/entity/files/__name@dasherize__/__name@dasherize__.actions.ts.template +0 -249
- package/src/entity/files/__name@dasherize__/__name@dasherize__.effects.ts.template +0 -131
- package/src/entity/files/__name@dasherize__/__name@dasherize__.reducer.spec.ts.template +0 -13
- package/src/entity/files/__name@dasherize__/__name@dasherize__.reducer.ts.template +0 -51
- package/src/entity/files/__name@dasherize__/__name@dasherize__.service.ts.template +0 -50
- package/src/entity-in-example/files/__name@dasherize__/__name@dasherize__.actions.ts.template +0 -270
- package/src/entity-in-example/files/__name@dasherize__/__name@dasherize__.effects.ts.template +0 -131
- package/src/entity-in-example/files/__name@dasherize__/__name@dasherize__.model.ts.template +0 -3
- package/src/entity-in-example/files/__name@dasherize__/__name@dasherize__.reducer.spec.ts.template +0 -13
- package/src/entity-in-example/files/__name@dasherize__/__name@dasherize__.reducer.ts.template +0 -51
- package/src/entity-in-example/files/__name@dasherize__/__name@dasherize__.service.ts.template +0 -50
- package/src/entity-in-example/index.d.ts +0 -2
- package/src/entity-in-example/index.js +0 -141
- package/src/entity-in-example/index.js.map +0 -1
- package/src/entity-in-example/index_spec.d.ts +0 -1
- package/src/entity-in-example/index_spec.js +0 -23
- package/src/entity-in-example/index_spec.js.map +0 -1
- package/src/entity-in-example/schema.json +0 -45
- package/src/init/files/CHANGELOG.md.template +0 -10
- package/src/init/files/src/app/admin/admin-routing.module.ts.template +0 -17
- package/src/init/files/src/app/admin/admin.module.spec.ts.template +0 -13
- package/src/init/files/src/app/admin/admin.module.ts.template +0 -28
- package/src/init/files/src/app/admin/waitlist/+state/waitlist.actions.ts.template +0 -23
- package/src/init/files/src/app/admin/waitlist/+state/waitlist.effects.ts.template +0 -50
- package/src/init/files/src/app/admin/waitlist/+state/waitlist.model.ts.template +0 -0
- package/src/init/files/src/app/admin/waitlist/+state/waitlist.selectors.ts.template +0 -39
- package/src/init/files/src/app/admin/waitlist/+state/waitlist.state.ts.template +0 -13
- package/src/init/files/src/app/admin/waitlist/waitlist.component.ts.template +0 -141
- package/src/init/files/src/app/app-routing.module.ts.template +0 -26
- package/src/init/files/src/app/app.module.ts.template +0 -34
- package/src/init/files/src/app/core/core.module.ts.template +0 -75
- package/src/init/files/src/app/core/setup/firebase-setup.ts.template +0 -25
- package/src/init/files/src/app/core/setup/module-import-guard.ts.template +0 -5
- package/src/init/files/src/app/core/snackbar/snackbar.actions.ts.template +0 -24
- package/src/init/files/src/app/core/snackbar/snackbar.effects.ts.template +0 -41
- package/src/init/files/src/app/core/store/app-state/app-state.actions.ts.template +0 -249
- package/src/init/files/src/app/core/store/app-state/app-state.effects.ts.template +0 -131
- package/src/init/files/src/app/core/store/app-state/app-state.model.ts.template +0 -8
- package/src/init/files/src/app/core/store/app-state/app-state.reducer.spec.ts.template +0 -13
- package/src/init/files/src/app/core/store/app-state/app-state.reducer.ts.template +0 -51
- package/src/init/files/src/app/core/store/app-state/app-state.service.ts.template +0 -50
- package/src/init/files/src/app/core/store/app.actions.ts.template +0 -92
- package/src/init/files/src/app/core/store/app.effects.ts.template +0 -175
- package/src/init/files/src/app/core/store/app.reducer.ts.template +0 -36
- package/src/init/files/src/app/core/store/app.selectors.ts.template +0 -42
- package/src/init/files/src/app/core/store/auth/auth.actions.ts.template +0 -77
- package/src/init/files/src/app/core/store/auth/auth.effects.ts.template +0 -163
- package/src/init/files/src/app/core/store/auth/auth.reducer.spec.ts.template +0 -13
- package/src/init/files/src/app/core/store/auth/auth.reducer.ts.template +0 -26
- package/src/init/files/src/app/core/store/auth/auth.selectors.ts.template +0 -25
- package/src/init/files/src/app/core/store/cached-load-connections.service.ts.template +0 -405
- package/src/init/files/src/app/core/store/cached-selectors.service.ts.template +0 -376
- package/src/init/files/src/app/core/store/effects.helpers.ts.template +0 -66
- package/src/init/files/src/app/core/store/user/user.actions.ts.template +0 -248
- package/src/init/files/src/app/core/store/user/user.effects.ts.template +0 -148
- package/src/init/files/src/app/core/store/user/user.reducer.spec.ts.template +0 -13
- package/src/init/files/src/app/core/store/user/user.reducer.ts.template +0 -50
- package/src/init/files/src/app/core/store/user/user.service.ts.template +0 -50
- package/src/init/files/src/app/core/store/user-context/user-context.actions.ts.template +0 -248
- package/src/init/files/src/app/core/store/user-context/user-context.effects.ts.template +0 -131
- package/src/init/files/src/app/core/store/user-context/user-context.reducer.spec.ts.template +0 -13
- package/src/init/files/src/app/core/store/user-context/user-context.reducer.ts.template +0 -51
- package/src/init/files/src/app/core/store/user-context/user-context.service.ts.template +0 -50
- package/src/init/files/src/app/core/utils/string-case.utils.ts.template +0 -96
- package/src/init/files/src/app/general/general-routing.module.ts.template +0 -25
- package/src/init/files/src/app/general/general.module.spec.ts.template +0 -13
- package/src/init/files/src/app/general/general.module.ts.template +0 -36
- package/src/init/files/src/app/general/home/+state/home.actions.ts.template +0 -26
- package/src/init/files/src/app/general/home/+state/home.effects.ts.template +0 -48
- package/src/init/files/src/app/general/home/+state/home.model.ts.template +0 -0
- package/src/init/files/src/app/general/home/+state/home.selectors.ts.template +0 -20
- package/src/init/files/src/app/general/home/+state/home.state.ts.template +0 -13
- package/src/init/files/src/app/general/home/home.component.html.template +0 -5
- package/src/init/files/src/app/general/home/home.component.ts.template +0 -88
- package/src/init/files/src/app/general/landing/+state/landing.actions.ts.template +0 -26
- package/src/init/files/src/app/general/landing/+state/landing.effects.ts.template +0 -48
- package/src/init/files/src/app/general/landing/+state/landing.model.ts.template +0 -0
- package/src/init/files/src/app/general/landing/+state/landing.selectors.ts.template +0 -20
- package/src/init/files/src/app/general/landing/+state/landing.state.ts.template +0 -13
- package/src/init/files/src/app/general/landing/landing.component.ts.template +0 -98
- package/src/init/files/src/app/general/login/login.component.html.template +0 -11
- package/src/init/files/src/app/general/login/login.component.ts.template +0 -80
- package/src/init/files/src/app/onboarding/consent/+state/consent.actions.ts.template +0 -23
- package/src/init/files/src/app/onboarding/consent/+state/consent.effects.ts.template +0 -47
- package/src/init/files/src/app/onboarding/consent/+state/consent.model.ts.template +0 -0
- package/src/init/files/src/app/onboarding/consent/+state/consent.selectors.ts.template +0 -20
- package/src/init/files/src/app/onboarding/consent/+state/consent.state.ts.template +0 -13
- package/src/init/files/src/app/onboarding/consent/consent.component.ts.template +0 -151
- package/src/init/files/src/app/onboarding/onboarding-routing.module.ts.template +0 -19
- package/src/init/files/src/app/onboarding/onboarding.module.spec.ts.template +0 -13
- package/src/init/files/src/app/onboarding/onboarding.module.ts.template +0 -32
- package/src/init/files/src/app/onboarding/waiting/+state/waiting.actions.ts.template +0 -26
- package/src/init/files/src/app/onboarding/waiting/+state/waiting.effects.ts.template +0 -52
- package/src/init/files/src/app/onboarding/waiting/+state/waiting.model.ts.template +0 -9
- package/src/init/files/src/app/onboarding/waiting/+state/waiting.selectors.ts.template +0 -42
- package/src/init/files/src/app/onboarding/waiting/+state/waiting.state.ts.template +0 -13
- package/src/init/files/src/app/onboarding/waiting/waiting.animations.ts.template +0 -4
- package/src/init/files/src/app/onboarding/waiting/waiting.component.html.template +0 -57
- package/src/init/files/src/app/onboarding/waiting/waiting.component.spec.ts.template +0 -25
- package/src/init/files/src/app/onboarding/waiting/waiting.component.ts.template +0 -281
- package/src/init/files/src/app/shared/components/redeployment-warning/redeployment-warning.component.html.template +0 -10
- package/src/init/files/src/app/shared/shared.module.ts.template +0 -87
- package/src/init/files/src/main.ts.template +0 -12
- package/src/module/files/__name@dasherize__/__name@dasherize__-routing.module.ts.template +0 -15
- package/src/module/files/__name@dasherize__/__name@dasherize__.module.spec.ts.template +0 -13
- package/src/module/files/__name@dasherize__/__name@dasherize__.module.ts.template +0 -24
- package/src/module/index.d.ts +0 -2
- package/src/module/index.js +0 -97
- package/src/module/index.js.map +0 -1
- package/src/module/index_spec.d.ts +0 -1
- package/src/module/index_spec.js +0 -23
- package/src/module/index_spec.js.map +0 -1
- package/src/module/schema.json +0 -38
- /package/src/init/files/src/app/{onboarding → first-time}/consent/consent.animations.ts.template +0 -0
- /package/src/init/files/src/app/{onboarding → first-time}/consent/consent.component.scss.template +0 -0
- /package/src/init/files/src/app/{onboarding → first-time}/consent/consent.component.spec.ts.template +0 -0
- /package/src/init/files/src/app/{general → first-time}/landing/landing.animations.ts.template +0 -0
- /package/src/init/files/src/app/{general → first-time}/landing/landing.component.scss.template +0 -0
- /package/src/init/files/src/app/{general → first-time}/landing/landing.component.spec.ts.template +0 -0
- /package/src/init/files/src/app/{general → first-time}/login/login.component.scss.template +0 -0
- /package/src/init/files/src/app/{general → first-time}/login/login.component.spec.ts.template +0 -0
- /package/src/init/files/src/app/{general → main}/home/home.animations.ts.template +0 -0
- /package/src/init/files/src/app/{general → main}/home/home.component.scss.template +0 -0
- /package/src/init/files/src/app/{general → main}/home/home.component.spec.ts.template +0 -0
- /package/src/init/files/src/app/shared/{components/redeployment-warning → redeployment-warning}/redeployment-warning.component.scss.template +0 -0
- /package/src/init/files/src/app/shared/{components/redeployment-warning → redeployment-warning}/redeployment-warning.component.spec.ts.template +0 -0
package/src/entity-in-example/files/__name@dasherize__/__name@dasherize__.actions.ts.template
DELETED
|
@@ -1,270 +0,0 @@
|
|
|
1
|
-
import { Action } from '@ngrx/store';
|
|
2
|
-
import { LoadAction } from '../app.actions';
|
|
3
|
-
import { <%= classify(name) %> } from './<%= dasherize(name) %>.model';
|
|
4
|
-
|
|
5
|
-
export enum <%= classify(name) %>ActionTypes {
|
|
6
|
-
STREAM = '[<%= classify(name) %>] stream <%= camelize(name) %>',
|
|
7
|
-
STREAM_SUCCESS = '[<%= classify(name) %>] stream <%= camelize(name) %> success',
|
|
8
|
-
STREAM_FAIL = '[<%= classify(name) %>] stream <%= camelize(name) %> fail',
|
|
9
|
-
LOAD = '[<%= classify(name) %>] load <%= camelize(name) %>',
|
|
10
|
-
LOAD_SUCCESS = '[<%= classify(name) %>] load <%= camelize(name) %> success',
|
|
11
|
-
LOAD_FAIL = '[<%= classify(name) %>] load <%= camelize(name) %> fail',
|
|
12
|
-
ADD = '[<%= classify(name) %>] add <%= camelize(name) %>',
|
|
13
|
-
ADD_SUCCESS = '[<%= classify(name) %>] add <%= camelize(name) %> success',
|
|
14
|
-
ADD_FAIL = '[<%= classify(name) %>] add <%= camelize(name) %> fail',
|
|
15
|
-
UPDATE = '[<%= classify(name) %>] update <%= camelize(name) %>',
|
|
16
|
-
UPDATE_SUCCESS = '[<%= classify(name) %>] update <%= camelize(name) %> success',
|
|
17
|
-
UPDATE_FAIL = '[<%= classify(name) %>] update <%= camelize(name) %> fail',
|
|
18
|
-
UPSERT = '[<%= classify(name) %>] upsert <%= camelize(name) %>',
|
|
19
|
-
UPSERT_SUCCESS = '[<%= classify(name) %>] upsert <%= camelize(name) %> success',
|
|
20
|
-
UPSERT_FAIL = '[<%= classify(name) %>] upsert <%= camelize(name) %> fail',
|
|
21
|
-
REMOVE = '[<%= classify(name) %>] remove <%= camelize(name) %>',
|
|
22
|
-
REMOVE_SUCCESS = '[<%= classify(name) %>] remove <%= camelize(name) %> success',
|
|
23
|
-
REMOVE_FAIL = '[<%= classify(name) %>] remove <%= camelize(name) %> fail',
|
|
24
|
-
LOADED = '[<%= classify(name) %>] loaded',
|
|
25
|
-
ADDED = '[<%= classify(name) %>] added',
|
|
26
|
-
MODIFIED = '[<%= classify(name) %>] modified',
|
|
27
|
-
REMOVED = '[<%= classify(name) %>] removed',
|
|
28
|
-
}
|
|
29
|
-
|
|
30
|
-
// See Firebase Docs for current constraints on valid queries
|
|
31
|
-
export class Stream<%= classify(name) %> implements Action {
|
|
32
|
-
readonly type = <%= classify(name) %>ActionTypes.STREAM;
|
|
33
|
-
constructor(
|
|
34
|
-
// property, comparator, value
|
|
35
|
-
public queryParams: [string, string, any][],
|
|
36
|
-
public queryOptions: {
|
|
37
|
-
orderBy?: string | [string, string],
|
|
38
|
-
limit?: number,
|
|
39
|
-
startAt?: string,
|
|
40
|
-
startAfter?: string,
|
|
41
|
-
endAt?: string,
|
|
42
|
-
endBefore?: string,
|
|
43
|
-
},
|
|
44
|
-
public correlationId: string,
|
|
45
|
-
public followupActions?: (<%= camelize(name) %>: <%= classify(name) %>) => LoadAction[],
|
|
46
|
-
) {}
|
|
47
|
-
}
|
|
48
|
-
|
|
49
|
-
export class Stream<%= classify(name) %>Success implements Action {
|
|
50
|
-
readonly type = <%= classify(name) %>ActionTypes.STREAM_SUCCESS;
|
|
51
|
-
constructor(
|
|
52
|
-
public queryParams: [string, string, any][],
|
|
53
|
-
public queryOptions: {
|
|
54
|
-
orderBy?: string | [string, string],
|
|
55
|
-
limit?: number,
|
|
56
|
-
startAt?: string,
|
|
57
|
-
startAfter?: string,
|
|
58
|
-
endAt?: string,
|
|
59
|
-
endBefore?: string,
|
|
60
|
-
},
|
|
61
|
-
public correlationId: string,
|
|
62
|
-
public followupActions?: (<%= camelize(name) %>: <%= classify(name) %>) => LoadAction[],
|
|
63
|
-
) {}
|
|
64
|
-
}
|
|
65
|
-
|
|
66
|
-
export class Stream<%= classify(name) %>Fail implements Action {
|
|
67
|
-
readonly type = <%= classify(name) %>ActionTypes.STREAM_FAIL;
|
|
68
|
-
constructor(
|
|
69
|
-
public error: any,
|
|
70
|
-
public correlationId?: string,
|
|
71
|
-
) {}
|
|
72
|
-
}
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
export class Load<%= classify(name) %> implements Action {
|
|
76
|
-
readonly type = <%= classify(name) %>ActionTypes.LOAD;
|
|
77
|
-
constructor(
|
|
78
|
-
// property, comparator, value
|
|
79
|
-
public queryParams: [string, string, any][],
|
|
80
|
-
public queryOptions: {
|
|
81
|
-
orderBy?: string | [string, string],
|
|
82
|
-
limit?: number,
|
|
83
|
-
startAt?: string,
|
|
84
|
-
startAfter?: string,
|
|
85
|
-
endAt?: string,
|
|
86
|
-
endBefore?: string,
|
|
87
|
-
},
|
|
88
|
-
public correlationId: string,
|
|
89
|
-
public followupActions?: (<%= camelize(name) %>: <%= classify(name) %>) => LoadAction[],
|
|
90
|
-
) {}
|
|
91
|
-
}
|
|
92
|
-
|
|
93
|
-
export class Load<%= classify(name) %>Success implements Action {
|
|
94
|
-
readonly type = <%= classify(name) %>ActionTypes.LOAD_SUCCESS;
|
|
95
|
-
constructor(
|
|
96
|
-
public queryParams: [string, string, any][],
|
|
97
|
-
public queryOptions: {
|
|
98
|
-
orderBy?: string | [string, string],
|
|
99
|
-
limit?: number,
|
|
100
|
-
startAt?: string,
|
|
101
|
-
startAfter?: string,
|
|
102
|
-
endAt?: string,
|
|
103
|
-
endBefore?: string,
|
|
104
|
-
},
|
|
105
|
-
public correlationId: string,
|
|
106
|
-
public followupActions?: (<%= camelize(name) %>: <%= classify(name) %>) => LoadAction[],
|
|
107
|
-
) {}
|
|
108
|
-
}
|
|
109
|
-
|
|
110
|
-
export class Load<%= classify(name) %>Fail implements Action {
|
|
111
|
-
readonly type = <%= classify(name) %>ActionTypes.LOAD_FAIL;
|
|
112
|
-
constructor(
|
|
113
|
-
public error: any,
|
|
114
|
-
public correlationId?: string,
|
|
115
|
-
) {}
|
|
116
|
-
}
|
|
117
|
-
|
|
118
|
-
export class Add<%= classify(name) %> implements Action {
|
|
119
|
-
readonly type = <%= classify(name) %>ActionTypes.ADD;
|
|
120
|
-
constructor(
|
|
121
|
-
public <%= camelize(name) %>: <%= classify(name) %>,
|
|
122
|
-
public correlationId?: string,
|
|
123
|
-
) {}
|
|
124
|
-
}
|
|
125
|
-
|
|
126
|
-
export class Add<%= classify(name) %>Success implements Action {
|
|
127
|
-
readonly type = <%= classify(name) %>ActionTypes.ADD_SUCCESS;
|
|
128
|
-
constructor(
|
|
129
|
-
public <%= camelize(name) %>: <%= classify(name) %>,
|
|
130
|
-
public correlationId?: string,
|
|
131
|
-
) {}
|
|
132
|
-
}
|
|
133
|
-
|
|
134
|
-
export class Add<%= classify(name) %>Fail implements Action {
|
|
135
|
-
readonly type = <%= classify(name) %>ActionTypes.ADD_FAIL;
|
|
136
|
-
constructor(
|
|
137
|
-
public error: any,
|
|
138
|
-
public correlationId?: string,
|
|
139
|
-
) {}
|
|
140
|
-
}
|
|
141
|
-
|
|
142
|
-
export class Update<%= classify(name) %> implements Action {
|
|
143
|
-
readonly type = <%= classify(name) %>ActionTypes.UPDATE;
|
|
144
|
-
constructor(
|
|
145
|
-
public __id: string,
|
|
146
|
-
public changes: Partial<<%= classify(name) %>>,
|
|
147
|
-
public correlationId?: string,
|
|
148
|
-
) { }
|
|
149
|
-
}
|
|
150
|
-
|
|
151
|
-
export class Update<%= classify(name) %>Success implements Action {
|
|
152
|
-
readonly type = <%= classify(name) %>ActionTypes.UPDATE_SUCCESS;
|
|
153
|
-
constructor(
|
|
154
|
-
public __id: string,
|
|
155
|
-
public changes: Partial<<%= classify(name) %>>,
|
|
156
|
-
public correlationId?: string,
|
|
157
|
-
) {}
|
|
158
|
-
}
|
|
159
|
-
|
|
160
|
-
export class Update<%= classify(name) %>Fail implements Action {
|
|
161
|
-
readonly type = <%= classify(name) %>ActionTypes.UPDATE_FAIL;
|
|
162
|
-
constructor(
|
|
163
|
-
public error: any,
|
|
164
|
-
public correlationId?: string,
|
|
165
|
-
) {}
|
|
166
|
-
}
|
|
167
|
-
|
|
168
|
-
export class Upsert<%= classify(name) %> implements Action {
|
|
169
|
-
readonly type = <%= classify(name) %>ActionTypes.UPSERT;
|
|
170
|
-
constructor(
|
|
171
|
-
public <%= camelize(name) %>: <%= classify(name) %>,
|
|
172
|
-
public correlationId?: string,
|
|
173
|
-
) {}
|
|
174
|
-
}
|
|
175
|
-
|
|
176
|
-
export class Upsert<%= classify(name) %>Success implements Action {
|
|
177
|
-
readonly type = <%= classify(name) %>ActionTypes.UPSERT_SUCCESS;
|
|
178
|
-
constructor(
|
|
179
|
-
public <%= camelize(name) %>: <%= classify(name) %>,
|
|
180
|
-
public correlationId?: string,
|
|
181
|
-
) {}
|
|
182
|
-
}
|
|
183
|
-
|
|
184
|
-
export class Upsert<%= classify(name) %>Fail implements Action {
|
|
185
|
-
readonly type = <%= classify(name) %>ActionTypes.UPSERT_FAIL;
|
|
186
|
-
constructor(
|
|
187
|
-
public error: any,
|
|
188
|
-
public correlationId?: string,
|
|
189
|
-
) {}
|
|
190
|
-
}
|
|
191
|
-
|
|
192
|
-
export class Remove<%= classify(name) %> implements Action {
|
|
193
|
-
readonly type = <%= classify(name) %>ActionTypes.REMOVE;
|
|
194
|
-
constructor(
|
|
195
|
-
public __id: string,
|
|
196
|
-
public correlationId?: string,
|
|
197
|
-
) { }
|
|
198
|
-
}
|
|
199
|
-
|
|
200
|
-
export class Remove<%= classify(name) %>Success implements Action {
|
|
201
|
-
readonly type = <%= classify(name) %>ActionTypes.REMOVE_SUCCESS;
|
|
202
|
-
constructor(
|
|
203
|
-
public __id: string,
|
|
204
|
-
public correlationId?: string,
|
|
205
|
-
) {}
|
|
206
|
-
}
|
|
207
|
-
|
|
208
|
-
export class Remove<%= classify(name) %>Fail implements Action {
|
|
209
|
-
readonly type = <%= classify(name) %>ActionTypes.REMOVE_FAIL;
|
|
210
|
-
constructor(
|
|
211
|
-
public error: any,
|
|
212
|
-
public correlationId?: string,
|
|
213
|
-
) {}
|
|
214
|
-
}
|
|
215
|
-
|
|
216
|
-
export class Loaded<%= classify(name) %> implements Action {
|
|
217
|
-
readonly type = <%= classify(name) %>ActionTypes.LOADED;
|
|
218
|
-
constructor(
|
|
219
|
-
public payload: <%= classify(name) %>[],
|
|
220
|
-
public correlationId?: string,
|
|
221
|
-
) {}
|
|
222
|
-
}
|
|
223
|
-
|
|
224
|
-
export class Added<%= classify(name) %> implements Action {
|
|
225
|
-
readonly type = <%= classify(name) %>ActionTypes.ADDED;
|
|
226
|
-
constructor(
|
|
227
|
-
public payload: <%= classify(name) %>,
|
|
228
|
-
public correlationId?: string,
|
|
229
|
-
) {}
|
|
230
|
-
}
|
|
231
|
-
|
|
232
|
-
export class Modified<%= classify(name) %> implements Action {
|
|
233
|
-
readonly type = <%= classify(name) %>ActionTypes.MODIFIED;
|
|
234
|
-
constructor(
|
|
235
|
-
public payload: <%= classify(name) %>,
|
|
236
|
-
public correlationId?: string,
|
|
237
|
-
) {}
|
|
238
|
-
}
|
|
239
|
-
|
|
240
|
-
export class Removed<%= classify(name) %> implements Action {
|
|
241
|
-
readonly type = <%= classify(name) %>ActionTypes.REMOVED;
|
|
242
|
-
constructor(
|
|
243
|
-
public payload: <%= classify(name) %>,
|
|
244
|
-
public correlationId?: string,
|
|
245
|
-
) {}
|
|
246
|
-
}
|
|
247
|
-
|
|
248
|
-
export type <%= classify(name) %>Actions =
|
|
249
|
-
Stream<%= classify(name) %> |
|
|
250
|
-
Stream<%= classify(name) %>Success |
|
|
251
|
-
Stream<%= classify(name) %>Fail |
|
|
252
|
-
Load<%= classify(name) %> |
|
|
253
|
-
Load<%= classify(name) %>Success |
|
|
254
|
-
Load<%= classify(name) %>Fail |
|
|
255
|
-
Add<%= classify(name) %> |
|
|
256
|
-
Add<%= classify(name) %>Success |
|
|
257
|
-
Add<%= classify(name) %>Fail |
|
|
258
|
-
Update<%= classify(name) %> |
|
|
259
|
-
Update<%= classify(name) %>Success |
|
|
260
|
-
Update<%= classify(name) %>Fail |
|
|
261
|
-
Upsert<%= classify(name) %> |
|
|
262
|
-
Upsert<%= classify(name) %>Success |
|
|
263
|
-
Upsert<%= classify(name) %>Fail |
|
|
264
|
-
Remove<%= classify(name) %> |
|
|
265
|
-
Remove<%= classify(name) %>Success |
|
|
266
|
-
Remove<%= classify(name) %>Fail |
|
|
267
|
-
Loaded<%= classify(name) %> |
|
|
268
|
-
Added<%= classify(name) %> |
|
|
269
|
-
Modified<%= classify(name) %> |
|
|
270
|
-
Removed<%= classify(name) %>;
|
package/src/entity-in-example/files/__name@dasherize__/__name@dasherize__.effects.ts.template
DELETED
|
@@ -1,131 +0,0 @@
|
|
|
1
|
-
import { Injectable } from '@angular/core';
|
|
2
|
-
import { Action } from '@ngrx/store';
|
|
3
|
-
import { Actions, createEffect, ofType } from '@ngrx/effects';
|
|
4
|
-
import { EMPTY, of, Observable, throwError, forkJoin, from, pipe, merge } from 'rxjs';
|
|
5
|
-
import { switchMap, flatMap, mergeMap, map, catchError, tap, take } from 'rxjs/operators';
|
|
6
|
-
import { FirebaseService } from '../../firebase/firebase.service';
|
|
7
|
-
import { CachedLoadConnectionsService } from '../cached-load-connections.service';
|
|
8
|
-
|
|
9
|
-
import { <%= classify(name) %> } from './<%= dasherize(name) %>.model';
|
|
10
|
-
import { <%= classify(name) %>ActionTypes, <%= classify(name) %>Actions,
|
|
11
|
-
Stream<%= classify(name) %>, Stream<%= classify(name) %>Success, Stream<%= classify(name) %>Fail,
|
|
12
|
-
Load<%= classify(name) %>, Load<%= classify(name) %>Success, Load<%= classify(name) %>Fail,
|
|
13
|
-
Add<%= classify(name) %>, Add<%= classify(name) %>Success, Add<%= classify(name) %>Fail,
|
|
14
|
-
Update<%= classify(name) %>, Update<%= classify(name) %>Success, Update<%= classify(name) %>Fail,
|
|
15
|
-
Upsert<%= classify(name) %>, Upsert<%= classify(name) %>Success, Upsert<%= classify(name) %>Fail,
|
|
16
|
-
Remove<%= classify(name) %>, Remove<%= classify(name) %>Success, Remove<%= classify(name) %>Fail } from './<%= dasherize(name) %>.actions';
|
|
17
|
-
|
|
18
|
-
@Injectable()
|
|
19
|
-
export class <%= classify(name) %>Effects {
|
|
20
|
-
/** Process the stream action to create firebase connections. */
|
|
21
|
-
stream$: Observable<Action> = createEffect(
|
|
22
|
-
() => this.actions$.pipe(
|
|
23
|
-
ofType<Stream<%= classify(name) %>>(<%= classify(name) %>ActionTypes.STREAM),
|
|
24
|
-
mergeMap((action: Stream<%= classify(name) %>) => {
|
|
25
|
-
const connection = this.clc.processLoadAction(action);
|
|
26
|
-
return connection.loadStream.pipe(
|
|
27
|
-
take(1),
|
|
28
|
-
map(() => new Stream<%= classify(name) %>Success(action.queryParams, action.queryOptions, action.correlationId, action.followupActions)),
|
|
29
|
-
catchError((error) => of(new Stream<%= classify(name) %>Fail(error, action.correlationId))),
|
|
30
|
-
);
|
|
31
|
-
}),
|
|
32
|
-
),
|
|
33
|
-
);
|
|
34
|
-
|
|
35
|
-
/** Process the load action to create firebase connections. */
|
|
36
|
-
load$: Observable<Action> = createEffect(
|
|
37
|
-
() => this.actions$.pipe(
|
|
38
|
-
ofType<Load<%= classify(name) %>>(<%= classify(name) %>ActionTypes.LOAD),
|
|
39
|
-
mergeMap((action: Load<%= classify(name) %>) => {
|
|
40
|
-
const connection = this.clc.processLoadAction(action);
|
|
41
|
-
return connection.loadStream.pipe(
|
|
42
|
-
take(1),
|
|
43
|
-
map(() => new Load<%= classify(name) %>Success(action.queryParams, action.queryOptions, action.correlationId, action.followupActions)),
|
|
44
|
-
catchError((error) => of(new Load<%= classify(name) %>Fail(error, action.correlationId))),
|
|
45
|
-
);
|
|
46
|
-
}),
|
|
47
|
-
),
|
|
48
|
-
);
|
|
49
|
-
|
|
50
|
-
/** Process the add action to update database and initiate callbacks. */
|
|
51
|
-
add$: Observable<Action> = createEffect(
|
|
52
|
-
() => this.actions$.pipe(
|
|
53
|
-
ofType<Add<%= classify(name) %>>(<%= classify(name) %>ActionTypes.ADD),
|
|
54
|
-
mergeMap((action: Add<%= classify(name) %>) => {
|
|
55
|
-
return this.db.addEntity('<%= camelize(name) %>s', action.<%= camelize(name) %>).pipe(
|
|
56
|
-
mergeMap(() => merge(
|
|
57
|
-
of(new Add<%= classify(name) %>Success(action.<%= camelize(name) %>, action.correlationId)),
|
|
58
|
-
this.actionsOnAdd(action),
|
|
59
|
-
)),
|
|
60
|
-
catchError((error) => of(new Add<%= classify(name) %>Fail(error, action.correlationId))),
|
|
61
|
-
);
|
|
62
|
-
}),
|
|
63
|
-
),
|
|
64
|
-
);
|
|
65
|
-
|
|
66
|
-
/** Process the update action to update database and initiate callbacks. */
|
|
67
|
-
update$: Observable<Action> = createEffect(
|
|
68
|
-
() => this.actions$.pipe(
|
|
69
|
-
ofType<Update<%= classify(name) %>>(<%= classify(name) %>ActionTypes.UPDATE),
|
|
70
|
-
mergeMap((action: Update<%= classify(name) %>) => {
|
|
71
|
-
return this.db.updateEntity('<%= camelize(name) %>s', action.__id, action.changes).pipe(
|
|
72
|
-
mergeMap(() => merge(
|
|
73
|
-
of(new Update<%= classify(name) %>Success(action.__id, action.changes, action.correlationId)),
|
|
74
|
-
this.actionsOnUpdate(action),
|
|
75
|
-
)),
|
|
76
|
-
catchError((error) => of(new Update<%= classify(name) %>Fail(error, action.correlationId))),
|
|
77
|
-
);
|
|
78
|
-
}),
|
|
79
|
-
),
|
|
80
|
-
);
|
|
81
|
-
|
|
82
|
-
/** Process the upsert action to update database and initiate callbacks. */
|
|
83
|
-
upsert$: Observable<Action> = createEffect(
|
|
84
|
-
() => this.actions$.pipe(
|
|
85
|
-
ofType<Upsert<%= classify(name) %>>(<%= classify(name) %>ActionTypes.UPSERT),
|
|
86
|
-
mergeMap((action: Upsert<%= classify(name) %>) => {
|
|
87
|
-
return this.db.upsertEntity('<%= camelize(name) %>s', action.<%= camelize(name) %>).pipe(
|
|
88
|
-
mergeMap((results) => merge(
|
|
89
|
-
of(new Upsert<%= classify(name) %>Success(action.<%= camelize(name) %>, action.correlationId)),
|
|
90
|
-
results.type === 'add' ? this.actionsOnAdd(new Add<%= classify(name) %>(action.<%= camelize(name) %>, action.correlationId)) : this.actionsOnUpdate(new Update<%= classify(name) %>(action.<%= camelize(name) %>.__id, action.<%= camelize(name) %>, action.correlationId)),
|
|
91
|
-
)),
|
|
92
|
-
catchError((error) => of(new Upsert<%= classify(name) %>Fail(error, action.correlationId))),
|
|
93
|
-
);
|
|
94
|
-
}),
|
|
95
|
-
),
|
|
96
|
-
);
|
|
97
|
-
|
|
98
|
-
/** Process the remove action to update database and initiate callbacks. */
|
|
99
|
-
remove$: Observable<Action> = createEffect(
|
|
100
|
-
() => this.actions$.pipe(
|
|
101
|
-
ofType<Remove<%= classify(name) %>>(<%= classify(name) %>ActionTypes.REMOVE),
|
|
102
|
-
mergeMap((action: Remove<%= classify(name) %>) => {
|
|
103
|
-
return this.db.removeEntity('<%= camelize(name) %>s', action.__id).pipe(
|
|
104
|
-
mergeMap(() => merge(
|
|
105
|
-
of(new Remove<%= classify(name) %>Success(action.__id, action.correlationId)),
|
|
106
|
-
this.actionsOnRemove(action),
|
|
107
|
-
)),
|
|
108
|
-
catchError((error) => of(new Remove<%= classify(name) %>Fail(error, action.correlationId))),
|
|
109
|
-
);
|
|
110
|
-
}),
|
|
111
|
-
),
|
|
112
|
-
);
|
|
113
|
-
|
|
114
|
-
actionsOnAdd(action: Add<%= classify(name) %>): Observable<Action> {
|
|
115
|
-
return EMPTY;
|
|
116
|
-
}
|
|
117
|
-
|
|
118
|
-
actionsOnUpdate(action: Update<%= classify(name) %>): Observable<Action> {
|
|
119
|
-
return EMPTY;
|
|
120
|
-
}
|
|
121
|
-
|
|
122
|
-
actionsOnRemove(action: Remove<%= classify(name) %>): Observable<Action> {
|
|
123
|
-
return EMPTY;
|
|
124
|
-
}
|
|
125
|
-
|
|
126
|
-
constructor(
|
|
127
|
-
private actions$: Actions,
|
|
128
|
-
private db: FirebaseService,
|
|
129
|
-
private clc: CachedLoadConnectionsService,
|
|
130
|
-
) {}
|
|
131
|
-
}
|
package/src/entity-in-example/files/__name@dasherize__/__name@dasherize__.reducer.spec.ts.template
DELETED
|
@@ -1,13 +0,0 @@
|
|
|
1
|
-
import { reducer, initialState } from './<%= dasherize(name) %>.reducer';
|
|
2
|
-
|
|
3
|
-
describe('<%= classify(name) %> Reducer', () => {
|
|
4
|
-
describe('unknown action', () => {
|
|
5
|
-
it('should return the initial state', () => {
|
|
6
|
-
const action = {} as any;
|
|
7
|
-
|
|
8
|
-
const result = reducer(initialState, action);
|
|
9
|
-
|
|
10
|
-
expect(result).toBe(initialState);
|
|
11
|
-
});
|
|
12
|
-
});
|
|
13
|
-
});
|
package/src/entity-in-example/files/__name@dasherize__/__name@dasherize__.reducer.ts.template
DELETED
|
@@ -1,51 +0,0 @@
|
|
|
1
|
-
import { EntityState, EntityAdapter, createEntityAdapter } from '@ngrx/entity';
|
|
2
|
-
import { <%= classify(name) %> } from './<%= dasherize(name) %>.model';
|
|
3
|
-
import { <%= classify(name) %>Actions, <%= classify(name) %>ActionTypes } from './<%= dasherize(name) %>.actions';
|
|
4
|
-
import { createFeatureSelector } from '@ngrx/store';
|
|
5
|
-
|
|
6
|
-
export interface State extends EntityState<<%= classify(name) %>> {
|
|
7
|
-
// additional entities state properties
|
|
8
|
-
}
|
|
9
|
-
|
|
10
|
-
export const adapter: EntityAdapter<<%= classify(name) %>> = createEntityAdapter<<%= classify(name) %>>({
|
|
11
|
-
selectId: (<%= camelize(name) %>: <%= classify(name) %>) => <%= camelize(name) %>.__id,
|
|
12
|
-
sortComparer: false,
|
|
13
|
-
});
|
|
14
|
-
|
|
15
|
-
export const initialState: State = adapter.getInitialState({
|
|
16
|
-
// additional entity state properties
|
|
17
|
-
});
|
|
18
|
-
|
|
19
|
-
export function reducer(
|
|
20
|
-
state: State = initialState,
|
|
21
|
-
action: <%= classify(name) %>Actions,
|
|
22
|
-
) {
|
|
23
|
-
switch (action.type) {
|
|
24
|
-
case <%= classify(name) %>ActionTypes.ADDED:
|
|
25
|
-
return adapter.upsertOne(action.payload, state);
|
|
26
|
-
|
|
27
|
-
case <%= classify(name) %>ActionTypes.LOADED:
|
|
28
|
-
return adapter.upsertMany(action.payload, state);
|
|
29
|
-
|
|
30
|
-
case <%= classify(name) %>ActionTypes.MODIFIED:
|
|
31
|
-
return adapter.updateOne({
|
|
32
|
-
id: action.payload.__id,
|
|
33
|
-
changes: action.payload,
|
|
34
|
-
}, state);
|
|
35
|
-
|
|
36
|
-
case <%= classify(name) %>ActionTypes.REMOVED:
|
|
37
|
-
return adapter.removeOne(action.payload.__id, state);
|
|
38
|
-
|
|
39
|
-
default:
|
|
40
|
-
return state;
|
|
41
|
-
}
|
|
42
|
-
}
|
|
43
|
-
|
|
44
|
-
export const get<%= classify(name) %>State = createFeatureSelector<State>('<%= camelize(name) %>');
|
|
45
|
-
|
|
46
|
-
export const {
|
|
47
|
-
selectIds,
|
|
48
|
-
selectEntities,
|
|
49
|
-
selectAll,
|
|
50
|
-
selectTotal,
|
|
51
|
-
} = adapter.getSelectors(get<%= classify(name) %>State);
|
package/src/entity-in-example/files/__name@dasherize__/__name@dasherize__.service.ts.template
DELETED
|
@@ -1,50 +0,0 @@
|
|
|
1
|
-
import { Injectable } from '@angular/core';
|
|
2
|
-
import { Observable } from 'rxjs';
|
|
3
|
-
import { CachedSelectorsService } from '../cached-selectors.service';
|
|
4
|
-
import { FirebaseService } from '../../firebase/firebase.service';
|
|
5
|
-
import { <%= classify(name) %> } from './<%= dasherize(name) %>.model';
|
|
6
|
-
|
|
7
|
-
@Injectable({
|
|
8
|
-
providedIn: 'root',
|
|
9
|
-
})
|
|
10
|
-
export class <%= classify(name) %>Service {
|
|
11
|
-
constructor(
|
|
12
|
-
private cs: CachedSelectorsService,
|
|
13
|
-
private db: FirebaseService,
|
|
14
|
-
) { }
|
|
15
|
-
|
|
16
|
-
/** Select a <%= camelize(name) %> from the store. */
|
|
17
|
-
public select<%= classify(name) %> = <T extends <%= classify(name) %>>(
|
|
18
|
-
id: string,
|
|
19
|
-
correlationId: string,
|
|
20
|
-
childrenFn?: (e: <%= classify(name) %>) => { [index: string]: Observable<any> },
|
|
21
|
-
): Observable<T> => {
|
|
22
|
-
return this.cs.selectEntityObj<<%= classify(name) %>, T>('<%= camelize(name) %>', id, correlationId, childrenFn);
|
|
23
|
-
};
|
|
24
|
-
|
|
25
|
-
/** Select <%= camelize(name) %>s from the store. */
|
|
26
|
-
public select<%= classify(name) %>s = <T extends <%= classify(name) %>>(
|
|
27
|
-
queryParams: [string, string, any][],
|
|
28
|
-
correlationId: string,
|
|
29
|
-
childrenFn?: (e: <%= classify(name) %>) => { [index: string]: Observable<any> },
|
|
30
|
-
): Observable<Array<T>> => {
|
|
31
|
-
return this.cs.selectEntityList<<%= classify(name) %>, T>('<%= camelize(name) %>', queryParams, correlationId, childrenFn);
|
|
32
|
-
};
|
|
33
|
-
|
|
34
|
-
/** Get a <%= camelize(name) %> directly from the database. */
|
|
35
|
-
public get<%= classify(name) %> = <T extends <%= classify(name) %>>(
|
|
36
|
-
id: string,
|
|
37
|
-
childrenFn?: (e: <%= classify(name) %>) => { [index: string]: Observable<any> },
|
|
38
|
-
): Observable<T> => {
|
|
39
|
-
return this.db.queryObjOnce<<%= classify(name) %>, T>('<%= camelize(name) %>s', id, childrenFn);
|
|
40
|
-
};
|
|
41
|
-
|
|
42
|
-
/** Get <%= camelize(name) %>s directly from the database. */
|
|
43
|
-
public get<%= classify(name) %>s = <T extends <%= classify(name) %>>(
|
|
44
|
-
queryParams: [string, string, any][],
|
|
45
|
-
queryOptions?: { [index: string]: any },
|
|
46
|
-
childrenFn?: (e: <%= classify(name) %>) => { [index: string]: Observable<any> },
|
|
47
|
-
): Observable<Array<T>> => {
|
|
48
|
-
return this.db.queryListOnce<<%= classify(name) %>, T>('<%= camelize(name) %>s', queryParams, queryOptions, childrenFn);
|
|
49
|
-
};
|
|
50
|
-
}
|
|
@@ -1,141 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
3
|
-
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
4
|
-
return new (P || (P = Promise))(function (resolve, reject) {
|
|
5
|
-
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
6
|
-
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
7
|
-
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
8
|
-
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
9
|
-
});
|
|
10
|
-
};
|
|
11
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
|
-
exports.entity = void 0;
|
|
13
|
-
const schematics_1 = require("@angular-devkit/schematics");
|
|
14
|
-
const change_1 = require("@schematics/angular/utility/change");
|
|
15
|
-
const find_module_1 = require("@schematics/angular/utility/find-module");
|
|
16
|
-
const parse_name_1 = require("@schematics/angular/utility/parse-name");
|
|
17
|
-
const workspace_1 = require("@schematics/angular/utility/workspace");
|
|
18
|
-
const core_1 = require("@angular-devkit/core");
|
|
19
|
-
const statements_adder_1 = require("../shared/statements-adder");
|
|
20
|
-
function addInserts(options) {
|
|
21
|
-
return (host, context) => {
|
|
22
|
-
const classifiedName = core_1.strings.classify(options.name);
|
|
23
|
-
const camelizedName = core_1.strings.camelize(options.name);
|
|
24
|
-
context.logger.info(`names: ${classifiedName}, ${camelizedName}`);
|
|
25
|
-
// Add core module changes
|
|
26
|
-
const coreModulePath = options.module;
|
|
27
|
-
const coreModuleText = (0, statements_adder_1.getSourceText)(host, coreModulePath);
|
|
28
|
-
context.logger.info(`modulePath: ${coreModulePath}`);
|
|
29
|
-
const entityEffectsPath = `/${options.path}/` +
|
|
30
|
-
core_1.strings.dasherize(options.name) + '/' +
|
|
31
|
-
core_1.strings.dasherize(options.name) + '.effects';
|
|
32
|
-
context.logger.info(`entityEffectsPath: ${entityEffectsPath}`);
|
|
33
|
-
const coreToEffectsPath = (0, find_module_1.buildRelativePath)(coreModulePath, entityEffectsPath);
|
|
34
|
-
context.logger.info(`coreToEffectsPath: ${coreToEffectsPath}`);
|
|
35
|
-
let insertChangesInCore = (0, statements_adder_1.simpleInsert)(coreModuleText, coreModulePath, [
|
|
36
|
-
'// Entity Effects',
|
|
37
|
-
'// Entity Effects'
|
|
38
|
-
], [
|
|
39
|
-
`import { ${classifiedName}Effects } from '${coreToEffectsPath}';`,
|
|
40
|
-
` ${classifiedName}Effects,`
|
|
41
|
-
]);
|
|
42
|
-
// Add app reducer changes
|
|
43
|
-
const appReducerPath = '//src/app/core/store/app.reducer.ts';
|
|
44
|
-
const appReducerText = (0, statements_adder_1.getSourceText)(host, appReducerPath);
|
|
45
|
-
context.logger.info(`appReducerPath: ${appReducerPath}`);
|
|
46
|
-
const entityReducerPath = `/${options.path}/` +
|
|
47
|
-
core_1.strings.dasherize(options.name) + '/' +
|
|
48
|
-
core_1.strings.dasherize(options.name) + '.reducer';
|
|
49
|
-
context.logger.info(`entityReducerPath: ${entityReducerPath}`);
|
|
50
|
-
const appToEntityReducerPath = (0, find_module_1.buildRelativePath)(appReducerPath, entityReducerPath);
|
|
51
|
-
let insertChangesInAppReducer = (0, statements_adder_1.simpleInsert)(appReducerText, appReducerPath, [
|
|
52
|
-
'// Entity Reducers',
|
|
53
|
-
'// Entity State',
|
|
54
|
-
'// Entity Reducers'
|
|
55
|
-
], [
|
|
56
|
-
`import * as from${classifiedName} from '${appToEntityReducerPath}';`,
|
|
57
|
-
` ${camelizedName}: from${classifiedName}.State;`,
|
|
58
|
-
` ${camelizedName}: from${classifiedName}.reducer,`
|
|
59
|
-
]);
|
|
60
|
-
// Add app selector changes
|
|
61
|
-
const appSelectorPath = '//src/app/core/store/app.selectors.ts';
|
|
62
|
-
const appSelectorText = (0, statements_adder_1.getSourceText)(host, appSelectorPath);
|
|
63
|
-
const entityServicePath = `/${options.path}/` +
|
|
64
|
-
core_1.strings.dasherize(options.name) + '/' +
|
|
65
|
-
core_1.strings.dasherize(options.name) + '.service';
|
|
66
|
-
const appToEntityServicePath = (0, find_module_1.buildRelativePath)(appSelectorPath, entityServicePath);
|
|
67
|
-
let insertChangesInAppSelector = (0, statements_adder_1.simpleInsert)(appSelectorText, appSelectorPath, [
|
|
68
|
-
'// Entity Selectors',
|
|
69
|
-
'// Entity Selectors',
|
|
70
|
-
'// Entity Selectors'
|
|
71
|
-
], [
|
|
72
|
-
`import { ${classifiedName}Service } from '${appToEntityServicePath}';`,
|
|
73
|
-
` private ${camelizedName}: ${classifiedName}Service,`,
|
|
74
|
-
` public get${classifiedName} = this.${camelizedName}.get${classifiedName};\n public get${classifiedName}s = this.${camelizedName}.get${classifiedName}s;\n public select${classifiedName} = this.${camelizedName}.select${classifiedName};\n public select${classifiedName}s = this.${camelizedName}.select${classifiedName}s;`
|
|
75
|
-
]);
|
|
76
|
-
// Add firebase service changes
|
|
77
|
-
const appFirebaseServicePath = '//src/app/core/firebase/firebase.service.ts';
|
|
78
|
-
const appFirebaseServiceText = (0, statements_adder_1.getSourceText)(host, appFirebaseServicePath);
|
|
79
|
-
const entityModelPath = `/${options.path}/` +
|
|
80
|
-
core_1.strings.dasherize(options.name) + '/' +
|
|
81
|
-
core_1.strings.dasherize(options.name) + '.model';
|
|
82
|
-
const appToEntityModelPath = (0, find_module_1.buildRelativePath)(appFirebaseServicePath, entityModelPath);
|
|
83
|
-
let insertChangesInFirebaseService = (0, statements_adder_1.simpleInsert)(appFirebaseServiceText, appFirebaseServicePath, [
|
|
84
|
-
'// Entity Models',
|
|
85
|
-
'// Entity Models'
|
|
86
|
-
], [
|
|
87
|
-
`import { ${classifiedName} } from '${appToEntityModelPath}';`,
|
|
88
|
-
` ${camelizedName}s: new BehaviorSubject<Array<{ type: string; result: ${classifiedName} }>>(
|
|
89
|
-
this.mockDBService.getInitialDBStateChanges('${camelizedName}s')
|
|
90
|
-
),`
|
|
91
|
-
]);
|
|
92
|
-
context.logger.info(`about to start committing`);
|
|
93
|
-
// For each of the files and corresponding set of changes, commit to the tree
|
|
94
|
-
[
|
|
95
|
-
[coreModulePath, insertChangesInCore],
|
|
96
|
-
[appReducerPath, insertChangesInAppReducer],
|
|
97
|
-
[appSelectorPath, insertChangesInAppSelector],
|
|
98
|
-
[appFirebaseServicePath, insertChangesInFirebaseService],
|
|
99
|
-
].map(([filePath, insertChanges]) => {
|
|
100
|
-
const declarationRecorder = host.beginUpdate(filePath);
|
|
101
|
-
for (const change of insertChanges) {
|
|
102
|
-
if (change instanceof change_1.InsertChange) {
|
|
103
|
-
declarationRecorder.insertLeft(change.pos, change.toAdd);
|
|
104
|
-
}
|
|
105
|
-
}
|
|
106
|
-
host.commitUpdate(declarationRecorder);
|
|
107
|
-
});
|
|
108
|
-
return host;
|
|
109
|
-
};
|
|
110
|
-
}
|
|
111
|
-
function entity(options) {
|
|
112
|
-
return (tree, context) => __awaiter(this, void 0, void 0, function* () {
|
|
113
|
-
// Make sure the command is executed in the directory where the component should be generated
|
|
114
|
-
if (!options.inDirectory) {
|
|
115
|
-
context.logger.info("Please navigate to the directory where you want to generate the entity.");
|
|
116
|
-
return (0, schematics_1.noop)();
|
|
117
|
-
}
|
|
118
|
-
const workspace = yield (0, workspace_1.getWorkspace)(tree);
|
|
119
|
-
const project = workspace.projects.get(options.project);
|
|
120
|
-
if (!project) {
|
|
121
|
-
throw new schematics_1.SchematicsException(`Project "${options.project}" does not exist.`);
|
|
122
|
-
}
|
|
123
|
-
if (options.path === undefined) {
|
|
124
|
-
options.path = (0, workspace_1.buildDefaultPath)(project);
|
|
125
|
-
}
|
|
126
|
-
options.module = (0, find_module_1.findModuleFromOptions)(tree, options);
|
|
127
|
-
const parsedPath = (0, parse_name_1.parseName)(options.path, options.name);
|
|
128
|
-
options.name = parsedPath.name;
|
|
129
|
-
options.path = parsedPath.path;
|
|
130
|
-
const templateSource = (0, schematics_1.apply)((0, schematics_1.url)('./files'), [
|
|
131
|
-
(0, schematics_1.applyTemplates)(Object.assign(Object.assign({}, core_1.strings), options)),
|
|
132
|
-
(0, schematics_1.move)(parsedPath.path),
|
|
133
|
-
]);
|
|
134
|
-
return (0, schematics_1.chain)([
|
|
135
|
-
addInserts(options),
|
|
136
|
-
(0, schematics_1.mergeWith)(templateSource)
|
|
137
|
-
]);
|
|
138
|
-
});
|
|
139
|
-
}
|
|
140
|
-
exports.entity = entity;
|
|
141
|
-
//# sourceMappingURL=index.js.map
|