@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.
Files changed (223) 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/.eslintrc.json.template +1 -1
  14. package/src/init/files/.firebaserc.template +8 -0
  15. package/src/init/files/.github/workflows/angular-github-ci.yml.template +1 -1
  16. package/src/init/files/README.md.template +13 -10
  17. package/src/init/files/angular.json.template +18 -11
  18. package/src/init/files/package.json.template +29 -30
  19. package/src/init/files/src/app/admin/{waitlist/waitlist.animations.ts.template → admin-panel/admin-panel.animations.ts.template} +1 -1
  20. package/src/init/files/src/app/admin/{waitlist/waitlist.component.html.template → admin-panel/admin-panel.component.html.template} +3 -3
  21. package/src/init/files/src/app/admin/{waitlist/waitlist.component.scss.template → admin-panel/admin-panel.component.scss.template} +1 -1
  22. package/src/init/files/src/app/admin/admin-panel/admin-panel.component.spec.ts.template +25 -0
  23. package/src/init/files/src/app/admin/admin-panel/admin-panel.component.ts.template +99 -0
  24. package/src/init/files/src/app/app.component.ts.template +12 -8
  25. package/src/init/files/src/app/app.config.ts.template +65 -0
  26. package/src/init/files/src/app/app.routes.ts.template +32 -0
  27. package/src/init/files/src/app/core/analytics/log.service.ts.template +122 -89
  28. package/src/init/files/src/app/core/analytics/time-analytics.service.ts.template +9 -17
  29. package/src/init/files/src/app/core/auth/auth.guard.ts.template +26 -23
  30. package/src/init/files/src/app/core/firebase/cached-listeners.service.ts.template +291 -0
  31. package/src/init/files/src/app/core/firebase/database.service.ts.template +56 -0
  32. package/src/init/files/src/app/core/firebase/firebase.mock.service.ts.template +276 -0
  33. package/src/init/files/src/app/core/firebase/firebase.service.ts.template +265 -215
  34. package/src/init/files/src/app/core/local-storage/session.service.ts.template +3 -4
  35. package/src/init/files/src/app/core/store/app.model.ts.template +19 -0
  36. package/src/init/files/src/app/core/store/app.store.ts.template +1074 -0
  37. package/src/init/files/src/app/core/store/auth/auth.mock.ts.template +20 -0
  38. package/src/init/files/src/app/core/store/auth/auth.store.ts.template +136 -0
  39. package/src/init/files/src/app/core/store/batch-write.firebase.service.ts.template +58 -0
  40. package/src/init/files/src/app/core/store/batch-write.mock.service.ts.template +105 -0
  41. package/src/init/files/src/app/core/store/batch-write.service.ts.template +126 -0
  42. package/src/init/files/src/app/core/store/user/user.mock.ts.template +24 -0
  43. package/src/init/files/src/app/core/store/user/user.model.ts.template +3 -6
  44. package/src/init/files/src/app/core/store/user/user.store.ts.template +41 -0
  45. package/src/init/files/src/app/core/store/user-context/user-context.mock.ts.template +24 -0
  46. package/src/init/files/src/app/core/store/user-context/user-context.model.ts.template +1 -0
  47. package/src/init/files/src/app/core/store/user-context/user-context.store.ts.template +41 -0
  48. package/src/init/files/src/app/core/utils/rand.utils.ts.template +13 -0
  49. package/src/init/files/src/app/{onboarding → first-time}/consent/consent.component.html.template +10 -14
  50. package/src/init/files/src/app/{onboarding → first-time}/consent/consent.component.scss.template +2 -2
  51. package/src/init/files/src/app/first-time/consent/consent.component.ts.template +95 -0
  52. package/src/init/files/src/app/first-time/early-access/early-access.animations.ts.template +4 -0
  53. package/src/init/files/src/app/first-time/early-access/early-access.component.html.template +65 -0
  54. package/src/init/files/src/app/{onboarding/waiting/waiting.component.scss.template → first-time/early-access/early-access.component.scss.template} +10 -3
  55. package/src/init/files/src/app/first-time/early-access/early-access.component.spec.ts.template +25 -0
  56. package/src/init/files/src/app/first-time/early-access/early-access.component.ts.template +254 -0
  57. package/src/init/files/src/app/first-time/early-access/early-access.model.ts.template +7 -0
  58. package/src/init/files/src/app/{general → first-time}/landing/landing.component.html.template +1 -1
  59. package/src/init/files/src/app/first-time/landing/landing.component.ts.template +44 -0
  60. package/src/init/files/src/app/first-time/login/login.component.html.template +10 -0
  61. package/src/init/files/src/app/first-time/login/login.component.ts.template +45 -0
  62. package/src/init/files/src/app/first-time/onboarding/onboarding.animations.ts.template +4 -0
  63. package/src/init/files/src/app/first-time/onboarding/onboarding.component.html.template +2 -0
  64. package/src/init/files/src/app/first-time/onboarding/onboarding.component.scss.template +5 -0
  65. package/src/init/files/src/app/{admin/waitlist/waitlist.component.spec.ts.template → first-time/onboarding/onboarding.component.spec.ts.template} +6 -6
  66. package/src/init/files/src/app/first-time/onboarding/onboarding.component.ts.template +41 -0
  67. package/src/init/files/src/app/main/home/home.component.html.template +6 -0
  68. package/src/init/files/src/app/{general → main}/home/home.component.scss.template +1 -0
  69. package/src/init/files/src/app/main/home/home.component.ts.template +55 -0
  70. package/src/init/files/src/app/shared/navbar/navbar.component.html.template +15 -0
  71. package/src/init/files/src/app/shared/navbar/navbar.component.scss.template +41 -0
  72. package/src/init/files/src/app/shared/navbar/navbar.component.spec.ts.template +25 -0
  73. package/src/init/files/src/app/shared/navbar/navbar.component.ts.template +40 -0
  74. package/src/init/files/src/app/shared/redeployment-warning/redeployment-warning.component.html.template +9 -0
  75. package/src/init/files/src/app/shared/{components/redeployment-warning → redeployment-warning}/redeployment-warning.component.ts.template +17 -6
  76. package/src/init/files/src/app/shared/{components/redeployment-warning → redeployment-warning}/redeployment-warning.service.ts.template +2 -2
  77. package/src/init/files/src/assets/images/close-x.svg +3 -0
  78. package/src/init/files/src/environments/environment.prod.ts.template +6 -2
  79. package/src/init/files/src/environments/environment.ts.template +4 -2
  80. package/src/init/files/src/index.html.template +1 -1
  81. package/src/init/files/src/styles.scss.template +4 -0
  82. package/src/init/files/tsconfig.json.template +0 -1
  83. package/src/container/files/__name@dasherize__/+state/__name@dasherize__.actions.ts.template +0 -26
  84. package/src/container/files/__name@dasherize__/+state/__name@dasherize__.effects.ts.template +0 -48
  85. package/src/container/files/__name@dasherize__/+state/__name@dasherize__.model.ts.template +0 -0
  86. package/src/container/files/__name@dasherize__/+state/__name@dasherize__.selectors.ts.template +0 -20
  87. package/src/container/files/__name@dasherize__/+state/__name@dasherize__.state.ts.template +0 -13
  88. package/src/container/files/__name@dasherize__/__name@dasherize__.animations.ts.template +0 -4
  89. package/src/container/files/__name@dasherize__/__name@dasherize__.component.html.template +0 -3
  90. package/src/container/files/__name@dasherize__/__name@dasherize__.component.scss.template +0 -5
  91. package/src/container/files/__name@dasherize__/__name@dasherize__.component.spec.ts.template +0 -25
  92. package/src/container/files/__name@dasherize__/__name@dasherize__.component.ts.template +0 -90
  93. package/src/container/index.d.ts +0 -2
  94. package/src/container/index.js +0 -127
  95. package/src/container/index.js.map +0 -1
  96. package/src/container/index_spec.d.ts +0 -1
  97. package/src/container/index_spec.js +0 -23
  98. package/src/container/index_spec.js.map +0 -1
  99. package/src/container/schema.json +0 -50
  100. package/src/entity/files/__name@dasherize__/__name@dasherize__.actions.ts.template +0 -249
  101. package/src/entity/files/__name@dasherize__/__name@dasherize__.effects.ts.template +0 -131
  102. package/src/entity/files/__name@dasherize__/__name@dasherize__.reducer.spec.ts.template +0 -13
  103. package/src/entity/files/__name@dasherize__/__name@dasherize__.reducer.ts.template +0 -51
  104. package/src/entity/files/__name@dasherize__/__name@dasherize__.service.ts.template +0 -50
  105. package/src/entity-in-example/files/__name@dasherize__/__name@dasherize__.actions.ts.template +0 -270
  106. package/src/entity-in-example/files/__name@dasherize__/__name@dasherize__.effects.ts.template +0 -131
  107. package/src/entity-in-example/files/__name@dasherize__/__name@dasherize__.model.ts.template +0 -3
  108. package/src/entity-in-example/files/__name@dasherize__/__name@dasherize__.reducer.spec.ts.template +0 -13
  109. package/src/entity-in-example/files/__name@dasherize__/__name@dasherize__.reducer.ts.template +0 -51
  110. package/src/entity-in-example/files/__name@dasherize__/__name@dasherize__.service.ts.template +0 -50
  111. package/src/entity-in-example/index.d.ts +0 -2
  112. package/src/entity-in-example/index.js +0 -141
  113. package/src/entity-in-example/index.js.map +0 -1
  114. package/src/entity-in-example/index_spec.d.ts +0 -1
  115. package/src/entity-in-example/index_spec.js +0 -23
  116. package/src/entity-in-example/index_spec.js.map +0 -1
  117. package/src/entity-in-example/schema.json +0 -45
  118. package/src/init/files/CHANGELOG.md.template +0 -10
  119. package/src/init/files/src/app/admin/admin-routing.module.ts.template +0 -17
  120. package/src/init/files/src/app/admin/admin.module.spec.ts.template +0 -13
  121. package/src/init/files/src/app/admin/admin.module.ts.template +0 -28
  122. package/src/init/files/src/app/admin/waitlist/+state/waitlist.actions.ts.template +0 -23
  123. package/src/init/files/src/app/admin/waitlist/+state/waitlist.effects.ts.template +0 -50
  124. package/src/init/files/src/app/admin/waitlist/+state/waitlist.model.ts.template +0 -0
  125. package/src/init/files/src/app/admin/waitlist/+state/waitlist.selectors.ts.template +0 -39
  126. package/src/init/files/src/app/admin/waitlist/+state/waitlist.state.ts.template +0 -13
  127. package/src/init/files/src/app/admin/waitlist/waitlist.component.ts.template +0 -141
  128. package/src/init/files/src/app/app-routing.module.ts.template +0 -26
  129. package/src/init/files/src/app/app.module.ts.template +0 -34
  130. package/src/init/files/src/app/core/core.module.ts.template +0 -75
  131. package/src/init/files/src/app/core/setup/firebase-setup.ts.template +0 -25
  132. package/src/init/files/src/app/core/setup/module-import-guard.ts.template +0 -5
  133. package/src/init/files/src/app/core/snackbar/snackbar.actions.ts.template +0 -24
  134. package/src/init/files/src/app/core/snackbar/snackbar.effects.ts.template +0 -41
  135. package/src/init/files/src/app/core/store/app-state/app-state.actions.ts.template +0 -249
  136. package/src/init/files/src/app/core/store/app-state/app-state.effects.ts.template +0 -131
  137. package/src/init/files/src/app/core/store/app-state/app-state.model.ts.template +0 -8
  138. package/src/init/files/src/app/core/store/app-state/app-state.reducer.spec.ts.template +0 -13
  139. package/src/init/files/src/app/core/store/app-state/app-state.reducer.ts.template +0 -51
  140. package/src/init/files/src/app/core/store/app-state/app-state.service.ts.template +0 -50
  141. package/src/init/files/src/app/core/store/app.actions.ts.template +0 -92
  142. package/src/init/files/src/app/core/store/app.effects.ts.template +0 -175
  143. package/src/init/files/src/app/core/store/app.reducer.ts.template +0 -36
  144. package/src/init/files/src/app/core/store/app.selectors.ts.template +0 -42
  145. package/src/init/files/src/app/core/store/auth/auth.actions.ts.template +0 -77
  146. package/src/init/files/src/app/core/store/auth/auth.effects.ts.template +0 -163
  147. package/src/init/files/src/app/core/store/auth/auth.reducer.spec.ts.template +0 -13
  148. package/src/init/files/src/app/core/store/auth/auth.reducer.ts.template +0 -26
  149. package/src/init/files/src/app/core/store/auth/auth.selectors.ts.template +0 -25
  150. package/src/init/files/src/app/core/store/cached-load-connections.service.ts.template +0 -405
  151. package/src/init/files/src/app/core/store/cached-selectors.service.ts.template +0 -376
  152. package/src/init/files/src/app/core/store/effects.helpers.ts.template +0 -66
  153. package/src/init/files/src/app/core/store/user/user.actions.ts.template +0 -248
  154. package/src/init/files/src/app/core/store/user/user.effects.ts.template +0 -148
  155. package/src/init/files/src/app/core/store/user/user.reducer.spec.ts.template +0 -13
  156. package/src/init/files/src/app/core/store/user/user.reducer.ts.template +0 -50
  157. package/src/init/files/src/app/core/store/user/user.service.ts.template +0 -50
  158. package/src/init/files/src/app/core/store/user-context/user-context.actions.ts.template +0 -248
  159. package/src/init/files/src/app/core/store/user-context/user-context.effects.ts.template +0 -131
  160. package/src/init/files/src/app/core/store/user-context/user-context.reducer.spec.ts.template +0 -13
  161. package/src/init/files/src/app/core/store/user-context/user-context.reducer.ts.template +0 -51
  162. package/src/init/files/src/app/core/store/user-context/user-context.service.ts.template +0 -50
  163. package/src/init/files/src/app/core/utils/string-case.utils.ts.template +0 -96
  164. package/src/init/files/src/app/general/general-routing.module.ts.template +0 -25
  165. package/src/init/files/src/app/general/general.module.spec.ts.template +0 -13
  166. package/src/init/files/src/app/general/general.module.ts.template +0 -36
  167. package/src/init/files/src/app/general/home/+state/home.actions.ts.template +0 -26
  168. package/src/init/files/src/app/general/home/+state/home.effects.ts.template +0 -48
  169. package/src/init/files/src/app/general/home/+state/home.model.ts.template +0 -0
  170. package/src/init/files/src/app/general/home/+state/home.selectors.ts.template +0 -20
  171. package/src/init/files/src/app/general/home/+state/home.state.ts.template +0 -13
  172. package/src/init/files/src/app/general/home/home.component.html.template +0 -5
  173. package/src/init/files/src/app/general/home/home.component.ts.template +0 -88
  174. package/src/init/files/src/app/general/landing/+state/landing.actions.ts.template +0 -26
  175. package/src/init/files/src/app/general/landing/+state/landing.effects.ts.template +0 -48
  176. package/src/init/files/src/app/general/landing/+state/landing.model.ts.template +0 -0
  177. package/src/init/files/src/app/general/landing/+state/landing.selectors.ts.template +0 -20
  178. package/src/init/files/src/app/general/landing/+state/landing.state.ts.template +0 -13
  179. package/src/init/files/src/app/general/landing/landing.component.ts.template +0 -98
  180. package/src/init/files/src/app/general/login/login.component.html.template +0 -11
  181. package/src/init/files/src/app/general/login/login.component.ts.template +0 -80
  182. package/src/init/files/src/app/onboarding/consent/+state/consent.actions.ts.template +0 -23
  183. package/src/init/files/src/app/onboarding/consent/+state/consent.effects.ts.template +0 -47
  184. package/src/init/files/src/app/onboarding/consent/+state/consent.model.ts.template +0 -0
  185. package/src/init/files/src/app/onboarding/consent/+state/consent.selectors.ts.template +0 -20
  186. package/src/init/files/src/app/onboarding/consent/+state/consent.state.ts.template +0 -13
  187. package/src/init/files/src/app/onboarding/consent/consent.component.ts.template +0 -151
  188. package/src/init/files/src/app/onboarding/onboarding-routing.module.ts.template +0 -19
  189. package/src/init/files/src/app/onboarding/onboarding.module.spec.ts.template +0 -13
  190. package/src/init/files/src/app/onboarding/onboarding.module.ts.template +0 -32
  191. package/src/init/files/src/app/onboarding/waiting/+state/waiting.actions.ts.template +0 -26
  192. package/src/init/files/src/app/onboarding/waiting/+state/waiting.effects.ts.template +0 -52
  193. package/src/init/files/src/app/onboarding/waiting/+state/waiting.model.ts.template +0 -9
  194. package/src/init/files/src/app/onboarding/waiting/+state/waiting.selectors.ts.template +0 -42
  195. package/src/init/files/src/app/onboarding/waiting/+state/waiting.state.ts.template +0 -13
  196. package/src/init/files/src/app/onboarding/waiting/waiting.animations.ts.template +0 -4
  197. package/src/init/files/src/app/onboarding/waiting/waiting.component.html.template +0 -57
  198. package/src/init/files/src/app/onboarding/waiting/waiting.component.spec.ts.template +0 -25
  199. package/src/init/files/src/app/onboarding/waiting/waiting.component.ts.template +0 -281
  200. package/src/init/files/src/app/shared/components/redeployment-warning/redeployment-warning.component.html.template +0 -10
  201. package/src/init/files/src/app/shared/shared.module.ts.template +0 -87
  202. package/src/init/files/src/main.ts.template +0 -12
  203. package/src/module/files/__name@dasherize__/__name@dasherize__-routing.module.ts.template +0 -15
  204. package/src/module/files/__name@dasherize__/__name@dasherize__.module.spec.ts.template +0 -13
  205. package/src/module/files/__name@dasherize__/__name@dasherize__.module.ts.template +0 -24
  206. package/src/module/index.d.ts +0 -2
  207. package/src/module/index.js +0 -97
  208. package/src/module/index.js.map +0 -1
  209. package/src/module/index_spec.d.ts +0 -1
  210. package/src/module/index_spec.js +0 -23
  211. package/src/module/index_spec.js.map +0 -1
  212. package/src/module/schema.json +0 -38
  213. /package/src/init/files/src/app/{onboarding → first-time}/consent/consent.animations.ts.template +0 -0
  214. /package/src/init/files/src/app/{onboarding → first-time}/consent/consent.component.spec.ts.template +0 -0
  215. /package/src/init/files/src/app/{general → first-time}/landing/landing.animations.ts.template +0 -0
  216. /package/src/init/files/src/app/{general → first-time}/landing/landing.component.scss.template +0 -0
  217. /package/src/init/files/src/app/{general → first-time}/landing/landing.component.spec.ts.template +0 -0
  218. /package/src/init/files/src/app/{general → first-time}/login/login.component.scss.template +0 -0
  219. /package/src/init/files/src/app/{general → first-time}/login/login.component.spec.ts.template +0 -0
  220. /package/src/init/files/src/app/{general → main}/home/home.animations.ts.template +0 -0
  221. /package/src/init/files/src/app/{general → main}/home/home.component.spec.ts.template +0 -0
  222. /package/src/init/files/src/app/shared/{components/redeployment-warning → redeployment-warning}/redeployment-warning.component.scss.template +0 -0
  223. /package/src/init/files/src/app/shared/{components/redeployment-warning → redeployment-warning}/redeployment-warning.component.spec.ts.template +0 -0
@@ -1,127 +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.container = 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 validation_1 = require("@schematics/angular/utility/validation");
18
- const workspace_1 = require("@schematics/angular/utility/workspace");
19
- const core_1 = require("@angular-devkit/core");
20
- const statements_adder_1 = require("../shared/statements-adder");
21
- function addInserts(options) {
22
- return (host, context) => {
23
- if (!options.module) {
24
- return host;
25
- }
26
- const classifiedName = core_1.strings.classify(options.name);
27
- const dasherizedName = core_1.strings.dasherize(options.name);
28
- const containerPath = `/${options.path}/` +
29
- core_1.strings.dasherize(options.name) + '/' +
30
- core_1.strings.dasherize(options.name) + '.component';
31
- // Add to module
32
- const modulePath = options.module;
33
- const moduleText = (0, statements_adder_1.getSourceText)(host, modulePath);
34
- const moduleToContainerPath = (0, find_module_1.buildRelativePath)(modulePath, containerPath);
35
- const effectsPath = `/${options.path}/` +
36
- core_1.strings.dasherize(options.name) + '/+state/' +
37
- core_1.strings.dasherize(options.name) + '.effects';
38
- const moduleToEffectsPath = (0, find_module_1.buildRelativePath)(modulePath, effectsPath);
39
- let insertChangesInModule = (0, statements_adder_1.simpleInsert)(moduleText, modulePath, [
40
- '// Containers',
41
- 'EffectsModule.forFeature([',
42
- '// Containers'
43
- ], [
44
- `import { ${classifiedName}Component } from '${moduleToContainerPath}';\nimport { ${classifiedName}Effects } from '${moduleToEffectsPath}';`,
45
- ` ${classifiedName}Effects,`,
46
- ` ${classifiedName}Component,`
47
- ]);
48
- // Add routing module changes
49
- context.logger.info(modulePath);
50
- const moduleDir = (0, core_1.normalize)(modulePath).split('/').slice(0, -1).join('/');
51
- const moduleFileName = (0, core_1.normalize)(modulePath).split('/').pop() || '';
52
- const moduleName = moduleFileName.split('.')[0];
53
- const moduleRoutingPath = `${moduleDir}/${moduleName}-routing.module.ts`;
54
- context.logger.info(moduleRoutingPath);
55
- const moduleRoutingText = (0, statements_adder_1.getSourceText)(host, moduleRoutingPath);
56
- const moduleRoutingToContainerPath = (0, find_module_1.buildRelativePath)(moduleRoutingPath, containerPath);
57
- context.logger.info("moduleRoutingPath: " + moduleRoutingPath);
58
- let insertChangesInRoutingModule = (0, statements_adder_1.simpleInsert)(moduleRoutingText, moduleRoutingPath, [
59
- '// Containers',
60
- 'const routes: Routes = ['
61
- ], [
62
- `import { ${classifiedName}Component } from '${moduleRoutingToContainerPath}';`,
63
- ` { path: '${dasherizedName}', component: ${classifiedName}Component, canActivate: [AuthGuard] },`
64
- ]);
65
- context.logger.info(`about to start committing`);
66
- // For each of the files and corresponding set of changes, commit to the tree
67
- [
68
- [modulePath, insertChangesInModule],
69
- [moduleRoutingPath, insertChangesInRoutingModule],
70
- ].map(([filePath, insertChanges]) => {
71
- const declarationRecorder = host.beginUpdate(filePath);
72
- for (const change of insertChanges) {
73
- if (change instanceof change_1.InsertChange) {
74
- declarationRecorder.insertLeft(change.pos, change.toAdd);
75
- }
76
- }
77
- host.commitUpdate(declarationRecorder);
78
- });
79
- return host;
80
- };
81
- }
82
- function container(options) {
83
- return (tree, context) => __awaiter(this, void 0, void 0, function* () {
84
- // Make sure the command is executed in the directory where the container should be generated
85
- if (!options.inDirectory) {
86
- context.logger.info("Please navigate to the directory where you want to generate the container.");
87
- return (0, schematics_1.noop)();
88
- }
89
- const workspace = yield (0, workspace_1.getWorkspace)(tree);
90
- const project = workspace.projects.get(options.project);
91
- if (!project) {
92
- throw new schematics_1.SchematicsException(`Project "${options.project}" does not exist.`);
93
- }
94
- context.logger.info(`options.path: ${options.path}`);
95
- if (options.path === undefined) {
96
- options.path = (0, workspace_1.buildDefaultPath)(project);
97
- }
98
- context.logger.info(`options.path: ${options.path}`);
99
- options.module = (0, find_module_1.findModuleFromOptions)(tree, options);
100
- context.logger.info(`options.module: ${options.module}`);
101
- const parsedPath = (0, parse_name_1.parseName)(options.path, options.name);
102
- options.name = parsedPath.name;
103
- options.path = parsedPath.path;
104
- (0, validation_1.validateHtmlSelector)(options.selector);
105
- // Define relative path parameters
106
- const containerPath = `/${options.path}/` +
107
- core_1.strings.dasherize(options.name) + '/' +
108
- core_1.strings.dasherize(options.name) + '.component';
109
- const moduleDir = (0, core_1.normalize)(options.module).split('/').slice(0, -1).join('/');
110
- context.logger.info(`moduleDir: ${moduleDir}`);
111
- const moduleToContainerPath = (0, find_module_1.buildRelativePath)(options.module, containerPath);
112
- context.logger.info(`moduleToContainer: ${moduleToContainerPath}`);
113
- // This is just a hacky way of figuring how many ../ we need to get to core
114
- const containerToCorePath = moduleToContainerPath.split('/')
115
- .slice(0, -1).map(() => '..').join('/') + '/core';
116
- const templateSource = (0, schematics_1.apply)((0, schematics_1.url)('./files'), [
117
- (0, schematics_1.applyTemplates)(Object.assign(Object.assign(Object.assign({}, core_1.strings), options), { containerToCorePath })),
118
- (0, schematics_1.move)(parsedPath.path),
119
- ]);
120
- return (0, schematics_1.chain)([
121
- addInserts(options),
122
- (0, schematics_1.mergeWith)(templateSource)
123
- ]);
124
- });
125
- }
126
- exports.container = container;
127
- //# sourceMappingURL=index.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["index.ts"],"names":[],"mappings":";;;;;;;;;;;;AAAA,2DAIoC;AACpC,+DAA0E;AAC1E,yEAAmG;AACnG,uEAAmE;AACnE,uEAA8E;AAC9E,qEAAuF;AAEvF,+CAAyD;AAEzD,iEAAyE;AAEzE,SAAS,UAAU,CAAC,OAAY;IAC9B,OAAO,CAAC,IAAU,EAAE,OAAyB,EAAE,EAAE;QAC/C,IAAI,CAAC,OAAO,CAAC,MAAM,EAAE;YACnB,OAAO,IAAI,CAAC;SACb;QAED,MAAM,cAAc,GAAG,cAAO,CAAC,QAAQ,CAAC,OAAO,CAAC,IAAI,CAAC,CAAC;QACtD,MAAM,cAAc,GAAG,cAAO,CAAC,SAAS,CAAC,OAAO,CAAC,IAAI,CAAC,CAAC;QACvD,MAAM,aAAa,GACjB,IAAI,OAAO,CAAC,IAAI,GAAG;YACnB,cAAO,CAAC,SAAS,CAAC,OAAO,CAAC,IAAI,CAAC,GAAG,GAAG;YACrC,cAAO,CAAC,SAAS,CAAC,OAAO,CAAC,IAAI,CAAC,GAAG,YAAY,CAAC;QAEjD,gBAAgB;QAChB,MAAM,UAAU,GAAG,OAAO,CAAC,MAAM,CAAC;QAClC,MAAM,UAAU,GAAG,IAAA,gCAAa,EAAC,IAAI,EAAE,UAAU,CAAC,CAAC;QACnD,MAAM,qBAAqB,GAAG,IAAA,+BAAiB,EAAC,UAAU,EAAE,aAAa,CAAC,CAAC;QAE3E,MAAM,WAAW,GACf,IAAI,OAAO,CAAC,IAAI,GAAG;YACnB,cAAO,CAAC,SAAS,CAAC,OAAO,CAAC,IAAI,CAAC,GAAG,UAAU;YAC5C,cAAO,CAAC,SAAS,CAAC,OAAO,CAAC,IAAI,CAAC,GAAG,UAAU,CAAC;QAC/C,MAAM,mBAAmB,GAA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AAiB,EAAC,OAAO,CAAC,MAAM,EAAE,aAAa,CAAC,CAAC;QAC/E,OAAO,CAAC,MAAM,CAAC,IAAI,CAAC,sBAAsB,qBAAqB,EAAE,CAAC,CAAC;QACnE,2EAA2E;QAC3E,MAAM,mBAAmB,GAAG,qBAAqB,CAAC,KAAK,CAAC,GAAG,CAAC;aACzD,KAAK,CAAC,CAAC,EAAC,CAAC,CAAC,CAAC,CAAC,GAAG,CAAC,GAAG,EAAE,CAAC,IAAI,CAAC,CAAC,IAAI,CAAC,GAAG,CAAC,GAAG,OAAO,CAAC;QAEnD,MAAM,cAAc,GAAG,IAAA,kBAAK,EAAC,IAAA,gBAAG,EAAC,SAAS,CAAC,EAAE;YAC3C,IAAA,2BAAc,gDACT,cAAO,GACP,OAAO,KACV,mBAAmB,IACnB;YACF,IAAA,iBAAI,EAAC,UAAU,CAAC,IAAI,CAAC;SACtB,CAAC,CAAC;QAEH,OAAO,IAAA,kBAAK,EAAC;YACX,UAAU,CAAC,OAAO,CAAC;YACnB,IAAA,sBAAS,EAAC,cAAc,CAAC;SAC1B,CAAC,CAAC;IACL,CAAC,CAAA,CAAC;AACJ,CAAC;AA7DD,8BA6DC"}
@@ -1 +0,0 @@
1
- export {};
@@ -1,23 +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
- const schematics_1 = require("@angular-devkit/schematics");
13
- const testing_1 = require("@angular-devkit/schematics/testing");
14
- const path = require("path");
15
- const collectionPath = path.join(__dirname, '../collection.json');
16
- describe('container', () => {
17
- it('works', () => __awaiter(void 0, void 0, void 0, function* () {
18
- const runner = new testing_1.SchematicTestRunner('schematics', collectionPath);
19
- const tree = yield runner.runSchematic('container', {}, schematics_1.Tree.empty());
20
- expect(tree.files).toEqual([]);
21
- }));
22
- });
23
- //# sourceMappingURL=index_spec.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"index_spec.js","sourceRoot":"","sources":["index_spec.ts"],"names":[],"mappings":";;;;;;;;;;;AAAA,2DAAkD;AAClD,gEAAyE;AACzE,6BAA6B;AAG7B,MAAM,cAAc,GAAG,IAAI,CAAC,IAAI,CAAC,SAAS,EAAE,oBAAoB,CAAC,CAAC;AAGlE,QAAQ,CAAC,WAAW,EAAE,GAAG,EAAE;IACzB,EAAE,CAAC,OAAO,EAAE,GAAS,EAAE;QACrB,MAAM,MAAM,GAAG,IAAI,6BAAmB,CAAC,YAAY,EAAE,cAAc,CAAC,CAAC;QACrE,MAAM,IAAI,GAAG,MAAM,MAAM,CAAC,YAAY,CAAC,WAAW,EAAE,EAAE,EAAE,iBAAI,CAAC,KAAK,EAAE,CAAC,CAAC;QAEtE,MAAM,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC,OAAO,CAAC,EAAE,CAAC,CAAC;IACjC,CAAC,CAAA,CAAC,CAAC;AACL,CAAC,CAAC,CAAC"}
@@ -1,50 +0,0 @@
1
- {
2
- "$schema": "http://json-schema.org/schema",
3
- "$id": "ContainerSchema",
4
- "title": "Container Schema",
5
- "type": "object",
6
- "description": "Creates a new container in the default project.",
7
- "properties": {
8
- "index": {
9
- "type": "number",
10
- "default": 1
11
- },
12
- "path": {
13
- "type": "string",
14
- "format": "path",
15
- "description": "The path at which to create the container file, relative to the current workspace. Should be organized according to the view hierarchy to the extent possible.",
16
- "visible": false,
17
- "$default": {
18
- "$source": "workingDirectory"
19
- }
20
- },
21
- "project": {
22
- "type": "string",
23
- "description": "The name of the project.",
24
- "$default": {
25
- "$source": "projectName"
26
- }
27
- },
28
- "name": {
29
- "type": "string",
30
- "description": "The name of the container.",
31
- "$default": {
32
- "$source": "argv",
33
- "index": 0
34
- },
35
- "x-prompt": "What name would you like to use for the container?"
36
- },
37
- "module": {
38
- "type": "string",
39
- "description": "The declaring NgModule.",
40
- "alias": "m"
41
- },
42
- "inDirectory": {
43
- "type": "boolean",
44
- "x-prompt": "Are you currently in the directory where you want to generate the container? (please organize your container according to the view hierarchy to the extent possible)"
45
- }
46
- },
47
- "required": [
48
- "name"
49
- ]
50
- }
@@ -1,249 +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
- REMOVE = '[<%= classify(name) %>] remove <%= camelize(name) %>',
19
- REMOVE_SUCCESS = '[<%= classify(name) %>] remove <%= camelize(name) %> success',
20
- REMOVE_FAIL = '[<%= classify(name) %>] remove <%= camelize(name) %> fail',
21
- LOADED = '[<%= classify(name) %>] loaded',
22
- ADDED = '[<%= classify(name) %>] added',
23
- MODIFIED = '[<%= classify(name) %>] modified',
24
- REMOVED = '[<%= classify(name) %>] removed',
25
- }
26
-
27
- // See Firebase Docs for current constraints on valid queries
28
- export class Stream<%= classify(name) %> implements Action {
29
- readonly type = <%= classify(name) %>ActionTypes.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?: (<%= camelize(name) %>: <%= classify(name) %>) => LoadAction[],
43
- ) {}
44
- }
45
-
46
- export class Stream<%= classify(name) %>Success implements Action {
47
- readonly type = <%= classify(name) %>ActionTypes.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?: (<%= camelize(name) %>: <%= classify(name) %>) => LoadAction[],
60
- ) {}
61
- }
62
-
63
- export class Stream<%= classify(name) %>Fail implements Action {
64
- readonly type = <%= classify(name) %>ActionTypes.STREAM_FAIL;
65
- constructor(
66
- public error: any,
67
- public correlationId?: string,
68
- ) {}
69
- }
70
-
71
-
72
- export class Load<%= classify(name) %> implements Action {
73
- readonly type = <%= classify(name) %>ActionTypes.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?: (<%= camelize(name) %>: <%= classify(name) %>) => LoadAction[],
87
- ) {}
88
- }
89
-
90
- export class Load<%= classify(name) %>Success implements Action {
91
- readonly type = <%= classify(name) %>ActionTypes.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?: (<%= camelize(name) %>: <%= classify(name) %>) => LoadAction[],
104
- ) {}
105
- }
106
-
107
- export class Load<%= classify(name) %>Fail implements Action {
108
- readonly type = <%= classify(name) %>ActionTypes.LOAD_FAIL;
109
- constructor(
110
- public error: any,
111
- public correlationId?: string,
112
- ) {}
113
- }
114
-
115
- export class Add<%= classify(name) %> implements Action {
116
- readonly type = <%= classify(name) %>ActionTypes.ADD;
117
- constructor(
118
- public <%= camelize(name) %>: <%= classify(name) %>,
119
- public correlationId?: string,
120
- public options?: {
121
- optimistic?: boolean,
122
- },
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
- public options?: {
132
- optimistic?: boolean,
133
- },
134
- ) {}
135
- }
136
-
137
- export class Add<%= classify(name) %>Fail implements Action {
138
- readonly type = <%= classify(name) %>ActionTypes.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 Update<%= classify(name) %> implements Action {
149
- readonly type = <%= classify(name) %>ActionTypes.UPDATE;
150
- constructor(
151
- public __id: string,
152
- public changes: Partial<<%= classify(name) %>>,
153
- public correlationId?: string,
154
- ) { }
155
- }
156
-
157
- export class Update<%= classify(name) %>Success implements Action {
158
- readonly type = <%= classify(name) %>ActionTypes.UPDATE_SUCCESS;
159
- constructor(
160
- public __id: string,
161
- public changes: Partial<<%= classify(name) %>>,
162
- public correlationId?: string,
163
- ) {}
164
- }
165
-
166
- export class Update<%= classify(name) %>Fail implements Action {
167
- readonly type = <%= classify(name) %>ActionTypes.UPDATE_FAIL;
168
- constructor(
169
- public error: any,
170
- public correlationId?: string,
171
- ) {}
172
- }
173
-
174
- export class Remove<%= classify(name) %> implements Action {
175
- readonly type = <%= classify(name) %>ActionTypes.REMOVE;
176
- constructor(
177
- public __id: string,
178
- public correlationId?: string,
179
- ) { }
180
- }
181
-
182
- export class Remove<%= classify(name) %>Success implements Action {
183
- readonly type = <%= classify(name) %>ActionTypes.REMOVE_SUCCESS;
184
- constructor(
185
- public __id: string,
186
- public correlationId?: string,
187
- ) {}
188
- }
189
-
190
- export class Remove<%= classify(name) %>Fail implements Action {
191
- readonly type = <%= classify(name) %>ActionTypes.REMOVE_FAIL;
192
- constructor(
193
- public error: any,
194
- public correlationId?: string,
195
- ) {}
196
- }
197
-
198
- export class Loaded<%= classify(name) %> implements Action {
199
- readonly type = <%= classify(name) %>ActionTypes.LOADED;
200
- constructor(
201
- public payload: <%= classify(name) %>[],
202
- public correlationId?: string,
203
- ) {}
204
- }
205
-
206
- export class Added<%= classify(name) %> implements Action {
207
- readonly type = <%= classify(name) %>ActionTypes.ADDED;
208
- constructor(
209
- public payload: <%= classify(name) %>,
210
- public correlationId?: string,
211
- ) {}
212
- }
213
-
214
- export class Modified<%= classify(name) %> implements Action {
215
- readonly type = <%= classify(name) %>ActionTypes.MODIFIED;
216
- constructor(
217
- public payload: <%= classify(name) %>,
218
- public correlationId?: string,
219
- ) {}
220
- }
221
-
222
- export class Removed<%= classify(name) %> implements Action {
223
- readonly type = <%= classify(name) %>ActionTypes.REMOVED;
224
- constructor(
225
- public payload: <%= classify(name) %>,
226
- public correlationId?: string,
227
- ) {}
228
- }
229
-
230
- export type <%= classify(name) %>Actions =
231
- Stream<%= classify(name) %> |
232
- Stream<%= classify(name) %>Success |
233
- Stream<%= classify(name) %>Fail |
234
- Load<%= classify(name) %> |
235
- Load<%= classify(name) %>Success |
236
- Load<%= classify(name) %>Fail |
237
- Add<%= classify(name) %> |
238
- Add<%= classify(name) %>Success |
239
- Add<%= classify(name) %>Fail |
240
- Update<%= classify(name) %> |
241
- Update<%= classify(name) %>Success |
242
- Update<%= classify(name) %>Fail |
243
- Remove<%= classify(name) %> |
244
- Remove<%= classify(name) %>Success |
245
- Remove<%= classify(name) %>Fail |
246
- Loaded<%= classify(name) %> |
247
- Added<%= classify(name) %> |
248
- Modified<%= classify(name) %> |
249
- Removed<%= classify(name) %>;
@@ -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
- Added<%= classify(name) %>, Removed<%= classify(name) %>,
12
- Stream<%= classify(name) %>, Stream<%= classify(name) %>Success, Stream<%= classify(name) %>Fail,
13
- Load<%= classify(name) %>, Load<%= classify(name) %>Success, Load<%= classify(name) %>Fail,
14
- Add<%= classify(name) %>, Add<%= classify(name) %>Success, Add<%= classify(name) %>Fail,
15
- Update<%= classify(name) %>, Update<%= classify(name) %>Success, Update<%= 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
- if (action.options && action.options.optimistic) {
56
- return merge(
57
- of(new Added<%= classify(name) %>(action.<%= camelize(name) %>, action.correlationId)),
58
- this.db.addEntity('<%= camelize(name) %>s', action.<%= camelize(name) %>).pipe(
59
- mergeMap(() => merge(
60
- of(new Add<%= classify(name) %>Success(action.<%= camelize(name) %>, action.correlationId)),
61
- this.actionsOnAdd(action),
62
- )),
63
- catchError((error) => merge(
64
- of(new Add<%= classify(name) %>Fail(error, action.correlationId)),
65
- of(new Removed<%= classify(name) %>(action.<%= camelize(name) %>, action.correlationId)),
66
- )),
67
- ),
68
- );
69
- } else {
70
- return this.db.addEntity('<%= camelize(name) %>s', action.<%= camelize(name) %>).pipe(
71
- mergeMap(() => merge(
72
- of(new Add<%= classify(name) %>Success(action.<%= camelize(name) %>, action.correlationId)),
73
- this.actionsOnAdd(action),
74
- )),
75
- catchError((error) => of(new Add<%= classify(name) %>Fail(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<Update<%= classify(name) %>>(<%= classify(name) %>ActionTypes.UPDATE),
86
- mergeMap((action: Update<%= classify(name) %>) => {
87
- return this.db.updateEntity('<%= camelize(name) %>s', action.__id, action.changes).pipe(
88
- mergeMap(() => merge(
89
- of(new Update<%= classify(name) %>Success(action.__id, action.changes, action.correlationId)),
90
- this.actionsOnUpdate(action),
91
- )),
92
- catchError((error) => of(new Update<%= 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
- }
@@ -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
- });
@@ -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);