@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.
Files changed (220) hide show
  1. package/README.md +8 -0
  2. package/package.json +4 -4
  3. package/src/collection.json +0 -16
  4. package/src/component/files/__name@dasherize__/__name@dasherize__.component.ts.template +22 -8
  5. package/src/component/index.js +2 -45
  6. package/src/component/index.js.map +1 -1
  7. package/src/component/schema.json +0 -5
  8. package/src/entity/files/__name@dasherize__/__name@dasherize__.mock.ts.template +12 -0
  9. package/src/entity/files/__name@dasherize__/__name@dasherize__.model.ts.template +1 -0
  10. package/src/entity/files/__name@dasherize__/__name@dasherize__.store.ts.template +41 -0
  11. package/src/entity/index.js +29 -50
  12. package/src/entity/index.js.map +1 -1
  13. package/src/init/files/.firebaserc.template +8 -0
  14. package/src/init/files/README.md.template +6 -6
  15. package/src/init/files/angular.json.template +18 -11
  16. package/src/init/files/package.json.template +29 -30
  17. package/src/init/files/src/app/admin/{waitlist/waitlist.animations.ts.template → admin-panel/admin-panel.animations.ts.template} +1 -1
  18. package/src/init/files/src/app/admin/{waitlist/waitlist.component.html.template → admin-panel/admin-panel.component.html.template} +3 -3
  19. package/src/init/files/src/app/admin/{waitlist/waitlist.component.scss.template → admin-panel/admin-panel.component.scss.template} +1 -1
  20. package/src/init/files/src/app/admin/admin-panel/admin-panel.component.spec.ts.template +25 -0
  21. package/src/init/files/src/app/admin/admin-panel/admin-panel.component.ts.template +99 -0
  22. package/src/init/files/src/app/app.component.html.template +1 -0
  23. package/src/init/files/src/app/app.component.ts.template +14 -8
  24. package/src/init/files/src/app/app.config.ts.template +63 -0
  25. package/src/init/files/src/app/app.routes.ts.template +32 -0
  26. package/src/init/files/src/app/core/analytics/log.service.ts.template +122 -89
  27. package/src/init/files/src/app/core/analytics/time-analytics.service.ts.template +9 -17
  28. package/src/init/files/src/app/core/auth/auth.guard.ts.template +25 -22
  29. package/src/init/files/src/app/core/firebase/cached-listeners.service.ts.template +291 -0
  30. package/src/init/files/src/app/core/firebase/database.service.ts.template +56 -0
  31. package/src/init/files/src/app/core/firebase/firebase.mock.service.ts.template +276 -0
  32. package/src/init/files/src/app/core/firebase/firebase.service.ts.template +265 -215
  33. package/src/init/files/src/app/core/local-storage/session.service.ts.template +3 -4
  34. package/src/init/files/src/app/core/store/app.model.ts.template +19 -0
  35. package/src/init/files/src/app/core/store/app.store.ts.template +1074 -0
  36. package/src/init/files/src/app/core/store/auth/auth.mock.ts.template +20 -0
  37. package/src/init/files/src/app/core/store/auth/auth.store.ts.template +136 -0
  38. package/src/init/files/src/app/core/store/batch-write.firebase.service.ts.template +58 -0
  39. package/src/init/files/src/app/core/store/batch-write.mock.service.ts.template +105 -0
  40. package/src/init/files/src/app/core/store/batch-write.service.ts.template +126 -0
  41. package/src/init/files/src/app/core/store/user/user.mock.ts.template +24 -0
  42. package/src/init/files/src/app/core/store/user/user.model.ts.template +1 -1
  43. package/src/init/files/src/app/core/store/user/user.store.ts.template +41 -0
  44. package/src/init/files/src/app/core/store/user-context/user-context.mock.ts.template +24 -0
  45. package/src/init/files/src/app/core/store/user-context/user-context.model.ts.template +1 -0
  46. package/src/init/files/src/app/core/store/user-context/user-context.store.ts.template +41 -0
  47. package/src/init/files/src/app/core/utils/rand.utils.ts.template +13 -0
  48. package/src/init/files/src/app/{onboarding → first-time}/consent/consent.component.html.template +8 -13
  49. package/src/init/files/src/app/first-time/consent/consent.component.ts.template +90 -0
  50. package/src/init/files/src/app/first-time/early-access/early-access.animations.ts.template +4 -0
  51. package/src/init/files/src/app/first-time/early-access/early-access.component.html.template +69 -0
  52. package/src/init/files/src/app/{onboarding/waiting/waiting.component.scss.template → first-time/early-access/early-access.component.scss.template} +1 -1
  53. package/src/init/files/src/app/first-time/early-access/early-access.component.spec.ts.template +25 -0
  54. package/src/init/files/src/app/first-time/early-access/early-access.component.ts.template +194 -0
  55. package/src/init/files/src/app/first-time/early-access/early-access.model.ts.template +7 -0
  56. package/src/init/files/src/app/{general → first-time}/landing/landing.component.html.template +1 -1
  57. package/src/init/files/src/app/first-time/landing/landing.component.ts.template +44 -0
  58. package/src/init/files/src/app/first-time/login/login.component.html.template +10 -0
  59. package/src/init/files/src/app/first-time/login/login.component.ts.template +45 -0
  60. package/src/init/files/src/app/first-time/onboarding/onboarding.animations.ts.template +4 -0
  61. package/src/init/files/src/app/first-time/onboarding/onboarding.component.html.template +2 -0
  62. package/src/init/files/src/app/first-time/onboarding/onboarding.component.scss.template +5 -0
  63. package/src/init/files/src/app/{admin/waitlist/waitlist.component.spec.ts.template → first-time/onboarding/onboarding.component.spec.ts.template} +6 -6
  64. package/src/init/files/src/app/first-time/onboarding/onboarding.component.ts.template +41 -0
  65. package/src/init/files/src/app/main/home/home.component.html.template +5 -0
  66. package/src/init/files/src/app/main/home/home.component.ts.template +51 -0
  67. package/src/init/files/src/app/shared/navbar/navbar.component.html.template +15 -0
  68. package/src/init/files/src/app/shared/navbar/navbar.component.scss.template +43 -0
  69. package/src/init/files/src/app/shared/navbar/navbar.component.spec.ts.template +25 -0
  70. package/src/init/files/src/app/shared/navbar/navbar.component.ts.template +40 -0
  71. package/src/init/files/src/app/shared/redeployment-warning/redeployment-warning.component.html.template +9 -0
  72. package/src/init/files/src/app/shared/{components/redeployment-warning → redeployment-warning}/redeployment-warning.component.ts.template +17 -6
  73. package/src/init/files/src/app/shared/{components/redeployment-warning → redeployment-warning}/redeployment-warning.service.ts.template +2 -2
  74. package/src/init/files/src/assets/images/close-x.svg +3 -0
  75. package/src/init/files/src/environments/environment.ts.template +1 -0
  76. package/src/init/files/src/index.html.template +1 -1
  77. package/src/init/files/tsconfig.json.template +0 -1
  78. package/src/container/files/__name@dasherize__/+state/__name@dasherize__.actions.ts.template +0 -26
  79. package/src/container/files/__name@dasherize__/+state/__name@dasherize__.effects.ts.template +0 -48
  80. package/src/container/files/__name@dasherize__/+state/__name@dasherize__.model.ts.template +0 -0
  81. package/src/container/files/__name@dasherize__/+state/__name@dasherize__.selectors.ts.template +0 -20
  82. package/src/container/files/__name@dasherize__/+state/__name@dasherize__.state.ts.template +0 -13
  83. package/src/container/files/__name@dasherize__/__name@dasherize__.animations.ts.template +0 -4
  84. package/src/container/files/__name@dasherize__/__name@dasherize__.component.html.template +0 -3
  85. package/src/container/files/__name@dasherize__/__name@dasherize__.component.scss.template +0 -5
  86. package/src/container/files/__name@dasherize__/__name@dasherize__.component.spec.ts.template +0 -25
  87. package/src/container/files/__name@dasherize__/__name@dasherize__.component.ts.template +0 -90
  88. package/src/container/index.d.ts +0 -2
  89. package/src/container/index.js +0 -127
  90. package/src/container/index.js.map +0 -1
  91. package/src/container/index_spec.d.ts +0 -1
  92. package/src/container/index_spec.js +0 -23
  93. package/src/container/index_spec.js.map +0 -1
  94. package/src/container/schema.json +0 -50
  95. package/src/entity/files/__name@dasherize__/__name@dasherize__.actions.ts.template +0 -249
  96. package/src/entity/files/__name@dasherize__/__name@dasherize__.effects.ts.template +0 -131
  97. package/src/entity/files/__name@dasherize__/__name@dasherize__.reducer.spec.ts.template +0 -13
  98. package/src/entity/files/__name@dasherize__/__name@dasherize__.reducer.ts.template +0 -51
  99. package/src/entity/files/__name@dasherize__/__name@dasherize__.service.ts.template +0 -50
  100. package/src/entity-in-example/files/__name@dasherize__/__name@dasherize__.actions.ts.template +0 -270
  101. package/src/entity-in-example/files/__name@dasherize__/__name@dasherize__.effects.ts.template +0 -131
  102. package/src/entity-in-example/files/__name@dasherize__/__name@dasherize__.model.ts.template +0 -3
  103. package/src/entity-in-example/files/__name@dasherize__/__name@dasherize__.reducer.spec.ts.template +0 -13
  104. package/src/entity-in-example/files/__name@dasherize__/__name@dasherize__.reducer.ts.template +0 -51
  105. package/src/entity-in-example/files/__name@dasherize__/__name@dasherize__.service.ts.template +0 -50
  106. package/src/entity-in-example/index.d.ts +0 -2
  107. package/src/entity-in-example/index.js +0 -141
  108. package/src/entity-in-example/index.js.map +0 -1
  109. package/src/entity-in-example/index_spec.d.ts +0 -1
  110. package/src/entity-in-example/index_spec.js +0 -23
  111. package/src/entity-in-example/index_spec.js.map +0 -1
  112. package/src/entity-in-example/schema.json +0 -45
  113. package/src/init/files/CHANGELOG.md.template +0 -10
  114. package/src/init/files/src/app/admin/admin-routing.module.ts.template +0 -17
  115. package/src/init/files/src/app/admin/admin.module.spec.ts.template +0 -13
  116. package/src/init/files/src/app/admin/admin.module.ts.template +0 -28
  117. package/src/init/files/src/app/admin/waitlist/+state/waitlist.actions.ts.template +0 -23
  118. package/src/init/files/src/app/admin/waitlist/+state/waitlist.effects.ts.template +0 -50
  119. package/src/init/files/src/app/admin/waitlist/+state/waitlist.model.ts.template +0 -0
  120. package/src/init/files/src/app/admin/waitlist/+state/waitlist.selectors.ts.template +0 -39
  121. package/src/init/files/src/app/admin/waitlist/+state/waitlist.state.ts.template +0 -13
  122. package/src/init/files/src/app/admin/waitlist/waitlist.component.ts.template +0 -141
  123. package/src/init/files/src/app/app-routing.module.ts.template +0 -26
  124. package/src/init/files/src/app/app.module.ts.template +0 -34
  125. package/src/init/files/src/app/core/core.module.ts.template +0 -75
  126. package/src/init/files/src/app/core/setup/firebase-setup.ts.template +0 -25
  127. package/src/init/files/src/app/core/setup/module-import-guard.ts.template +0 -5
  128. package/src/init/files/src/app/core/snackbar/snackbar.actions.ts.template +0 -24
  129. package/src/init/files/src/app/core/snackbar/snackbar.effects.ts.template +0 -41
  130. package/src/init/files/src/app/core/store/app-state/app-state.actions.ts.template +0 -249
  131. package/src/init/files/src/app/core/store/app-state/app-state.effects.ts.template +0 -131
  132. package/src/init/files/src/app/core/store/app-state/app-state.model.ts.template +0 -8
  133. package/src/init/files/src/app/core/store/app-state/app-state.reducer.spec.ts.template +0 -13
  134. package/src/init/files/src/app/core/store/app-state/app-state.reducer.ts.template +0 -51
  135. package/src/init/files/src/app/core/store/app-state/app-state.service.ts.template +0 -50
  136. package/src/init/files/src/app/core/store/app.actions.ts.template +0 -92
  137. package/src/init/files/src/app/core/store/app.effects.ts.template +0 -175
  138. package/src/init/files/src/app/core/store/app.reducer.ts.template +0 -36
  139. package/src/init/files/src/app/core/store/app.selectors.ts.template +0 -42
  140. package/src/init/files/src/app/core/store/auth/auth.actions.ts.template +0 -77
  141. package/src/init/files/src/app/core/store/auth/auth.effects.ts.template +0 -163
  142. package/src/init/files/src/app/core/store/auth/auth.reducer.spec.ts.template +0 -13
  143. package/src/init/files/src/app/core/store/auth/auth.reducer.ts.template +0 -26
  144. package/src/init/files/src/app/core/store/auth/auth.selectors.ts.template +0 -25
  145. package/src/init/files/src/app/core/store/cached-load-connections.service.ts.template +0 -405
  146. package/src/init/files/src/app/core/store/cached-selectors.service.ts.template +0 -376
  147. package/src/init/files/src/app/core/store/effects.helpers.ts.template +0 -66
  148. package/src/init/files/src/app/core/store/user/user.actions.ts.template +0 -248
  149. package/src/init/files/src/app/core/store/user/user.effects.ts.template +0 -148
  150. package/src/init/files/src/app/core/store/user/user.reducer.spec.ts.template +0 -13
  151. package/src/init/files/src/app/core/store/user/user.reducer.ts.template +0 -50
  152. package/src/init/files/src/app/core/store/user/user.service.ts.template +0 -50
  153. package/src/init/files/src/app/core/store/user-context/user-context.actions.ts.template +0 -248
  154. package/src/init/files/src/app/core/store/user-context/user-context.effects.ts.template +0 -131
  155. package/src/init/files/src/app/core/store/user-context/user-context.reducer.spec.ts.template +0 -13
  156. package/src/init/files/src/app/core/store/user-context/user-context.reducer.ts.template +0 -51
  157. package/src/init/files/src/app/core/store/user-context/user-context.service.ts.template +0 -50
  158. package/src/init/files/src/app/core/utils/string-case.utils.ts.template +0 -96
  159. package/src/init/files/src/app/general/general-routing.module.ts.template +0 -25
  160. package/src/init/files/src/app/general/general.module.spec.ts.template +0 -13
  161. package/src/init/files/src/app/general/general.module.ts.template +0 -36
  162. package/src/init/files/src/app/general/home/+state/home.actions.ts.template +0 -26
  163. package/src/init/files/src/app/general/home/+state/home.effects.ts.template +0 -48
  164. package/src/init/files/src/app/general/home/+state/home.model.ts.template +0 -0
  165. package/src/init/files/src/app/general/home/+state/home.selectors.ts.template +0 -20
  166. package/src/init/files/src/app/general/home/+state/home.state.ts.template +0 -13
  167. package/src/init/files/src/app/general/home/home.component.html.template +0 -5
  168. package/src/init/files/src/app/general/home/home.component.ts.template +0 -88
  169. package/src/init/files/src/app/general/landing/+state/landing.actions.ts.template +0 -26
  170. package/src/init/files/src/app/general/landing/+state/landing.effects.ts.template +0 -48
  171. package/src/init/files/src/app/general/landing/+state/landing.model.ts.template +0 -0
  172. package/src/init/files/src/app/general/landing/+state/landing.selectors.ts.template +0 -20
  173. package/src/init/files/src/app/general/landing/+state/landing.state.ts.template +0 -13
  174. package/src/init/files/src/app/general/landing/landing.component.ts.template +0 -98
  175. package/src/init/files/src/app/general/login/login.component.html.template +0 -11
  176. package/src/init/files/src/app/general/login/login.component.ts.template +0 -80
  177. package/src/init/files/src/app/onboarding/consent/+state/consent.actions.ts.template +0 -23
  178. package/src/init/files/src/app/onboarding/consent/+state/consent.effects.ts.template +0 -47
  179. package/src/init/files/src/app/onboarding/consent/+state/consent.model.ts.template +0 -0
  180. package/src/init/files/src/app/onboarding/consent/+state/consent.selectors.ts.template +0 -20
  181. package/src/init/files/src/app/onboarding/consent/+state/consent.state.ts.template +0 -13
  182. package/src/init/files/src/app/onboarding/consent/consent.component.ts.template +0 -151
  183. package/src/init/files/src/app/onboarding/onboarding-routing.module.ts.template +0 -19
  184. package/src/init/files/src/app/onboarding/onboarding.module.spec.ts.template +0 -13
  185. package/src/init/files/src/app/onboarding/onboarding.module.ts.template +0 -32
  186. package/src/init/files/src/app/onboarding/waiting/+state/waiting.actions.ts.template +0 -26
  187. package/src/init/files/src/app/onboarding/waiting/+state/waiting.effects.ts.template +0 -52
  188. package/src/init/files/src/app/onboarding/waiting/+state/waiting.model.ts.template +0 -9
  189. package/src/init/files/src/app/onboarding/waiting/+state/waiting.selectors.ts.template +0 -42
  190. package/src/init/files/src/app/onboarding/waiting/+state/waiting.state.ts.template +0 -13
  191. package/src/init/files/src/app/onboarding/waiting/waiting.animations.ts.template +0 -4
  192. package/src/init/files/src/app/onboarding/waiting/waiting.component.html.template +0 -57
  193. package/src/init/files/src/app/onboarding/waiting/waiting.component.spec.ts.template +0 -25
  194. package/src/init/files/src/app/onboarding/waiting/waiting.component.ts.template +0 -281
  195. package/src/init/files/src/app/shared/components/redeployment-warning/redeployment-warning.component.html.template +0 -10
  196. package/src/init/files/src/app/shared/shared.module.ts.template +0 -87
  197. package/src/init/files/src/main.ts.template +0 -12
  198. package/src/module/files/__name@dasherize__/__name@dasherize__-routing.module.ts.template +0 -15
  199. package/src/module/files/__name@dasherize__/__name@dasherize__.module.spec.ts.template +0 -13
  200. package/src/module/files/__name@dasherize__/__name@dasherize__.module.ts.template +0 -24
  201. package/src/module/index.d.ts +0 -2
  202. package/src/module/index.js +0 -97
  203. package/src/module/index.js.map +0 -1
  204. package/src/module/index_spec.d.ts +0 -1
  205. package/src/module/index_spec.js +0 -23
  206. package/src/module/index_spec.js.map +0 -1
  207. package/src/module/schema.json +0 -38
  208. /package/src/init/files/src/app/{onboarding → first-time}/consent/consent.animations.ts.template +0 -0
  209. /package/src/init/files/src/app/{onboarding → first-time}/consent/consent.component.scss.template +0 -0
  210. /package/src/init/files/src/app/{onboarding → first-time}/consent/consent.component.spec.ts.template +0 -0
  211. /package/src/init/files/src/app/{general → first-time}/landing/landing.animations.ts.template +0 -0
  212. /package/src/init/files/src/app/{general → first-time}/landing/landing.component.scss.template +0 -0
  213. /package/src/init/files/src/app/{general → first-time}/landing/landing.component.spec.ts.template +0 -0
  214. /package/src/init/files/src/app/{general → first-time}/login/login.component.scss.template +0 -0
  215. /package/src/init/files/src/app/{general → first-time}/login/login.component.spec.ts.template +0 -0
  216. /package/src/init/files/src/app/{general → main}/home/home.animations.ts.template +0 -0
  217. /package/src/init/files/src/app/{general → main}/home/home.component.scss.template +0 -0
  218. /package/src/init/files/src/app/{general → main}/home/home.component.spec.ts.template +0 -0
  219. /package/src/init/files/src/app/shared/{components/redeployment-warning → redeployment-warning}/redeployment-warning.component.scss.template +0 -0
  220. /package/src/init/files/src/app/shared/{components/redeployment-warning → redeployment-warning}/redeployment-warning.component.spec.ts.template +0 -0
@@ -1,41 +0,0 @@
1
- import { Injectable } from '@angular/core';
2
- import { Action } from '@ngrx/store';
3
- import { Actions, createEffect, ofType } from '@ngrx/effects';
4
- import { of, Observable } from 'rxjs';
5
- import { tap, take } from 'rxjs/operators';
6
- import { SnackbarActionTypes, ShowSnackbar } from './snackbar.actions';
7
- import { MatSnackBar } from '@angular/material/snack-bar';
8
-
9
- @Injectable()
10
- export class SnackbarEffects {
11
-
12
- /** Process the snackbar action. */
13
- showSnackbar$: Observable<Action> = createEffect(
14
- () => this.actions$.pipe(
15
- ofType<ShowSnackbar>(SnackbarActionTypes.SHOW_MESSAGE),
16
- tap((action: ShowSnackbar) => {
17
-
18
- let snackBarRef;
19
- const config = action.payload.config;
20
-
21
- if (action.payload.component) {
22
- snackBarRef = this.snackBar.openFromComponent(action.payload.component, config);
23
- } else if (action.payload.message) {
24
- snackBarRef = this.snackBar.open(action.payload.message, action.payload.action || '', config);
25
- }
26
-
27
- if (action.payload.onAction) {
28
- snackBarRef.onAction().pipe(take(1)).subscribe(() => {
29
- action.payload.onAction(snackBarRef);
30
- snackBarRef.dismiss();
31
- });
32
- }
33
- }),
34
- ), { dispatch: false },
35
- );
36
-
37
- constructor(
38
- private actions$: Actions,
39
- private snackBar: MatSnackBar,
40
- ) {}
41
- }
@@ -1,249 +0,0 @@
1
- import { Action } from '@ngrx/store';
2
- import { LoadAction } from '../app.actions';
3
- import { AppState } from './app-state.model';
4
-
5
- export enum AppStateActionTypes {
6
- STREAM = '[AppState] stream appState',
7
- STREAM_SUCCESS = '[AppState] stream appState success',
8
- STREAM_FAIL = '[AppState] stream appState fail',
9
- LOAD = '[AppState] load appState',
10
- LOAD_SUCCESS = '[AppState] load appState success',
11
- LOAD_FAIL = '[AppState] load appState fail',
12
- ADD = '[AppState] add appState',
13
- ADD_SUCCESS = '[AppState] add appState success',
14
- ADD_FAIL = '[AppState] add appState fail',
15
- UPDATE = '[AppState] update appState',
16
- UPDATE_SUCCESS = '[AppState] update appState success',
17
- UPDATE_FAIL = '[AppState] update appState fail',
18
- REMOVE = '[AppState] remove appState',
19
- REMOVE_SUCCESS = '[AppState] remove appState success',
20
- REMOVE_FAIL = '[AppState] remove appState fail',
21
- LOADED = '[AppState] loaded',
22
- ADDED = '[AppState] added',
23
- MODIFIED = '[AppState] modified',
24
- REMOVED = '[AppState] removed',
25
- }
26
-
27
- // See Firebase Docs for current constraints on valid queries
28
- export class StreamAppState implements Action {
29
- readonly type = AppStateActionTypes.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?: (appState: AppState) => LoadAction[],
43
- ) {}
44
- }
45
-
46
- export class StreamAppStateSuccess implements Action {
47
- readonly type = AppStateActionTypes.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?: (appState: AppState) => LoadAction[],
60
- ) {}
61
- }
62
-
63
- export class StreamAppStateFail implements Action {
64
- readonly type = AppStateActionTypes.STREAM_FAIL;
65
- constructor(
66
- public error: any,
67
- public correlationId?: string,
68
- ) {}
69
- }
70
-
71
-
72
- export class LoadAppState implements Action {
73
- readonly type = AppStateActionTypes.LOAD;
74
- constructor(
75
- // property, comparator, value
76
- public queryParams: [string, string, any][],
77
- public queryOptions: {
78
- orderBy?: string | [string, string],
79
- limit?: number,
80
- startAt?: string,
81
- startAfter?: string,
82
- endAt?: string,
83
- endBefore?: string,
84
- },
85
- public correlationId: string,
86
- public followupActions?: (appState: AppState) => LoadAction[],
87
- ) {}
88
- }
89
-
90
- export class LoadAppStateSuccess implements Action {
91
- readonly type = AppStateActionTypes.LOAD_SUCCESS;
92
- constructor(
93
- public queryParams: [string, string, any][],
94
- public queryOptions: {
95
- orderBy?: string | [string, string],
96
- limit?: number,
97
- startAt?: string,
98
- startAfter?: string,
99
- endAt?: string,
100
- endBefore?: string,
101
- },
102
- public correlationId: string,
103
- public followupActions?: (appState: AppState) => LoadAction[],
104
- ) {}
105
- }
106
-
107
- export class LoadAppStateFail implements Action {
108
- readonly type = AppStateActionTypes.LOAD_FAIL;
109
- constructor(
110
- public error: any,
111
- public correlationId?: string,
112
- ) {}
113
- }
114
-
115
- export class AddAppState implements Action {
116
- readonly type = AppStateActionTypes.ADD;
117
- constructor(
118
- public appState: AppState,
119
- public correlationId?: string,
120
- public options?: {
121
- optimistic?: boolean,
122
- },
123
- ) {}
124
- }
125
-
126
- export class AddAppStateSuccess implements Action {
127
- readonly type = AppStateActionTypes.ADD_SUCCESS;
128
- constructor(
129
- public appState: AppState,
130
- public correlationId?: string,
131
- public options?: {
132
- optimistic?: boolean,
133
- },
134
- ) {}
135
- }
136
-
137
- export class AddAppStateFail implements Action {
138
- readonly type = AppStateActionTypes.ADD_FAIL;
139
- constructor(
140
- public error: any,
141
- public correlationId?: string,
142
- public options?: {
143
- optimistic?: boolean,
144
- },
145
- ) {}
146
- }
147
-
148
- export class UpdateAppState implements Action {
149
- readonly type = AppStateActionTypes.UPDATE;
150
- constructor(
151
- public __id: string,
152
- public changes: Partial<AppState>,
153
- public correlationId?: string,
154
- ) { }
155
- }
156
-
157
- export class UpdateAppStateSuccess implements Action {
158
- readonly type = AppStateActionTypes.UPDATE_SUCCESS;
159
- constructor(
160
- public __id: string,
161
- public changes: Partial<AppState>,
162
- public correlationId?: string,
163
- ) {}
164
- }
165
-
166
- export class UpdateAppStateFail implements Action {
167
- readonly type = AppStateActionTypes.UPDATE_FAIL;
168
- constructor(
169
- public error: any,
170
- public correlationId?: string,
171
- ) {}
172
- }
173
-
174
- export class RemoveAppState implements Action {
175
- readonly type = AppStateActionTypes.REMOVE;
176
- constructor(
177
- public __id: string,
178
- public correlationId?: string,
179
- ) { }
180
- }
181
-
182
- export class RemoveAppStateSuccess implements Action {
183
- readonly type = AppStateActionTypes.REMOVE_SUCCESS;
184
- constructor(
185
- public __id: string,
186
- public correlationId?: string,
187
- ) {}
188
- }
189
-
190
- export class RemoveAppStateFail implements Action {
191
- readonly type = AppStateActionTypes.REMOVE_FAIL;
192
- constructor(
193
- public error: any,
194
- public correlationId?: string,
195
- ) {}
196
- }
197
-
198
- export class LoadedAppState implements Action {
199
- readonly type = AppStateActionTypes.LOADED;
200
- constructor(
201
- public payload: AppState[],
202
- public correlationId?: string,
203
- ) {}
204
- }
205
-
206
- export class AddedAppState implements Action {
207
- readonly type = AppStateActionTypes.ADDED;
208
- constructor(
209
- public payload: AppState,
210
- public correlationId?: string,
211
- ) {}
212
- }
213
-
214
- export class ModifiedAppState implements Action {
215
- readonly type = AppStateActionTypes.MODIFIED;
216
- constructor(
217
- public payload: AppState,
218
- public correlationId?: string,
219
- ) {}
220
- }
221
-
222
- export class RemovedAppState implements Action {
223
- readonly type = AppStateActionTypes.REMOVED;
224
- constructor(
225
- public payload: AppState,
226
- public correlationId?: string,
227
- ) {}
228
- }
229
-
230
- export type AppStateActions =
231
- StreamAppState |
232
- StreamAppStateSuccess |
233
- StreamAppStateFail |
234
- LoadAppState |
235
- LoadAppStateSuccess |
236
- LoadAppStateFail |
237
- AddAppState |
238
- AddAppStateSuccess |
239
- AddAppStateFail |
240
- UpdateAppState |
241
- UpdateAppStateSuccess |
242
- UpdateAppStateFail |
243
- RemoveAppState |
244
- RemoveAppStateSuccess |
245
- RemoveAppStateFail |
246
- LoadedAppState |
247
- AddedAppState |
248
- ModifiedAppState |
249
- RemovedAppState;
@@ -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 { AppState } from './app-state.model';
10
- import { AppStateActionTypes, AppStateActions,
11
- AddedAppState, RemovedAppState,
12
- StreamAppState, StreamAppStateSuccess, StreamAppStateFail,
13
- LoadAppState, LoadAppStateSuccess, LoadAppStateFail,
14
- AddAppState, AddAppStateSuccess, AddAppStateFail,
15
- UpdateAppState, UpdateAppStateSuccess, UpdateAppStateFail,
16
- RemoveAppState, RemoveAppStateSuccess, RemoveAppStateFail } from './app-state.actions';
17
-
18
- @Injectable()
19
- export class AppStateEffects {
20
- /** Process the stream action to create firebase connections. */
21
- stream$: Observable<Action> = createEffect(
22
- () => this.actions$.pipe(
23
- ofType<StreamAppState>(AppStateActionTypes.STREAM),
24
- mergeMap((action: StreamAppState) => {
25
- const connection = this.clc.processLoadAction(action);
26
- return connection.loadStream.pipe(
27
- take(1),
28
- map(() => new StreamAppStateSuccess(action.queryParams, action.queryOptions, action.correlationId, action.followupActions)),
29
- catchError((error) => of(new StreamAppStateFail(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<LoadAppState>(AppStateActionTypes.LOAD),
39
- mergeMap((action: LoadAppState) => {
40
- const connection = this.clc.processLoadAction(action);
41
- return connection.loadStream.pipe(
42
- take(1),
43
- map(() => new LoadAppStateSuccess(action.queryParams, action.queryOptions, action.correlationId, action.followupActions)),
44
- catchError((error) => of(new LoadAppStateFail(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<AddAppState>(AppStateActionTypes.ADD),
54
- mergeMap((action: AddAppState) => {
55
- if (action.options && action.options.optimistic) {
56
- return merge(
57
- of(new AddedAppState(action.appState, action.correlationId)),
58
- this.db.addEntity('appStates', action.appState).pipe(
59
- mergeMap(() => merge(
60
- of(new AddAppStateSuccess(action.appState, action.correlationId)),
61
- this.actionsOnAdd(action),
62
- )),
63
- catchError((error) => merge(
64
- of(new AddAppStateFail(error, action.correlationId)),
65
- of(new RemovedAppState(action.appState, action.correlationId)),
66
- )),
67
- ),
68
- );
69
- } else {
70
- return this.db.addEntity('appStates', action.appState).pipe(
71
- mergeMap(() => merge(
72
- of(new AddAppStateSuccess(action.appState, action.correlationId)),
73
- this.actionsOnAdd(action),
74
- )),
75
- catchError((error) => of(new AddAppStateFail(error, action.correlationId))),
76
- );
77
- }
78
- }),
79
- ),
80
- );
81
-
82
- /** Process the update action to update database and initiate callbacks. */
83
- update$: Observable<Action> = createEffect(
84
- () => this.actions$.pipe(
85
- ofType<UpdateAppState>(AppStateActionTypes.UPDATE),
86
- mergeMap((action: UpdateAppState) => {
87
- return this.db.updateEntity('appStates', action.__id, action.changes).pipe(
88
- mergeMap(() => merge(
89
- of(new UpdateAppStateSuccess(action.__id, action.changes, action.correlationId)),
90
- this.actionsOnUpdate(action),
91
- )),
92
- catchError((error) => of(new UpdateAppStateFail(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<RemoveAppState>(AppStateActionTypes.REMOVE),
102
- mergeMap((action: RemoveAppState) => {
103
- return this.db.removeEntity('appStates', action.__id).pipe(
104
- mergeMap(() => merge(
105
- of(new RemoveAppStateSuccess(action.__id, action.correlationId)),
106
- this.actionsOnRemove(action),
107
- )),
108
- catchError((error) => of(new RemoveAppStateFail(error, action.correlationId))),
109
- );
110
- }),
111
- ),
112
- );
113
-
114
- actionsOnAdd(action: AddAppState): Observable<Action> {
115
- return EMPTY;
116
- }
117
-
118
- actionsOnUpdate(action: UpdateAppState): Observable<Action> {
119
- return EMPTY;
120
- }
121
-
122
- actionsOnRemove(action: RemoveAppState): Observable<Action> {
123
- return EMPTY;
124
- }
125
-
126
- constructor(
127
- private actions$: Actions,
128
- private db: FirebaseService,
129
- private clc: CachedLoadConnectionsService,
130
- ) {}
131
- }
@@ -1,8 +0,0 @@
1
- import { Timestamp } from '@angular/fire/firestore';
2
-
3
- export interface AppState {
4
- __id: string;
5
- _totalWaiting: number; // total number of people on the waitlist
6
- _createdAt?: Timestamp;
7
- _updatedAt?: Timestamp;
8
- }
@@ -1,13 +0,0 @@
1
- import { reducer, initialState } from './app-state.reducer';
2
-
3
- describe('AppState 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
- });
@@ -1,51 +0,0 @@
1
- import { EntityState, EntityAdapter, createEntityAdapter } from '@ngrx/entity';
2
- import { AppState } from './app-state.model';
3
- import { AppStateActions, AppStateActionTypes } from './app-state.actions';
4
- import { createFeatureSelector } from '@ngrx/store';
5
-
6
- export interface State extends EntityState<AppState> {
7
- // additional entities state properties
8
- }
9
-
10
- export const adapter: EntityAdapter<AppState> = createEntityAdapter<AppState>({
11
- selectId: (appState: AppState) => appState.__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: AppStateActions,
22
- ) {
23
- switch (action.type) {
24
- case AppStateActionTypes.ADDED:
25
- return adapter.upsertOne(action.payload, state);
26
-
27
- case AppStateActionTypes.LOADED:
28
- return adapter.upsertMany(action.payload, state);
29
-
30
- case AppStateActionTypes.MODIFIED:
31
- return adapter.updateOne({
32
- id: action.payload.__id,
33
- changes: action.payload,
34
- }, state);
35
-
36
- case AppStateActionTypes.REMOVED:
37
- return adapter.removeOne(action.payload.__id, state);
38
-
39
- default:
40
- return state;
41
- }
42
- }
43
-
44
- export const getAppStateState = createFeatureSelector<State>('appState');
45
-
46
- export const {
47
- selectIds,
48
- selectEntities,
49
- selectAll,
50
- selectTotal,
51
- } = adapter.getSelectors(getAppStateState);
@@ -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 { AppState } from './app-state.model';
6
-
7
- @Injectable({
8
- providedIn: 'root',
9
- })
10
- export class AppStateService {
11
- constructor(
12
- private cs: CachedSelectorsService,
13
- private db: FirebaseService,
14
- ) { }
15
-
16
- /** Select a appState from the store. */
17
- public selectAppState = <T extends AppState>(
18
- id: string,
19
- correlationId: string,
20
- childrenFn?: (e: AppState) => { [index: string]: Observable<any> },
21
- ): Observable<T> => {
22
- return this.cs.selectEntityObj<AppState, T>('appState', id, correlationId, childrenFn);
23
- };
24
-
25
- /** Select appStates from the store. */
26
- public selectAppStates = <T extends AppState>(
27
- queryParams: [string, string, any][],
28
- correlationId: string,
29
- childrenFn?: (e: AppState) => { [index: string]: Observable<any> },
30
- ): Observable<Array<T>> => {
31
- return this.cs.selectEntityList<AppState, T>('appState', queryParams, correlationId, childrenFn);
32
- };
33
-
34
- /** Get a appState directly from the database. */
35
- public getAppState = <T extends AppState>(
36
- id: string,
37
- childrenFn?: (e: AppState) => { [index: string]: Observable<any> },
38
- ): Observable<T> => {
39
- return this.db.queryObjOnce<AppState, T>('appStates', id, childrenFn);
40
- };
41
-
42
- /** Get appStates directly from the database. */
43
- public getAppStates = <T extends AppState>(
44
- queryParams: [string, string, any][],
45
- queryOptions?: { [index: string]: any },
46
- childrenFn?: (e: AppState) => { [index: string]: Observable<any> },
47
- ): Observable<Array<T>> => {
48
- return this.db.queryListOnce<AppState, T>('appStates', queryParams, queryOptions, childrenFn);
49
- };
50
- }
@@ -1,92 +0,0 @@
1
- import { Action } from '@ngrx/store';
2
- import { ObservableInput, Subject } from 'rxjs';
3
- import { NavigationExtras } from '@angular/router';
4
-
5
- export interface SAction extends Action {
6
- payload: { [index: string]: any; };
7
- correlationId?: string;
8
- }
9
-
10
- export interface LoadAction extends Action {
11
- queryParams: [string, string, any][];
12
- queryOptions: {
13
- orderBy?: string | [string, string],
14
- limit?: number,
15
- startAt?: string,
16
- startAfter?: string,
17
- endAt?: string,
18
- endBefore?: string,
19
- };
20
- correlationId: string;
21
- followupActions?: (entity: any) => LoadAction[];
22
- }
23
-
24
- export enum GeneralActionTypes {
25
- UNSUBSCRIBE = '[General] unsubscribe',
26
- ROUTER_NAVIGATE = '[Router] navigate',
27
- ACTION_FLOW = '[General] action flow',
28
- }
29
-
30
- export enum ActionSetResult {
31
- SUCCESS = 'success',
32
- FAILURE = 'failure',
33
- NONE = 'none', // was not tracked
34
- }
35
-
36
- export interface ActionSet {
37
- action: Action;
38
- responseActionTypes?: {
39
- success: string | string[];
40
- failure: string | string[];
41
- };
42
- // this can be used if you need to find a specific action set in the callback
43
- key?: string;
44
- callbacks?: {
45
- // Actions that should be dispatched if this one fails
46
- onFailure?: ObservableInput<Action>;
47
- // Action that should be dispatched if this one succeeds,
48
- // but some other Action in its actionSets batch fails
49
- onSuccessButOtherFailure?: ObservableInput<Action>;
50
- };
51
- }
52
-
53
- export interface ActionSetResponse extends ActionSet {
54
- result: ActionSetResult;
55
- responseAction: Action;
56
- }
57
-
58
- /**
59
- * An action that helps orchestrate a flow of actions
60
- * @param actionSets the group of actions to dispatch. Each set represents an action, the success action type, and the fail action type.
61
- * @param successActionFn a function executed if all actions are successful, and that returns an array of new actions to dispatch
62
- * @param failActionFn a function executed if any of the actions fail, and that returns an array of new actions to dispatch
63
- */
64
- export class ActionFlow implements Action {
65
- readonly type = GeneralActionTypes.ACTION_FLOW;
66
- constructor(public payload: {
67
- actionSets: ActionSet[],
68
- loading$?: Subject<boolean>,
69
- successActionFn?: (actionSetResponses: ActionSetResponse[]) => ObservableInput<Action>,
70
- failActionFn?: (actionSetResponses: ActionSetResponse[]) => ObservableInput<Action>,
71
- }) {}
72
- }
73
-
74
- export class Unsubscribe implements Action {
75
- readonly type = GeneralActionTypes.UNSUBSCRIBE;
76
- constructor(
77
- public correlationId?: string,
78
- ) {}
79
- }
80
-
81
- export class RouterNavigate implements Action {
82
- readonly type = GeneralActionTypes.ROUTER_NAVIGATE;
83
- constructor(
84
- public commands: any[],
85
- public extras?: NavigationExtras,
86
- ) {}
87
- }
88
-
89
- export type GeneralActions =
90
- Unsubscribe |
91
- ActionFlow |
92
- RouterNavigate;