@tech4good/angular-schematics 17.0.4 → 18.0.1
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/.eslintrc.json.template +1 -1
- package/src/init/files/.firebaserc.template +8 -0
- package/src/init/files/.github/workflows/angular-github-ci.yml.template +1 -1
- package/src/init/files/README.md.template +13 -10
- 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.ts.template +12 -8
- package/src/init/files/src/app/app.config.ts.template +65 -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 +26 -23
- 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 +3 -6
- 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 +10 -14
- package/src/init/files/src/app/{onboarding → first-time}/consent/consent.component.scss.template +2 -2
- package/src/init/files/src/app/first-time/consent/consent.component.ts.template +95 -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 +65 -0
- package/src/init/files/src/app/{onboarding/waiting/waiting.component.scss.template → first-time/early-access/early-access.component.scss.template} +10 -3
- 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 +254 -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 +6 -0
- package/src/init/files/src/app/{general → main}/home/home.component.scss.template +1 -0
- package/src/init/files/src/app/main/home/home.component.ts.template +55 -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 +41 -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.prod.ts.template +6 -2
- package/src/init/files/src/environments/environment.ts.template +4 -2
- package/src/init/files/src/index.html.template +1 -1
- package/src/init/files/src/styles.scss.template +4 -0
- 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.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.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
|
@@ -1,376 +0,0 @@
|
|
|
1
|
-
import { Injectable } from '@angular/core';
|
|
2
|
-
import { MemoizedSelector, createSelector, createFeatureSelector } from '@ngrx/store';
|
|
3
|
-
import { EntityState } from '@ngrx/entity';
|
|
4
|
-
import { Store, select } from '@ngrx/store';
|
|
5
|
-
import * as fromStore from '../../core/store/app.reducer';
|
|
6
|
-
import { pluck, tap, map, switchMap, filter } from 'rxjs/operators';
|
|
7
|
-
import { Observable, of, combineLatest } from 'rxjs';
|
|
8
|
-
import { FirebaseService } from '../firebase/firebase.service';
|
|
9
|
-
|
|
10
|
-
export interface CachedSelector<T> {
|
|
11
|
-
hashKey: string;
|
|
12
|
-
selector: MemoizedSelector<fromStore.State, T>;
|
|
13
|
-
correlationIds: string[];
|
|
14
|
-
}
|
|
15
|
-
|
|
16
|
-
export enum SelectType {
|
|
17
|
-
OBJECT = 'object',
|
|
18
|
-
LIST = 'list',
|
|
19
|
-
}
|
|
20
|
-
|
|
21
|
-
@Injectable({
|
|
22
|
-
providedIn: 'root',
|
|
23
|
-
})
|
|
24
|
-
export class CachedSelectorsService {
|
|
25
|
-
/** Store selectors by entityStoreKey. */
|
|
26
|
-
private entityStoreSelectors: { [entityStoreKey: string]: MemoizedSelector<fromStore.State, any> } = {};
|
|
27
|
-
|
|
28
|
-
/** Selectors by hashKey. */
|
|
29
|
-
private selectorsByHashKey: { [hashKey: string]: CachedSelector<any> } = {};
|
|
30
|
-
|
|
31
|
-
/** Selectors by correlationId. */
|
|
32
|
-
private selectorsByCorrelationId: { [cId: string]: CachedSelector<any>[] } = {};
|
|
33
|
-
|
|
34
|
-
/** Any hardcoded data that needs to be merged into observable selected from store. */
|
|
35
|
-
private hardcodedFields = {
|
|
36
|
-
};
|
|
37
|
-
|
|
38
|
-
constructor(
|
|
39
|
-
private store: Store<fromStore.State>,
|
|
40
|
-
private db: FirebaseService,
|
|
41
|
-
) { }
|
|
42
|
-
|
|
43
|
-
public createId = () => {
|
|
44
|
-
return this.db.createId();
|
|
45
|
-
};
|
|
46
|
-
|
|
47
|
-
/**
|
|
48
|
-
* Define a unique key for each selector.
|
|
49
|
-
* @param queryParams - either a simple id string (for SelectType.OBJECT) or the queryParams array (for SelectType.LIST)
|
|
50
|
-
*/
|
|
51
|
-
private getHashKey(selectType: SelectType, entityStoreKey: string, queryParams: string | [string, string, any][]): string {
|
|
52
|
-
return `${selectType}.${entityStoreKey}.${queryParams}`;
|
|
53
|
-
}
|
|
54
|
-
|
|
55
|
-
/** Gets a cached selector if one exists. */
|
|
56
|
-
private getSelector(selectType: SelectType, entityStoreKey: string, queryParams: string | [string, string, any][]): CachedSelector<any> {
|
|
57
|
-
const hashKey = this.getHashKey(selectType, entityStoreKey, queryParams);
|
|
58
|
-
return this.selectorsByHashKey[hashKey];
|
|
59
|
-
}
|
|
60
|
-
|
|
61
|
-
/**
|
|
62
|
-
* Releases all "virtual" selectors with that correlationId.
|
|
63
|
-
* For selectors where this correlationId was the only one, release
|
|
64
|
-
* it in actuality.
|
|
65
|
-
*/
|
|
66
|
-
public release = (correlationId: string) => {
|
|
67
|
-
// Add a 5-second delay so we don't have to reselect multiple times
|
|
68
|
-
// if the next view happens to use the same selectors
|
|
69
|
-
setTimeout(() => {
|
|
70
|
-
const selectors = this.selectorsByCorrelationId[correlationId];
|
|
71
|
-
|
|
72
|
-
// If there are no selectors, just return
|
|
73
|
-
if (!selectors) {
|
|
74
|
-
return;
|
|
75
|
-
}
|
|
76
|
-
|
|
77
|
-
while (selectors.length > 0) {
|
|
78
|
-
const s = selectors.pop();
|
|
79
|
-
|
|
80
|
-
// Remove the correlationId from the list in that selector
|
|
81
|
-
const index = s.correlationIds.findIndex((cId) => cId === correlationId);
|
|
82
|
-
s.correlationIds.splice(index, 1);
|
|
83
|
-
|
|
84
|
-
// If there are no more correlationIds, then release
|
|
85
|
-
if (s.correlationIds.length === 0) {
|
|
86
|
-
s.selector.release();
|
|
87
|
-
|
|
88
|
-
// Update selectorsByHashKey
|
|
89
|
-
this.selectorsByHashKey[s.hashKey] = undefined;
|
|
90
|
-
}
|
|
91
|
-
}
|
|
92
|
-
}, 5000);
|
|
93
|
-
};
|
|
94
|
-
|
|
95
|
-
public selectEntityObj = <S, T>(
|
|
96
|
-
entityStoreKey: string,
|
|
97
|
-
id: string,
|
|
98
|
-
correlationId: string,
|
|
99
|
-
childrenFn?: (e: S) => { [index: string]: Observable<any> },
|
|
100
|
-
): Observable<T> => {
|
|
101
|
-
return this.store.pipe(
|
|
102
|
-
select(this.getEntityObjSelector<S>(entityStoreKey, id, correlationId)),
|
|
103
|
-
// TODO: filter or not? principle is that if it should exist, we shouldn't emit before it's been
|
|
104
|
-
// loaded into the store. On the other hand, what if the db messes up? could this be fragile?
|
|
105
|
-
filter((val) => val !== undefined),
|
|
106
|
-
switchMap((e) => {
|
|
107
|
-
if (!e || !childrenFn) {
|
|
108
|
-
return of(e);
|
|
109
|
-
} else {
|
|
110
|
-
const children = childrenFn(e);
|
|
111
|
-
// transform the hash of observables into an array of observable hashes
|
|
112
|
-
const obsArray = Object.keys(children).map((objKey) => {
|
|
113
|
-
const obs = children[objKey];
|
|
114
|
-
return obs.pipe(
|
|
115
|
-
map((entity) => {
|
|
116
|
-
const obj = {};
|
|
117
|
-
obj[objKey] = entity;
|
|
118
|
-
return obj;
|
|
119
|
-
}),
|
|
120
|
-
);
|
|
121
|
-
});
|
|
122
|
-
return obsArray.length === 0 ? of(e) : combineLatest(obsArray).pipe(
|
|
123
|
-
map((array) => {
|
|
124
|
-
return Object.assign({}, e, ...array);
|
|
125
|
-
}),
|
|
126
|
-
);
|
|
127
|
-
}
|
|
128
|
-
}),
|
|
129
|
-
);
|
|
130
|
-
};
|
|
131
|
-
|
|
132
|
-
public selectEntityList = <S, T>(
|
|
133
|
-
entityStoreKey: string,
|
|
134
|
-
queryParams: [string, string, any][],
|
|
135
|
-
correlationId: string,
|
|
136
|
-
childrenFn?: (e: S) => { [index: string]: Observable<any> },
|
|
137
|
-
): Observable<Array<T>> => {
|
|
138
|
-
return this.store.pipe(
|
|
139
|
-
select(this.getEntityListSelector<S>(entityStoreKey, queryParams, correlationId)),
|
|
140
|
-
// TODO: filter or not? principle is that if it should exist, we shouldn't emit before it's been
|
|
141
|
-
// loaded into the store. On the other hand, what if the db messes up? could this be fragile?
|
|
142
|
-
filter((val) => val !== undefined),
|
|
143
|
-
switchMap((entities) => {
|
|
144
|
-
if (!entities || !childrenFn || entities.length === 0) {
|
|
145
|
-
return of(entities);
|
|
146
|
-
} else {
|
|
147
|
-
return combineLatest(entities.map((e) => {
|
|
148
|
-
// If there are children, then we need to transform the hash of observables into an observable with the data object
|
|
149
|
-
const children = childrenFn(e);
|
|
150
|
-
|
|
151
|
-
const obsArray = Object.keys(children).map((objKey) => {
|
|
152
|
-
const obs = children[objKey];
|
|
153
|
-
return obs.pipe(map((entity) => {
|
|
154
|
-
const obj = {};
|
|
155
|
-
obj[objKey] = entity;
|
|
156
|
-
return obj;
|
|
157
|
-
}));
|
|
158
|
-
});
|
|
159
|
-
return obsArray.length === 0 ? of(e) : combineLatest(obsArray).pipe(
|
|
160
|
-
map((array) => {
|
|
161
|
-
return Object.assign({}, e, ...array);
|
|
162
|
-
}),
|
|
163
|
-
);
|
|
164
|
-
}));
|
|
165
|
-
}
|
|
166
|
-
}),
|
|
167
|
-
);
|
|
168
|
-
};
|
|
169
|
-
|
|
170
|
-
/* ---------------- HELPERS --------------------- */
|
|
171
|
-
|
|
172
|
-
private getEntityStoreSelector<T>(
|
|
173
|
-
entityStoreKey: string,
|
|
174
|
-
): (s: fromStore.State) => EntityState<T> {
|
|
175
|
-
const selector = this.entityStoreSelectors[entityStoreKey] ||
|
|
176
|
-
createFeatureSelector<T>(entityStoreKey);
|
|
177
|
-
|
|
178
|
-
return selector;
|
|
179
|
-
}
|
|
180
|
-
|
|
181
|
-
private getEntityListSelector<T>(
|
|
182
|
-
entityStoreKey: string,
|
|
183
|
-
queryParams: [string, string, any][],
|
|
184
|
-
correlationId: string,
|
|
185
|
-
): (s: fromStore.State) => T[] {
|
|
186
|
-
// get selector
|
|
187
|
-
let cachedSelector = this.getSelector(SelectType.LIST, entityStoreKey, queryParams);
|
|
188
|
-
|
|
189
|
-
if (cachedSelector) {
|
|
190
|
-
// if the selector already exists, just need to add correlationId
|
|
191
|
-
// if it doesn't already exist
|
|
192
|
-
if (!cachedSelector.correlationIds.some((cId) => cId === correlationId)) {
|
|
193
|
-
cachedSelector.correlationIds.push(correlationId);
|
|
194
|
-
this.selectorsByCorrelationId[correlationId] = this.selectorsByCorrelationId[correlationId] || [];
|
|
195
|
-
this.selectorsByCorrelationId[correlationId].push(cachedSelector);
|
|
196
|
-
}
|
|
197
|
-
} else {
|
|
198
|
-
// if the selector does not exist, create it
|
|
199
|
-
cachedSelector = this.createEntityListSelector<T>(entityStoreKey, queryParams, correlationId);
|
|
200
|
-
this.selectorsByHashKey[cachedSelector.hashKey] = cachedSelector;
|
|
201
|
-
this.selectorsByCorrelationId[correlationId] = this.selectorsByCorrelationId[correlationId] || [];
|
|
202
|
-
this.selectorsByCorrelationId[correlationId].push(cachedSelector);
|
|
203
|
-
}
|
|
204
|
-
return cachedSelector.selector;
|
|
205
|
-
}
|
|
206
|
-
|
|
207
|
-
private createEntityListSelector<T>(
|
|
208
|
-
entityStoreKey: string,
|
|
209
|
-
queryParams: [string, string, any][],
|
|
210
|
-
correlationId: string,
|
|
211
|
-
): CachedSelector<T[]> {
|
|
212
|
-
return {
|
|
213
|
-
hashKey: this.getHashKey(SelectType.LIST, entityStoreKey, queryParams),
|
|
214
|
-
selector: createSelector(
|
|
215
|
-
this.getEntityStoreSelector<T>(entityStoreKey),
|
|
216
|
-
(entityStore) => {
|
|
217
|
-
const val = this.getList<T>(entityStore.entities, queryParams);
|
|
218
|
-
return val.map((e) => {
|
|
219
|
-
if (this.hardcodedFields[entityStoreKey]) {
|
|
220
|
-
return Object.assign({}, e, this.hardcodedFields[entityStoreKey][e['__id']]);
|
|
221
|
-
} else {
|
|
222
|
-
return e;
|
|
223
|
-
}
|
|
224
|
-
});
|
|
225
|
-
},
|
|
226
|
-
),
|
|
227
|
-
correlationIds: [correlationId],
|
|
228
|
-
};
|
|
229
|
-
}
|
|
230
|
-
|
|
231
|
-
private getList<T>(
|
|
232
|
-
entityHash: { [index: string]: T },
|
|
233
|
-
queryParams: [string, string, any][],
|
|
234
|
-
): Array<T & { [index: string]: any }> {
|
|
235
|
-
let filteredEntities = [];
|
|
236
|
-
|
|
237
|
-
// APPLY '__id', '=='/in FILTERS
|
|
238
|
-
|
|
239
|
-
const selectIdEqQueries = queryParams.filter((q) => q[0] === '__id' && q[1] === '==');
|
|
240
|
-
const uniqSelectEqIds = selectIdEqQueries.map((q) => q[2]).filter((q, i, a) => a.indexOf(q) === i);
|
|
241
|
-
const selectIdInQueries = queryParams.filter((q) => q[0] === '__id' && q[1] === 'in');
|
|
242
|
-
|
|
243
|
-
if (uniqSelectEqIds.length === 1 && entityHash[uniqSelectEqIds[0]]) {
|
|
244
|
-
// If there is exactly one '__id', we can start with that to filter
|
|
245
|
-
if (entityHash[uniqSelectEqIds[0]]) {
|
|
246
|
-
filteredEntities.push(entityHash[uniqSelectEqIds[0]]);
|
|
247
|
-
}
|
|
248
|
-
} else if (uniqSelectEqIds.length > 1) {
|
|
249
|
-
// If there are more than one select id ==, then there cannot be any matches
|
|
250
|
-
console.log('Is this really what you wanted to query?');
|
|
251
|
-
console.log(queryParams);
|
|
252
|
-
return [];
|
|
253
|
-
} else if (selectIdInQueries.length > 0) {
|
|
254
|
-
// If there is at least one 'in' query, start with that.
|
|
255
|
-
const firstInIds = selectIdInQueries[0][2];
|
|
256
|
-
filteredEntities = firstInIds.map((id) => entityHash[id]).filter((e) => e !== undefined);
|
|
257
|
-
|
|
258
|
-
// Then apply remaining 'in' filters. See general filter section
|
|
259
|
-
// for comments since this is just copied from that.
|
|
260
|
-
if (selectIdInQueries.length > 1) {
|
|
261
|
-
filteredEntities = filteredEntities.filter((e) => {
|
|
262
|
-
return !selectIdInQueries.slice(1).find((f) => {
|
|
263
|
-
const [key, rel, val] = f;
|
|
264
|
-
return !(val.find((ev) => ev === e[key]));
|
|
265
|
-
});
|
|
266
|
-
});
|
|
267
|
-
}
|
|
268
|
-
} else {
|
|
269
|
-
// Otherwise, start with the full list and filter further.
|
|
270
|
-
filteredEntities = Object.keys(entityHash).map((id) => entityHash[id]);
|
|
271
|
-
}
|
|
272
|
-
|
|
273
|
-
// APPLY REMAINING FILTERS
|
|
274
|
-
if (queryParams) {
|
|
275
|
-
filteredEntities = filteredEntities.filter((e) => {
|
|
276
|
-
// Looks for the first failed filter. If there exists any,
|
|
277
|
-
// return false (filter it out)
|
|
278
|
-
return !queryParams.find((f) => {
|
|
279
|
-
const [key, rel, val] = f;
|
|
280
|
-
|
|
281
|
-
// already processed '__id', '=='/'in', so always passes this filter
|
|
282
|
-
if (key === '__id' && (rel === '==' || rel === 'in')) {
|
|
283
|
-
return false;
|
|
284
|
-
}
|
|
285
|
-
|
|
286
|
-
// we try to handle the same operations as Firestore for consistency
|
|
287
|
-
switch (rel) {
|
|
288
|
-
case '==':
|
|
289
|
-
return !(e[key] === val);
|
|
290
|
-
case '!=':
|
|
291
|
-
return !(e[key] !== val);
|
|
292
|
-
|
|
293
|
-
case '>=':
|
|
294
|
-
return !(e[key] >= val);
|
|
295
|
-
|
|
296
|
-
case '<=':
|
|
297
|
-
return !(e[key] <= val);
|
|
298
|
-
|
|
299
|
-
case '>':
|
|
300
|
-
return !(e[key] > val);
|
|
301
|
-
|
|
302
|
-
case '<':
|
|
303
|
-
return !(e[key] < val);
|
|
304
|
-
|
|
305
|
-
case 'array-contains':
|
|
306
|
-
// If the parameter in question is optional, it should be filtered out
|
|
307
|
-
return e[key] ? !(e[key].find((ev) => ev === val)) : true;
|
|
308
|
-
|
|
309
|
-
case 'in':
|
|
310
|
-
return !(val.find((ev) => ev === e[key]));
|
|
311
|
-
|
|
312
|
-
default:
|
|
313
|
-
return false;
|
|
314
|
-
}
|
|
315
|
-
});
|
|
316
|
-
});
|
|
317
|
-
}
|
|
318
|
-
|
|
319
|
-
return filteredEntities;
|
|
320
|
-
}
|
|
321
|
-
|
|
322
|
-
private getEntityObjSelector<T>(
|
|
323
|
-
entityStoreKey: string,
|
|
324
|
-
id: string,
|
|
325
|
-
correlationId: string,
|
|
326
|
-
): (s: fromStore.State) => T {
|
|
327
|
-
// get selector
|
|
328
|
-
let cachedSelector = this.getSelector(SelectType.OBJECT, entityStoreKey, id);
|
|
329
|
-
|
|
330
|
-
if (cachedSelector) {
|
|
331
|
-
// if the selector already exists, just need to add correlationId
|
|
332
|
-
// if it doesn't already exist
|
|
333
|
-
if (!cachedSelector.correlationIds.some((cId) => cId === correlationId)) {
|
|
334
|
-
cachedSelector.correlationIds.push(correlationId);
|
|
335
|
-
this.selectorsByCorrelationId[correlationId] = this.selectorsByCorrelationId[correlationId] || [];
|
|
336
|
-
this.selectorsByCorrelationId[correlationId].push(cachedSelector);
|
|
337
|
-
}
|
|
338
|
-
} else {
|
|
339
|
-
// if the selector does not exist, create it
|
|
340
|
-
cachedSelector = this.createEntityObjSelector<T>(entityStoreKey, id, correlationId);
|
|
341
|
-
this.selectorsByHashKey[cachedSelector.hashKey] = cachedSelector;
|
|
342
|
-
this.selectorsByCorrelationId[correlationId] = this.selectorsByCorrelationId[correlationId] || [];
|
|
343
|
-
this.selectorsByCorrelationId[correlationId].push(cachedSelector);
|
|
344
|
-
}
|
|
345
|
-
return cachedSelector.selector;
|
|
346
|
-
}
|
|
347
|
-
|
|
348
|
-
private createEntityObjSelector<T>(
|
|
349
|
-
entityStoreKey: string,
|
|
350
|
-
id: string,
|
|
351
|
-
correlationId: string,
|
|
352
|
-
): CachedSelector<T> {
|
|
353
|
-
return {
|
|
354
|
-
hashKey: this.getHashKey(SelectType.OBJECT, entityStoreKey, id),
|
|
355
|
-
selector: createSelector(
|
|
356
|
-
this.getEntityStoreSelector<T>(entityStoreKey),
|
|
357
|
-
(entityStore) => {
|
|
358
|
-
const e = this.getObj<T>(entityStore.entities, id);
|
|
359
|
-
if (e && this.hardcodedFields[entityStoreKey]) {
|
|
360
|
-
return Object.assign({}, e, this.hardcodedFields[entityStoreKey][e['__id']]);
|
|
361
|
-
} else {
|
|
362
|
-
return e;
|
|
363
|
-
}
|
|
364
|
-
},
|
|
365
|
-
),
|
|
366
|
-
correlationIds: [correlationId],
|
|
367
|
-
};
|
|
368
|
-
}
|
|
369
|
-
|
|
370
|
-
private getObj<T>(
|
|
371
|
-
entityHash: { [index: string]: T },
|
|
372
|
-
id: string,
|
|
373
|
-
): T & { [index: string]: any } {
|
|
374
|
-
return entityHash[id];
|
|
375
|
-
}
|
|
376
|
-
}
|
|
@@ -1,66 +0,0 @@
|
|
|
1
|
-
import { Injectable } from '@angular/core';
|
|
2
|
-
import { Action } from '@ngrx/store';
|
|
3
|
-
import { Actions, ofType } from '@ngrx/effects';
|
|
4
|
-
import { select, Store } from '@ngrx/store';
|
|
5
|
-
import * as fromStore from './app.reducer';
|
|
6
|
-
import { Observable, pipe, forkJoin } from 'rxjs';
|
|
7
|
-
import { reduce, filter, mergeMap, map, take, first } from 'rxjs/operators';
|
|
8
|
-
|
|
9
|
-
@Injectable({
|
|
10
|
-
providedIn: 'root',
|
|
11
|
-
})
|
|
12
|
-
export class EffectsHelpers {
|
|
13
|
-
constructor(
|
|
14
|
-
private actions$: Actions,
|
|
15
|
-
private store: Store<fromStore.State>,
|
|
16
|
-
) {}
|
|
17
|
-
|
|
18
|
-
/**
|
|
19
|
-
* aggregates multiple actions together based on a calculated actionTypeArray
|
|
20
|
-
* (computed from the passed in function applied to the original action) and
|
|
21
|
-
* the correlationId
|
|
22
|
-
*/
|
|
23
|
-
aggregate = <A, R extends Action>(fn: (o: A) => Array<string|string[]>, correlationId: string) => pipe(
|
|
24
|
-
mergeMap((origAction: A): Observable<R[]> => {
|
|
25
|
-
const actionTypeArray = fn(origAction);
|
|
26
|
-
const actionObs = actionTypeArray.map((at) => {
|
|
27
|
-
return this.actions$.pipe(
|
|
28
|
-
Array.isArray(at) ? ofType(...at) : ofType(at),
|
|
29
|
-
this.hasCorrelationId(correlationId),
|
|
30
|
-
first(),
|
|
31
|
-
);
|
|
32
|
-
}) as Array<Observable<R>>;
|
|
33
|
-
return forkJoin(actionObs);
|
|
34
|
-
}),
|
|
35
|
-
);
|
|
36
|
-
|
|
37
|
-
/**
|
|
38
|
-
* enriches the original content in the event stream with the result from contentFn's
|
|
39
|
-
* returned the observable when it is applied to the original content.
|
|
40
|
-
*/
|
|
41
|
-
enrich = <A, P extends object>(contentFn$: (o: A) => Observable<P>) => pipe(
|
|
42
|
-
mergeMap((orig: A): Observable<A & { payload: P }> => {
|
|
43
|
-
// payload may not be defined on this Action
|
|
44
|
-
const payload = orig['payload'] || { };
|
|
45
|
-
|
|
46
|
-
return contentFn$(orig).pipe(
|
|
47
|
-
take(1),
|
|
48
|
-
map<P, A & { payload: P }>((c) => Object.assign({}, orig, {
|
|
49
|
-
payload: { ...payload, ...(c as object) },
|
|
50
|
-
})),
|
|
51
|
-
);
|
|
52
|
-
}),
|
|
53
|
-
);
|
|
54
|
-
|
|
55
|
-
/** Filter to Actions with specified correlationId(s). */
|
|
56
|
-
hasCorrelationId = <T extends Action>(correlationIds: string | string[]) => pipe(
|
|
57
|
-
// Use hash syntax since correlationId may not be defined on this Action
|
|
58
|
-
filter<T>((origAction) => {
|
|
59
|
-
if (!Array.isArray(correlationIds)) {
|
|
60
|
-
return origAction['correlationId'] === correlationIds;
|
|
61
|
-
} else {
|
|
62
|
-
return correlationIds.includes(origAction['correlationId']);
|
|
63
|
-
}
|
|
64
|
-
}),
|
|
65
|
-
);
|
|
66
|
-
}
|
|
@@ -1,248 +0,0 @@
|
|
|
1
|
-
import { Action } from '@ngrx/store';
|
|
2
|
-
import { LoadAction } from '../app.actions';
|
|
3
|
-
import { User } from './user.model';
|
|
4
|
-
|
|
5
|
-
export enum UserActionTypes {
|
|
6
|
-
STREAM = '[User] stream user',
|
|
7
|
-
STREAM_SUCCESS = '[User] stream user success',
|
|
8
|
-
STREAM_FAIL = '[User] stream user fail',
|
|
9
|
-
LOAD = '[User] load user',
|
|
10
|
-
LOAD_SUCCESS = '[User] load user success',
|
|
11
|
-
LOAD_FAIL = '[User] load user fail',
|
|
12
|
-
ADD = '[User] add user',
|
|
13
|
-
ADD_SUCCESS = '[User] add user success',
|
|
14
|
-
ADD_FAIL = '[User] add user fail',
|
|
15
|
-
UPDATE = '[User] update user',
|
|
16
|
-
UPDATE_SUCCESS = '[User] update user success',
|
|
17
|
-
UPDATE_FAIL = '[User] update user fail',
|
|
18
|
-
REMOVE = '[User] remove user',
|
|
19
|
-
REMOVE_SUCCESS = '[User] remove user success',
|
|
20
|
-
REMOVE_FAIL = '[User] remove user fail',
|
|
21
|
-
LOADED = '[User] loaded',
|
|
22
|
-
ADDED = '[User] added',
|
|
23
|
-
MODIFIED = '[User] modified',
|
|
24
|
-
REMOVED = '[User] removed',
|
|
25
|
-
}
|
|
26
|
-
|
|
27
|
-
// See Firebase Docs for current constraints on valid queries
|
|
28
|
-
export class StreamUser implements Action {
|
|
29
|
-
readonly type = UserActionTypes.STREAM;
|
|
30
|
-
constructor(
|
|
31
|
-
// property, comparator, value
|
|
32
|
-
public queryParams: [string, string, any][],
|
|
33
|
-
public queryOptions: {
|
|
34
|
-
orderBy?: string | [string, string],
|
|
35
|
-
limit?: number,
|
|
36
|
-
startAt?: string,
|
|
37
|
-
startAfter?: string,
|
|
38
|
-
endAt?: string,
|
|
39
|
-
endBefore?: string,
|
|
40
|
-
},
|
|
41
|
-
public correlationId: string,
|
|
42
|
-
public followupActions?: (user: User) => LoadAction[],
|
|
43
|
-
) {}
|
|
44
|
-
}
|
|
45
|
-
|
|
46
|
-
export class StreamUserSuccess implements Action {
|
|
47
|
-
readonly type = UserActionTypes.STREAM_SUCCESS;
|
|
48
|
-
constructor(
|
|
49
|
-
public queryParams: [string, string, any][],
|
|
50
|
-
public queryOptions: {
|
|
51
|
-
orderBy?: string | [string, string],
|
|
52
|
-
limit?: number,
|
|
53
|
-
startAt?: string,
|
|
54
|
-
startAfter?: string,
|
|
55
|
-
endAt?: string,
|
|
56
|
-
endBefore?: string,
|
|
57
|
-
},
|
|
58
|
-
public correlationId: string,
|
|
59
|
-
public followupActions?: (user: User) => LoadAction[],
|
|
60
|
-
) {}
|
|
61
|
-
}
|
|
62
|
-
|
|
63
|
-
export class StreamUserFail implements Action {
|
|
64
|
-
readonly type = UserActionTypes.STREAM_FAIL;
|
|
65
|
-
constructor(
|
|
66
|
-
public error: any,
|
|
67
|
-
public correlationId?: string,
|
|
68
|
-
) {}
|
|
69
|
-
}
|
|
70
|
-
|
|
71
|
-
export class LoadUser implements Action {
|
|
72
|
-
readonly type = UserActionTypes.LOAD;
|
|
73
|
-
constructor(
|
|
74
|
-
// property, comparator, value
|
|
75
|
-
public queryParams: [string, string, any][],
|
|
76
|
-
public queryOptions: {
|
|
77
|
-
orderBy?: string | [string, string],
|
|
78
|
-
limit?: number,
|
|
79
|
-
startAt?: string,
|
|
80
|
-
startAfter?: string,
|
|
81
|
-
endAt?: string,
|
|
82
|
-
endBefore?: string,
|
|
83
|
-
},
|
|
84
|
-
public correlationId: string,
|
|
85
|
-
public followupActions?: (user: User) => LoadAction[],
|
|
86
|
-
) {}
|
|
87
|
-
}
|
|
88
|
-
|
|
89
|
-
export class LoadUserSuccess implements Action {
|
|
90
|
-
readonly type = UserActionTypes.LOAD_SUCCESS;
|
|
91
|
-
constructor(
|
|
92
|
-
public queryParams: [string, string, any][],
|
|
93
|
-
public queryOptions: {
|
|
94
|
-
orderBy?: string | [string, string],
|
|
95
|
-
limit?: number,
|
|
96
|
-
startAt?: string,
|
|
97
|
-
startAfter?: string,
|
|
98
|
-
endAt?: string,
|
|
99
|
-
endBefore?: string,
|
|
100
|
-
},
|
|
101
|
-
public correlationId: string,
|
|
102
|
-
public followupActions?: (user: User) => LoadAction[],
|
|
103
|
-
) {}
|
|
104
|
-
}
|
|
105
|
-
|
|
106
|
-
export class LoadUserFail implements Action {
|
|
107
|
-
readonly type = UserActionTypes.LOAD_FAIL;
|
|
108
|
-
constructor(
|
|
109
|
-
public error: any,
|
|
110
|
-
public correlationId?: string,
|
|
111
|
-
) {}
|
|
112
|
-
}
|
|
113
|
-
|
|
114
|
-
export class AddUser implements Action {
|
|
115
|
-
readonly type = UserActionTypes.ADD;
|
|
116
|
-
constructor(
|
|
117
|
-
public user: User,
|
|
118
|
-
public correlationId?: string,
|
|
119
|
-
public options?: {
|
|
120
|
-
optimistic?: boolean,
|
|
121
|
-
},
|
|
122
|
-
) {}
|
|
123
|
-
}
|
|
124
|
-
|
|
125
|
-
export class AddUserSuccess implements Action {
|
|
126
|
-
readonly type = UserActionTypes.ADD_SUCCESS;
|
|
127
|
-
constructor(
|
|
128
|
-
public user: User,
|
|
129
|
-
public correlationId?: string,
|
|
130
|
-
public options?: {
|
|
131
|
-
optimistic?: boolean,
|
|
132
|
-
},
|
|
133
|
-
) {}
|
|
134
|
-
}
|
|
135
|
-
|
|
136
|
-
export class AddUserFail implements Action {
|
|
137
|
-
readonly type = UserActionTypes.ADD_FAIL;
|
|
138
|
-
constructor(
|
|
139
|
-
public error: any,
|
|
140
|
-
public correlationId?: string,
|
|
141
|
-
public options?: {
|
|
142
|
-
optimistic?: boolean,
|
|
143
|
-
},
|
|
144
|
-
) {}
|
|
145
|
-
}
|
|
146
|
-
|
|
147
|
-
export class UpdateUser implements Action {
|
|
148
|
-
readonly type = UserActionTypes.UPDATE;
|
|
149
|
-
constructor(
|
|
150
|
-
public __id: string,
|
|
151
|
-
public changes: Partial<User>,
|
|
152
|
-
public correlationId?: string,
|
|
153
|
-
) { }
|
|
154
|
-
}
|
|
155
|
-
|
|
156
|
-
export class UpdateUserSuccess implements Action {
|
|
157
|
-
readonly type = UserActionTypes.UPDATE_SUCCESS;
|
|
158
|
-
constructor(
|
|
159
|
-
public __id: string,
|
|
160
|
-
public changes: Partial<User>,
|
|
161
|
-
public correlationId?: string,
|
|
162
|
-
) {}
|
|
163
|
-
}
|
|
164
|
-
|
|
165
|
-
export class UpdateUserFail implements Action {
|
|
166
|
-
readonly type = UserActionTypes.UPDATE_FAIL;
|
|
167
|
-
constructor(
|
|
168
|
-
public error: any,
|
|
169
|
-
public correlationId?: string,
|
|
170
|
-
) {}
|
|
171
|
-
}
|
|
172
|
-
|
|
173
|
-
export class RemoveUser implements Action {
|
|
174
|
-
readonly type = UserActionTypes.REMOVE;
|
|
175
|
-
constructor(
|
|
176
|
-
public __id: string,
|
|
177
|
-
public correlationId?: string,
|
|
178
|
-
) { }
|
|
179
|
-
}
|
|
180
|
-
|
|
181
|
-
export class RemoveUserSuccess implements Action {
|
|
182
|
-
readonly type = UserActionTypes.REMOVE_SUCCESS;
|
|
183
|
-
constructor(
|
|
184
|
-
public __id: string,
|
|
185
|
-
public correlationId?: string,
|
|
186
|
-
) {}
|
|
187
|
-
}
|
|
188
|
-
|
|
189
|
-
export class RemoveUserFail implements Action {
|
|
190
|
-
readonly type = UserActionTypes.REMOVE_FAIL;
|
|
191
|
-
constructor(
|
|
192
|
-
public error: any,
|
|
193
|
-
public correlationId?: string,
|
|
194
|
-
) {}
|
|
195
|
-
}
|
|
196
|
-
|
|
197
|
-
export class LoadedUser implements Action {
|
|
198
|
-
readonly type = UserActionTypes.LOADED;
|
|
199
|
-
constructor(
|
|
200
|
-
public payload: User[],
|
|
201
|
-
public correlationId?: string,
|
|
202
|
-
) {}
|
|
203
|
-
}
|
|
204
|
-
|
|
205
|
-
export class AddedUser implements Action {
|
|
206
|
-
readonly type = UserActionTypes.ADDED;
|
|
207
|
-
constructor(
|
|
208
|
-
public payload: User,
|
|
209
|
-
public correlationId?: string,
|
|
210
|
-
) {}
|
|
211
|
-
}
|
|
212
|
-
|
|
213
|
-
export class ModifiedUser implements Action {
|
|
214
|
-
readonly type = UserActionTypes.MODIFIED;
|
|
215
|
-
constructor(
|
|
216
|
-
public payload: User,
|
|
217
|
-
public correlationId?: string,
|
|
218
|
-
) {}
|
|
219
|
-
}
|
|
220
|
-
|
|
221
|
-
export class RemovedUser implements Action {
|
|
222
|
-
readonly type = UserActionTypes.REMOVED;
|
|
223
|
-
constructor(
|
|
224
|
-
public payload: User,
|
|
225
|
-
public correlationId?: string,
|
|
226
|
-
) {}
|
|
227
|
-
}
|
|
228
|
-
|
|
229
|
-
export type UserActions =
|
|
230
|
-
StreamUser |
|
|
231
|
-
StreamUserSuccess |
|
|
232
|
-
StreamUserFail |
|
|
233
|
-
LoadUser |
|
|
234
|
-
LoadUserSuccess |
|
|
235
|
-
LoadUserFail |
|
|
236
|
-
AddUser |
|
|
237
|
-
AddUserSuccess |
|
|
238
|
-
AddUserFail |
|
|
239
|
-
UpdateUser |
|
|
240
|
-
UpdateUserSuccess |
|
|
241
|
-
UpdateUserFail |
|
|
242
|
-
RemoveUser |
|
|
243
|
-
RemoveUserSuccess |
|
|
244
|
-
RemoveUserFail |
|
|
245
|
-
LoadedUser |
|
|
246
|
-
AddedUser |
|
|
247
|
-
ModifiedUser |
|
|
248
|
-
RemovedUser;
|