@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,141 +0,0 @@
1
- "use strict";
2
- var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
3
- function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
4
- return new (P || (P = Promise))(function (resolve, reject) {
5
- function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
6
- function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
7
- function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
8
- step((generator = generator.apply(thisArg, _arguments || [])).next());
9
- });
10
- };
11
- Object.defineProperty(exports, "__esModule", { value: true });
12
- exports.entity = void 0;
13
- const schematics_1 = require("@angular-devkit/schematics");
14
- const change_1 = require("@schematics/angular/utility/change");
15
- const find_module_1 = require("@schematics/angular/utility/find-module");
16
- const parse_name_1 = require("@schematics/angular/utility/parse-name");
17
- const workspace_1 = require("@schematics/angular/utility/workspace");
18
- const core_1 = require("@angular-devkit/core");
19
- const statements_adder_1 = require("../shared/statements-adder");
20
- function addInserts(options) {
21
- return (host, context) => {
22
- const classifiedName = core_1.strings.classify(options.name);
23
- const camelizedName = core_1.strings.camelize(options.name);
24
- context.logger.info(`names: ${classifiedName}, ${camelizedName}`);
25
- // Add core module changes
26
- const coreModulePath = options.module;
27
- const coreModuleText = (0, statements_adder_1.getSourceText)(host, coreModulePath);
28
- context.logger.info(`modulePath: ${coreModulePath}`);
29
- const entityEffectsPath = `/${options.path}/` +
30
- core_1.strings.dasherize(options.name) + '/' +
31
- core_1.strings.dasherize(options.name) + '.effects';
32
- context.logger.info(`entityEffectsPath: ${entityEffectsPath}`);
33
- const coreToEffectsPath = (0, find_module_1.buildRelativePath)(coreModulePath, entityEffectsPath);
34
- context.logger.info(`coreToEffectsPath: ${coreToEffectsPath}`);
35
- let insertChangesInCore = (0, statements_adder_1.simpleInsert)(coreModuleText, coreModulePath, [
36
- '// Entity Effects',
37
- '// Entity Effects'
38
- ], [
39
- `import { ${classifiedName}Effects } from '${coreToEffectsPath}';`,
40
- ` ${classifiedName}Effects,`
41
- ]);
42
- // Add app reducer changes
43
- const appReducerPath = '//src/app/core/store/app.reducer.ts';
44
- const appReducerText = (0, statements_adder_1.getSourceText)(host, appReducerPath);
45
- context.logger.info(`appReducerPath: ${appReducerPath}`);
46
- const entityReducerPath = `/${options.path}/` +
47
- core_1.strings.dasherize(options.name) + '/' +
48
- core_1.strings.dasherize(options.name) + '.reducer';
49
- context.logger.info(`entityReducerPath: ${entityReducerPath}`);
50
- const appToEntityReducerPath = (0, find_module_1.buildRelativePath)(appReducerPath, entityReducerPath);
51
- let insertChangesInAppReducer = (0, statements_adder_1.simpleInsert)(appReducerText, appReducerPath, [
52
- '// Entity Reducers',
53
- '// Entity State',
54
- '// Entity Reducers'
55
- ], [
56
- `import * as from${classifiedName} from '${appToEntityReducerPath}';`,
57
- ` ${camelizedName}: from${classifiedName}.State;`,
58
- ` ${camelizedName}: from${classifiedName}.reducer,`
59
- ]);
60
- // Add app selector changes
61
- const appSelectorPath = '//src/app/core/store/app.selectors.ts';
62
- const appSelectorText = (0, statements_adder_1.getSourceText)(host, appSelectorPath);
63
- const entityServicePath = `/${options.path}/` +
64
- core_1.strings.dasherize(options.name) + '/' +
65
- core_1.strings.dasherize(options.name) + '.service';
66
- const appToEntityServicePath = (0, find_module_1.buildRelativePath)(appSelectorPath, entityServicePath);
67
- let insertChangesInAppSelector = (0, statements_adder_1.simpleInsert)(appSelectorText, appSelectorPath, [
68
- '// Entity Selectors',
69
- '// Entity Selectors',
70
- '// Entity Selectors'
71
- ], [
72
- `import { ${classifiedName}Service } from '${appToEntityServicePath}';`,
73
- ` private ${camelizedName}: ${classifiedName}Service,`,
74
- ` public get${classifiedName} = this.${camelizedName}.get${classifiedName};\n public get${classifiedName}s = this.${camelizedName}.get${classifiedName}s;\n public select${classifiedName} = this.${camelizedName}.select${classifiedName};\n public select${classifiedName}s = this.${camelizedName}.select${classifiedName}s;`
75
- ]);
76
- // Add firebase service changes
77
- const appFirebaseServicePath = '//src/app/core/firebase/firebase.service.ts';
78
- const appFirebaseServiceText = (0, statements_adder_1.getSourceText)(host, appFirebaseServicePath);
79
- const entityModelPath = `/${options.path}/` +
80
- core_1.strings.dasherize(options.name) + '/' +
81
- core_1.strings.dasherize(options.name) + '.model';
82
- const appToEntityModelPath = (0, find_module_1.buildRelativePath)(appFirebaseServicePath, entityModelPath);
83
- let insertChangesInFirebaseService = (0, statements_adder_1.simpleInsert)(appFirebaseServiceText, appFirebaseServicePath, [
84
- '// Entity Models',
85
- '// Entity Models'
86
- ], [
87
- `import { ${classifiedName} } from '${appToEntityModelPath}';`,
88
- ` ${camelizedName}s: new BehaviorSubject<Array<{ type: string; result: ${classifiedName} }>>(
89
- this.mockDBService.getInitialDBStateChanges('${camelizedName}s')
90
- ),`
91
- ]);
92
- context.logger.info(`about to start committing`);
93
- // For each of the files and corresponding set of changes, commit to the tree
94
- [
95
- [coreModulePath, insertChangesInCore],
96
- [appReducerPath, insertChangesInAppReducer],
97
- [appSelectorPath, insertChangesInAppSelector],
98
- [appFirebaseServicePath, insertChangesInFirebaseService],
99
- ].map(([filePath, insertChanges]) => {
100
- const declarationRecorder = host.beginUpdate(filePath);
101
- for (const change of insertChanges) {
102
- if (change instanceof change_1.InsertChange) {
103
- declarationRecorder.insertLeft(change.pos, change.toAdd);
104
- }
105
- }
106
- host.commitUpdate(declarationRecorder);
107
- });
108
- return host;
109
- };
110
- }
111
- function entity(options) {
112
- return (tree, context) => __awaiter(this, void 0, void 0, function* () {
113
- // Make sure the command is executed in the directory where the component should be generated
114
- if (!options.inDirectory) {
115
- context.logger.info("Please navigate to the directory where you want to generate the entity.");
116
- return (0, schematics_1.noop)();
117
- }
118
- const workspace = yield (0, workspace_1.getWorkspace)(tree);
119
- const project = workspace.projects.get(options.project);
120
- if (!project) {
121
- throw new schematics_1.SchematicsException(`Project "${options.project}" does not exist.`);
122
- }
123
- if (options.path === undefined) {
124
- options.path = (0, workspace_1.buildDefaultPath)(project);
125
- }
126
- options.module = (0, find_module_1.findModuleFromOptions)(tree, options);
127
- const parsedPath = (0, parse_name_1.parseName)(options.path, options.name);
128
- options.name = parsedPath.name;
129
- options.path = parsedPath.path;
130
- const templateSource = (0, schematics_1.apply)((0, schematics_1.url)('./files'), [
131
- (0, schematics_1.applyTemplates)(Object.assign(Object.assign({}, core_1.strings), options)),
132
- (0, schematics_1.move)(parsedPath.path),
133
- ]);
134
- return (0, schematics_1.chain)([
135
- addInserts(options),
136
- (0, schematics_1.mergeWith)(templateSource)
137
- ]);
138
- });
139
- }
140
- exports.entity = entity;
141
- //# sourceMappingURL=index.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["index.ts"],"names":[],"mappings":";;;;;;;;;;;;AAAA,2DAIoC;AAEpC,+DAA0E;AAC1E,yEAAmG;AACnG,uEAAmE;AACnE,qEAAuF;AACvF,+CAA+C;AAE/C,iEAAyE;AAEzE,SAAS,UAAU,CAAC,OAAY;IAC9B,OAAO,CAAC,IAAU,EAAE,OAAyB,EAAE,EAAE;QAE/C,MAAM,cAAc,GAAG,cAAO,CAAC,QAAQ,CAAC,OAAO,CAAC,IAAI,CAAC,CAAC;QACtD,MAAM,aAAa,GAAG,cAAO,CAAC,QAAQ,CAAC,OAAO,CAAC,IAAI,CAAC,CAAC;QACrD,OAAO,CAAC,MAAM,CAAC,IAAI,CAAC,UAAU,cAAc,KAAK,aAAa,EAAE,CAAC,CAAC;QAElE,0BAA0B;QAC1B,MAAM,cAAc,GAAG,OAAO,CAAC,MAAM,CAAC;QACtC,MAAM,cAAc,GAAG,IA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J,CAAC;AAvCD,wBAuCC"}
@@ -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('entity', () => {
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('entity', {}, 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,QAAQ,EAAE,GAAG,EAAE;IACtB,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,QAAQ,EAAE,EAAE,EAAE,iBAAI,CAAC,KAAK,EAAE,CAAC,CAAC;QAEnE,MAAM,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC,OAAO,CAAC,EAAE,CAAC,CAAC;IACjC,CAAC,CAAA,CAAC,CAAC;AACL,CAAC,CAAC,CAAC"}
@@ -1,45 +0,0 @@
1
- {
2
- "$schema": "http://json-schema.org/schema",
3
- "$id": "EntitySchema",
4
- "title": "Entity Schema",
5
- "type": "object",
6
- "description": "Creates a new entity 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 entity file, relative to the current workspace. Should typically be within /src/app/core/store.",
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 entity.",
31
- "$default": {
32
- "$source": "argv",
33
- "index": 0
34
- },
35
- "x-prompt": "What name would you like to use for the entity?"
36
- },
37
- "inDirectory": {
38
- "type": "boolean",
39
- "x-prompt": "Are you currently in the directory where you want to generate the entity? (typically directly in src/app/core/store)"
40
- }
41
- },
42
- "required": [
43
- "name"
44
- ]
45
- }
@@ -1,10 +0,0 @@
1
- Update this manually once the project is generated and update it as changes are made to the repository.
2
-
3
- <a name="13.0.0-0"></a>
4
- # 13.0.0-0 (YYYY-MM-DD)
5
- ### <%= classify(project) %>
6
- | Commit | Type | Description |
7
- | -- | -- | -- |
8
- | [commit-hash](commit-url) | fix | **module:** commit message ([#pr](pr-url)) |
9
-
10
- <!-- CHANGELOG SPLIT MARKER -->
@@ -1,17 +0,0 @@
1
- import { NgModule } from '@angular/core';
2
- import { Routes, RouterModule } from '@angular/router';
3
- import { AuthGuard } from '../core/auth/auth.guard';
4
-
5
- // Containers
6
- import { WaitlistComponent } from './waitlist/waitlist.component';
7
-
8
- const routes: Routes = [
9
- { path: '', redirectTo: '/landing', pathMatch: 'full' },
10
- { path: 'waitlist', component: WaitlistComponent, canActivate: [AuthGuard] },
11
- ];
12
-
13
- @NgModule({
14
- imports: [RouterModule.forChild(routes)],
15
- exports: [RouterModule],
16
- })
17
- export class AdminRoutingModule { }
@@ -1,13 +0,0 @@
1
- import { AdminModule } from './admin.module';
2
-
3
- describe('AdminModule', () => {
4
- let adminModule: AdminModule;
5
-
6
- beforeEach(() => {
7
- adminModule = new AdminModule();
8
- });
9
-
10
- it('should create an instance', () => {
11
- expect(adminModule).toBeTruthy();
12
- });
13
- });
@@ -1,28 +0,0 @@
1
- import { NgModule } from '@angular/core';
2
- import { CommonModule } from '@angular/common';
3
- import { EffectsModule } from '@ngrx/effects';
4
- import { SharedModule } from '../shared/shared.module';
5
- import { AdminRoutingModule } from './admin-routing.module';
6
-
7
- // Containers
8
- import { WaitlistComponent } from './waitlist/waitlist.component';
9
- import { WaitlistEffects } from './waitlist/+state/waitlist.effects';
10
-
11
- // Components
12
-
13
- @NgModule({
14
- imports: [
15
- CommonModule,
16
- SharedModule,
17
- AdminRoutingModule,
18
- EffectsModule.forFeature([
19
- WaitlistEffects,
20
- ]),
21
- ],
22
- declarations: [
23
- // Containers
24
- WaitlistComponent,
25
- // Components
26
- ],
27
- })
28
- export class AdminModule { }
@@ -1,23 +0,0 @@
1
- import { Action } from '@ngrx/store';
2
-
3
- export enum WaitlistActionTypes {
4
- LOAD_DATA = '[Waitlist] load data',
5
- CLEANUP = '[Waitlist] cleanup',
6
- }
7
-
8
- /** Action for loading required DB data. */
9
- export class LoadData implements Action {
10
- readonly type = WaitlistActionTypes.LOAD_DATA;
11
-
12
- constructor(public containerId: string) { }
13
- }
14
-
15
- /** Action for cleaning up loading subscriptions. */
16
- export class Cleanup implements Action {
17
- readonly type = WaitlistActionTypes.CLEANUP;
18
- constructor(public containerId: string) { }
19
- }
20
-
21
- export type WaitlistActions =
22
- LoadData |
23
- Cleanup;
@@ -1,50 +0,0 @@
1
- import { Injectable } from '@angular/core';
2
- import { Action } from '@ngrx/store';
3
- import { Actions, createEffect, ofType } from '@ngrx/effects';
4
-
5
- import { of, Observable } from 'rxjs';
6
- import { mergeMap, tap, map } from 'rxjs/operators';
7
-
8
- import { select, Store } from '@ngrx/store';
9
- import * as fromStore from '../../../core/store/app.reducer';
10
- import { FirebaseService } from '../../../core/firebase/firebase.service';
11
- import { EffectsHelpers } from '../../../core/store/effects.helpers';
12
- import { WaitlistState } from './waitlist.state';
13
-
14
- import { ActionFlow, RouterNavigate, LoadAction, Unsubscribe } from '../../../core/store/app.actions';
15
- import { WaitlistActionTypes, Cleanup, LoadData } from './waitlist.actions';
16
- import { AccessState } from '../../../core/store/user/user.model';
17
- import { StreamUser } from '../../../core/store/user/user.actions';
18
-
19
- @Injectable()
20
- export class WaitlistEffects {
21
- /** Load data from Firebase. */
22
- loadData$: Observable<Action> = createEffect(
23
- () => this.actions$.pipe(
24
- ofType<LoadData>(WaitlistActionTypes.LOAD_DATA),
25
- mergeMap((action: LoadData) => {
26
- const loadId = action.containerId;
27
-
28
- return [
29
- new StreamUser([], {}, loadId),
30
- ];
31
- }),
32
- ),
33
- );
34
-
35
- /** Unsubscribe connections from Firebase. */
36
- cleanup$: Observable<Action> = createEffect(
37
- () => this.actions$.pipe(
38
- ofType<Cleanup>(WaitlistActionTypes.CLEANUP),
39
- map((action: Cleanup) => new Unsubscribe(action.containerId)),
40
- ),
41
- );
42
-
43
- constructor(
44
- private actions$: Actions,
45
- private store: Store<fromStore.State>,
46
- private state: WaitlistState,
47
- private db: FirebaseService,
48
- private eh: EffectsHelpers,
49
- ) {}
50
- }
@@ -1,39 +0,0 @@
1
- import { Injectable } from '@angular/core';
2
- import { Store, select } from '@ngrx/store';
3
- import * as fromStore from '../../../core/store/app.reducer';
4
- import { EntitySelectorService } from '../../../core/store/app.selectors';
5
-
6
- import { Observable, of, combineLatest } from 'rxjs';
7
- import { bufferTime, distinctUntilChanged, shareReplay, mergeMap, filter, switchMap, map } from 'rxjs/operators';
8
- import { User, AccessState } from '../../../core/store/user/user.model';
9
-
10
- @Injectable({
11
- providedIn: 'root',
12
- })
13
- export class WaitlistSelectors {
14
- constructor(
15
- private slRx: EntitySelectorService,
16
- ) { }
17
-
18
- /** selector for getting waiting users. */
19
- selectWaitingUsers(cId: string): Observable<User[]> {
20
- return this.slRx.selectUsers([], cId).pipe(
21
- map((users) => {
22
- users.sort((a, b) => {
23
- if (a.accessState > b.accessState) {
24
- return 1;
25
- } else if (a.accessState < b.accessState) {
26
- return -1;
27
- } else {
28
- return 0;
29
- }
30
- });
31
- return users;
32
- }),
33
- );
34
- }
35
-
36
- cleanup(cId: string) {
37
- this.slRx.release(cId);
38
- }
39
- }
@@ -1,13 +0,0 @@
1
- import { Injectable } from '@angular/core';
2
-
3
- import { BehaviorSubject } from 'rxjs';
4
-
5
- @Injectable({
6
- providedIn: 'root',
7
- })
8
- export class WaitlistState {
9
- // --------------- LOCAL UI STATE ----------------------
10
-
11
- constructor(
12
- ) { }
13
- }
@@ -1,141 +0,0 @@
1
- import { Component, OnInit, OnDestroy, ChangeDetectionStrategy } from '@angular/core';
2
- import { WaitlistAnimations } from './waitlist.animations';
3
- import { ParamMap, ActivatedRoute } from '@angular/router';
4
- import { Store, select } from '@ngrx/store';
5
- import * as fromStore from '../../core/store/app.reducer';
6
- import * as fromAuth from '../../core/store/auth/auth.reducer';
7
- import { FirebaseService } from '../../core/firebase/firebase.service';
8
- import { Observable, Subject, BehaviorSubject, combineLatest } from 'rxjs';
9
- import { withLatestFrom, take, takeUntil } from 'rxjs/operators';
10
-
11
- import { WaitlistState } from './+state/waitlist.state';
12
- import { WaitlistSelectors } from './+state/waitlist.selectors';
13
-
14
- import { LoadData, Cleanup } from './+state/waitlist.actions';
15
- import { ActionFlow, RouterNavigate, ActionSet } from '../../core/store/app.actions';
16
-
17
- import { User, AccessState } from '../../core/store/user/user.model';
18
- import { ShowSnackbar } from '../../core/snackbar/snackbar.actions';
19
- import { UpdateUser, UserActionTypes } from '../../core/store/user/user.actions';
20
-
21
- // If you add other columns, update this, e.g. AccessState | string | boolean;
22
- type UpdateValueTypes = AccessState;
23
-
24
- @Component({
25
- selector: 'app-waitlist',
26
- templateUrl: './waitlist.component.html',
27
- styleUrls: ['./waitlist.component.scss'],
28
- changeDetection: ChangeDetectionStrategy.OnPush,
29
- animations: WaitlistAnimations,
30
- })
31
- export class WaitlistComponent implements OnInit, OnDestroy {
32
- // --------------- ROUTE PARAMS & CURRENT USER ---------
33
-
34
-
35
- // --------------- LOCAL AND GLOBAL STATE --------------
36
-
37
- /** Access options for menu sorted alphabetically. */
38
- accessOptions: AccessState[] = Object.keys(AccessState)
39
- .map((k) => AccessState[k] as AccessState)
40
- .sort((a, b) => {
41
- if (a > b) {
42
- return 1;
43
- } else if (a < b) {
44
- return -1;
45
- } else {
46
- return 0;
47
- }
48
- });
49
-
50
- /** Columns to display in the table */
51
- displayedColumns = ['userName', 'accessState'];
52
-
53
- // --------------- DB ENTITY DATA ----------------------
54
-
55
- /** Container id for selectors and loading. */
56
- containerId: string = this.db.createId();
57
-
58
- /** Get array of all waiting users. */
59
- waitingUsers$: Observable<User[]> = this.selectors.selectWaitingUsers(this.containerId);
60
-
61
- // --------------- DATA BINDING ------------------------
62
-
63
-
64
- // --------------- EVENT BINDING -----------------------
65
-
66
- /** Event stream for updating user accessState. */
67
- updateState$: Subject<{ user: User, key: string, value: UpdateValueTypes }> = new Subject<{ user: User, key: string, value: UpdateValueTypes }>();
68
-
69
-
70
- // --------------- HELPER FUNCTIONS AND OTHER ----------
71
-
72
- /** Unsubscribe observable for subscriptions. */
73
- unsubscribe$: Subject<void> = new Subject();
74
-
75
- constructor(
76
- private state: WaitlistState,
77
- private route: ActivatedRoute,
78
- private selectors: WaitlistSelectors,
79
- private store: Store<fromStore.State>,
80
- private db: FirebaseService,
81
- ) {
82
- }
83
-
84
- ngOnInit() {
85
- // --------------- EVENT HANDLING ----------------------
86
-
87
- this.updateState$.pipe(
88
- takeUntil(this.unsubscribe$),
89
- ).subscribe(({ user, key, value }) => {
90
- const data = {};
91
- data[key] = value;
92
- const actionSets: ActionSet[] = [{
93
- action: new UpdateUser(user.__id, {
94
- ...data,
95
- }, this.containerId),
96
- responseActionTypes: {
97
- success: UserActionTypes.UPDATE_SUCCESS,
98
- failure: UserActionTypes.UPDATE_FAIL,
99
- },
100
- }];
101
-
102
- this.store.dispatch(
103
- new ActionFlow({
104
- actionSets,
105
- successActionFn: (actionSetResponses) => {
106
- return [
107
- new ShowSnackbar({
108
- message: `Set ${user.name}'s ${key} to ${value}`,
109
- config: { duration: 3000 },
110
- }),
111
- ];
112
- },
113
- failActionFn: (actionSetResponses) => {
114
- return [
115
- new ShowSnackbar({
116
- message: 'Failed to submit response',
117
- config: { duration: 3000 },
118
- }),
119
- ];
120
- },
121
- }),
122
- );
123
- });
124
-
125
-
126
- // --------------- LOAD DATA ---------------------------
127
-
128
- // Once everything is set up, load the data for the role.
129
- this.store.dispatch( new LoadData(this.containerId) );
130
- }
131
-
132
- ngOnDestroy() {
133
- // Unsubscribe subscriptions.
134
- this.unsubscribe$.next();
135
- this.unsubscribe$.complete();
136
-
137
- // Unsubscribe from firebase connection from load and free up memoized selector values.
138
- this.store.dispatch( new Cleanup(this.containerId) );
139
- this.selectors.cleanup(this.containerId);
140
- }
141
- }
@@ -1,26 +0,0 @@
1
- import { NgModule } from '@angular/core';
2
- import { Routes, RouterModule, PreloadAllModules } from '@angular/router';
3
- import { AuthGuard } from './core/auth/auth.guard';
4
-
5
- // Containers
6
- import { LoginComponent } from './general/login/login.component';
7
- import { LandingComponent } from './general/landing/landing.component';
8
-
9
- // Our general approach is to load the GeneralModule eagerly and everything lazily (but with preloading)
10
- const appRoutes: Routes = [
11
- { path: 'admin', loadChildren: () => import('./admin/admin.module').then((mod) => mod.AdminModule) },
12
- { path: 'onboarding', loadChildren: () => import('./onboarding/onboarding.module').then((mod) => mod.OnboardingModule) },
13
- { path: '', component: LandingComponent, canActivate: [AuthGuard] },
14
- { path: '**', redirectTo: '', pathMatch: 'full' },
15
- ];
16
-
17
- @NgModule({
18
- imports: [
19
- RouterModule.forRoot(appRoutes, {
20
- useHash: true,
21
- preloadingStrategy: PreloadAllModules,
22
- }),
23
- ],
24
- exports: [RouterModule],
25
- })
26
- export class AppRoutingModule { }
@@ -1,34 +0,0 @@
1
- import { BrowserModule } from '@angular/platform-browser';
2
- import { BrowserAnimationsModule } from '@angular/platform-browser/animations';
3
- import { NgModule } from '@angular/core';
4
-
5
- import { AppComponent } from './app.component';
6
- import { AppRoutingModule } from './app-routing.module';
7
-
8
- // General Modules
9
- import { CoreModule } from './core/core.module';
10
- import { SharedModule } from './shared/shared.module';
11
-
12
- // Feature Modules
13
- import { GeneralModule } from './general/general.module';
14
-
15
- @NgModule({
16
- declarations: [
17
- AppComponent,
18
- ],
19
- imports: [
20
- BrowserModule,
21
- BrowserAnimationsModule,
22
- CoreModule,
23
- SharedModule,
24
- // Feature Modules
25
- GeneralModule,
26
- // Routing Module
27
- AppRoutingModule,
28
- ],
29
- providers: [],
30
- bootstrap: [
31
- AppComponent,
32
- ],
33
- })
34
- export class AppModule { }