@tech4good/angular-schematics 21.5.0 → 21.7.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (273) hide show
  1. package/CHANGELOG.md +44 -0
  2. package/README.md +266 -1
  3. package/package.json +34 -7
  4. package/src/component/files/__name@dasherize__/__name@dasherize__.component.spec.ts.template +4 -5
  5. package/src/component/files/__name@dasherize__/__name@dasherize__.component.ts.template +1 -1
  6. package/src/entity/files/__name@dasherize__/__name@dasherize__.mock.ts.template +16 -7
  7. package/src/entity/files/__name@dasherize__/__name@dasherize__.model.ts.template +13 -6
  8. package/src/entity/files/__name@dasherize__/__name@dasherize__.store.ts.template +18 -10
  9. package/src/entity/index.js +61 -49
  10. package/src/entity/index.js.map +1 -1
  11. package/src/entity/schema.json +4 -0
  12. package/src/guard/files/__name@dasherize__.guard.spec.ts.template +0 -1
  13. package/src/ng-add/files/.github/workflows/angular-github-ci.yml.template +3 -0
  14. package/src/ng-add/files/.gitignore.template +5 -0
  15. package/src/ng-add/files/analytics/datasets.js.template +206 -0
  16. package/src/ng-add/files/analytics/entity_sources.js.template +58 -0
  17. package/src/ng-add/files/analytics/entity_sources.test.js.template +57 -0
  18. package/src/ng-add/files/analytics/lib/api_query.js.template +87 -0
  19. package/src/ng-add/files/analytics/lib/api_query.test.js.template +84 -0
  20. package/src/ng-add/files/analytics/lib/bigquery_query_compatibility.test.js.template +53 -0
  21. package/src/ng-add/files/analytics/lib/dataset_schema.js.template +53 -0
  22. package/src/ng-add/files/analytics/lib/dataset_schema.test.js.template +34 -0
  23. package/src/ng-add/files/analytics/lib/entity_sync.js.template +397 -0
  24. package/src/ng-add/files/analytics/lib/entity_sync.test.js.template +212 -0
  25. package/src/ng-add/files/analytics/lib/identifier_salt.js.template +57 -0
  26. package/src/ng-add/files/analytics/lib/identifier_salt.test.js.template +36 -0
  27. package/src/ng-add/files/analytics/lib/snapshot_files.js.template +46 -0
  28. package/src/ng-add/files/analytics/lib/snapshot_files.test.js.template +67 -0
  29. package/src/ng-add/files/analytics/lib/sqlite.js.template +92 -0
  30. package/src/ng-add/files/analytics/lib/upload_entities.js.template +81 -0
  31. package/src/ng-add/files/analytics/lib/upload_entities.test.js.template +86 -0
  32. package/src/ng-add/files/analytics/proxy.conf.json.template +7 -0
  33. package/src/ng-add/files/analytics/scripts/refresh_snapshot.js.template +518 -0
  34. package/src/ng-add/files/analytics/scripts/start.js.template +88 -0
  35. package/src/ng-add/files/analytics/server/server.js.template +212 -0
  36. package/src/ng-add/files/angular.json.template +80 -1
  37. package/src/ng-add/files/bigquery/queries/active_time_by_route.sql.template +27 -8
  38. package/src/ng-add/files/bigquery/queries/active_user_windows.sql.template +67 -0
  39. package/src/ng-add/files/bigquery/queries/dashboard_route_visits.sql.template +47 -0
  40. package/src/ng-add/files/bigquery/queries/data_quality.sql.template +323 -0
  41. package/src/ng-add/files/bigquery/queries/onboarding_funnel.sql.template +512 -0
  42. package/src/ng-add/files/bigquery/queries/onboarding_stage_observations.sql.template +134 -0
  43. package/src/ng-add/files/bigquery/queries/weekly_retention_cohorts.sql.template +90 -0
  44. package/src/ng-add/files/bigquery/scripts/export_entities.js.template +120 -0
  45. package/src/ng-add/files/bigquery/scripts/init_views.js.template +57 -0
  46. package/src/ng-add/files/bigquery/scripts/run_query.js.template +141 -0
  47. package/src/ng-add/files/bigquery/views/events_flat.sql.template +27 -12
  48. package/src/ng-add/files/bigquery/views/logs_latest.sql.template +16 -3
  49. package/src/ng-add/files/docs-infra/analytics-guide.md.template +270 -25
  50. package/src/ng-add/files/docs-infra/analytics-workbench-guide.md.template +307 -0
  51. package/src/ng-add/files/docs-infra/authentication-architecture.md.template +300 -0
  52. package/src/ng-add/files/docs-infra/email-infrastructure.md.template +43 -0
  53. package/src/ng-add/files/docs-infra/firestore-index-checker.md.template +87 -0
  54. package/src/ng-add/files/docs-infra/infrastructure-guide.md.template +123 -38
  55. package/src/ng-add/files/docs-infra/load-system-architecture.md.template +15 -1
  56. package/src/ng-add/files/docs-infra/querying-strategy.md.template +14 -0
  57. package/src/ng-add/files/docs-infra/stream-system-architecture.md.template +21 -7
  58. package/src/ng-add/files/eslint.config.js.template +22 -3
  59. package/src/ng-add/files/firebase.json.template +6 -0
  60. package/src/ng-add/files/firestore.indexes.json.template +23 -0
  61. package/src/ng-add/files/firestore.rules.spec.ts.template +84 -15
  62. package/src/ng-add/files/firestore.rules.template +29 -17
  63. package/src/ng-add/files/functions/.gitignore.template +3 -0
  64. package/src/ng-add/files/functions/package.json.template +13 -0
  65. package/src/ng-add/files/functions/src/email.ts.template +23 -0
  66. package/src/ng-add/files/functions/src/index.ts.template +44 -0
  67. package/src/ng-add/files/functions/tsconfig.json.template +13 -0
  68. package/src/ng-add/files/jest.config.ts.template +3 -2
  69. package/src/ng-add/files/package.json.template +41 -16
  70. package/src/ng-add/files/projects/analytics/src/app/analytics-api.service.ts.template +130 -0
  71. package/src/ng-add/files/projects/analytics/src/app/app.component.html.template +77 -0
  72. package/src/ng-add/files/projects/analytics/src/app/app.component.scss.template +240 -0
  73. package/src/ng-add/files/projects/analytics/src/app/app.component.ts.template +96 -0
  74. package/src/ng-add/files/projects/analytics/src/app/app.routes.ts.template +11 -0
  75. package/src/ng-add/files/projects/analytics/src/app/dashboard-pages.spec.ts.template +151 -0
  76. package/src/ng-add/files/projects/analytics/src/app/data-quality/data-quality-page/data-quality-page.component.html.template +39 -0
  77. package/src/ng-add/files/projects/analytics/src/app/data-quality/data-quality-page/data-quality-page.component.scss.template +1 -0
  78. package/src/ng-add/files/projects/analytics/src/app/data-quality/data-quality-page/data-quality-page.component.ts.template +95 -0
  79. package/src/ng-add/files/projects/analytics/src/app/engagement/engagement-page/engagement-page.component.html.template +47 -0
  80. package/src/ng-add/files/projects/analytics/src/app/engagement/engagement-page/engagement-page.component.scss.template +1 -0
  81. package/src/ng-add/files/projects/analytics/src/app/engagement/engagement-page/engagement-page.component.ts.template +120 -0
  82. package/src/ng-add/files/projects/analytics/src/app/onboarding/onboarding-page/onboarding-page.component.html.template +40 -0
  83. package/src/ng-add/files/projects/analytics/src/app/onboarding/onboarding-page/onboarding-page.component.scss.template +1 -0
  84. package/src/ng-add/files/projects/analytics/src/app/onboarding/onboarding-page/onboarding-page.component.ts.template +98 -0
  85. package/src/ng-add/files/projects/analytics/src/app/overview/overview-page/overview-page.component.html.template +35 -0
  86. package/src/ng-add/files/projects/analytics/src/app/overview/overview-page/overview-page.component.scss.template +1 -0
  87. package/src/ng-add/files/projects/analytics/src/app/overview/overview-page/overview-page.component.ts.template +84 -0
  88. package/src/ng-add/files/projects/analytics/src/app/routes/routes-page/routes-page.component.html.template +42 -0
  89. package/src/ng-add/files/projects/analytics/src/app/routes/routes-page/routes-page.component.scss.template +1 -0
  90. package/src/ng-add/files/projects/analytics/src/app/routes/routes-page/routes-page.component.ts.template +110 -0
  91. package/src/ng-add/files/projects/analytics/src/app/shared/analytics-utils.ts.template +43 -0
  92. package/src/ng-add/files/projects/analytics/src/app/shared/chart-theme.ts.template +42 -0
  93. package/src/ng-add/files/projects/analytics/src/app/shared/dashboard-layout.scss.template +239 -0
  94. package/src/ng-add/files/projects/analytics/src/app/shared/dashboard-table/dashboard-table.component.html.template +76 -0
  95. package/src/ng-add/files/projects/analytics/src/app/shared/dashboard-table/dashboard-table.component.scss.template +128 -0
  96. package/src/ng-add/files/projects/analytics/src/app/shared/dashboard-table/dashboard-table.component.spec.ts.template +31 -0
  97. package/src/ng-add/files/projects/analytics/src/app/shared/dashboard-table/dashboard-table.component.ts.template +153 -0
  98. package/src/ng-add/files/projects/analytics/src/app/shared/funnel-chart/funnel-chart.component.html.template +16 -0
  99. package/src/ng-add/files/projects/analytics/src/app/shared/funnel-chart/funnel-chart.component.scss.template +63 -0
  100. package/src/ng-add/files/projects/analytics/src/app/shared/funnel-chart/funnel-chart.component.ts.template +52 -0
  101. package/src/ng-add/files/projects/analytics/src/app/shared/metric-card/metric-card.component.html.template +5 -0
  102. package/src/ng-add/files/projects/analytics/src/app/shared/metric-card/metric-card.component.scss.template +56 -0
  103. package/src/ng-add/files/projects/analytics/src/app/shared/metric-card/metric-card.component.spec.ts.template +30 -0
  104. package/src/ng-add/files/projects/analytics/src/app/shared/metric-card/metric-card.component.ts.template +15 -0
  105. package/src/ng-add/files/projects/analytics/src/app/shared/quality-chart/quality-chart.component.html.template +9 -0
  106. package/src/ng-add/files/projects/analytics/src/app/shared/quality-chart/quality-chart.component.scss.template +43 -0
  107. package/src/ng-add/files/projects/analytics/src/app/shared/quality-chart/quality-chart.component.ts.template +62 -0
  108. package/src/ng-add/files/projects/analytics/src/app/shared/route-distribution-chart/route-distribution-chart.component.html.template +9 -0
  109. package/src/ng-add/files/projects/analytics/src/app/shared/route-distribution-chart/route-distribution-chart.component.scss.template +33 -0
  110. package/src/ng-add/files/projects/analytics/src/app/shared/route-distribution-chart/route-distribution-chart.component.ts.template +82 -0
  111. package/src/ng-add/files/projects/analytics/src/app/shared/route-traffic-chart/route-traffic-chart.component.html.template +15 -0
  112. package/src/ng-add/files/projects/analytics/src/app/shared/route-traffic-chart/route-traffic-chart.component.scss.template +45 -0
  113. package/src/ng-add/files/projects/analytics/src/app/shared/route-traffic-chart/route-traffic-chart.component.ts.template +55 -0
  114. package/src/ng-add/files/projects/analytics/src/app/shared/status-message/status-message.component.html.template +18 -0
  115. package/src/ng-add/files/projects/analytics/src/app/shared/status-message/status-message.component.scss.template +45 -0
  116. package/src/ng-add/files/projects/analytics/src/app/shared/status-message/status-message.component.ts.template +15 -0
  117. package/src/ng-add/files/projects/analytics/src/app/vega-chart/vega-chart.component.ts.template +121 -0
  118. package/src/ng-add/files/projects/analytics/src/index.html.template +19 -0
  119. package/src/ng-add/files/projects/analytics/src/main.ts.template +16 -0
  120. package/src/ng-add/files/projects/analytics/src/styles.scss.template +28 -0
  121. package/src/ng-add/files/projects/analytics/tsconfig.app.json.template +13 -0
  122. package/src/ng-add/files/projects/analytics/tsconfig.spec.json.template +15 -0
  123. package/src/ng-add/files/src/app/admin/admin-panel/admin-panel.component.html.template +3 -1
  124. package/src/ng-add/files/src/app/admin/admin-panel/admin-panel.component.spec.ts.template +10 -13
  125. package/src/ng-add/files/src/app/admin/admin-panel/admin-panel.component.ts.template +2 -0
  126. package/src/ng-add/files/src/app/admin/admin-panel/admin-settings/admin-settings.component.spec.ts.template +4 -5
  127. package/src/ng-add/files/src/app/admin/admin-panel/admin-user-list/admin-user-list.component.spec.ts.template +11 -12
  128. package/src/ng-add/files/src/app/admin/admin-panel/admin-user-list/admin-user-list.component.ts.template +7 -7
  129. package/src/ng-add/files/src/app/admin/admin-panel/admin-user-list/admin-user-table/admin-user-table.component.spec.ts.template +8 -10
  130. package/src/ng-add/files/src/app/admin/admin-panel/admin-user-list/admin-user-table/admin-user-table.component.ts.template +3 -2
  131. package/src/ng-add/files/src/app/app.component.html.template +3 -3
  132. package/src/ng-add/files/src/app/app.component.scss.template +1 -1
  133. package/src/ng-add/files/src/app/app.component.spec.ts.template +4 -5
  134. package/src/ng-add/files/src/app/app.component.ts.template +3 -2
  135. package/src/ng-add/files/src/app/app.config.ts.template +21 -15
  136. package/src/ng-add/files/src/app/app.routes.ts.template +6 -0
  137. package/src/ng-add/files/src/app/auth-routing.spec.ts.template +13 -9
  138. package/src/ng-add/files/src/app/core/analytics/time-analytics.service.spec.ts.template +46 -29
  139. package/src/ng-add/files/src/app/core/analytics/time-analytics.service.ts.template +27 -18
  140. package/src/ng-add/files/src/app/core/auth/auth.providers.spec.ts.template +112 -0
  141. package/src/ng-add/files/src/app/core/auth/auth.providers.ts.template +48 -0
  142. package/src/ng-add/files/src/app/core/auth/auth.service.ts.template +14 -23
  143. package/src/ng-add/files/src/app/core/auth/guards/require-admin.guard.spec.ts.template +27 -0
  144. package/src/ng-add/files/src/app/core/auth/guards/require-admin.guard.ts.template +3 -2
  145. package/src/ng-add/files/src/app/core/auth/guards/require-auth-and-consent.guard.ts.template +7 -2
  146. package/src/ng-add/files/src/app/core/firebase/data.providers.prod.ts.template +21 -0
  147. package/src/ng-add/files/src/app/core/firebase/data.providers.ts.template +13 -0
  148. package/src/ng-add/files/src/app/core/local-storage/session.service.spec.ts.template +43 -0
  149. package/src/ng-add/files/src/app/core/local-storage/session.service.ts.template +7 -0
  150. package/src/ng-add/files/src/app/core/store/app-data.spec.ts.template +76 -0
  151. package/src/ng-add/files/src/app/core/store/auth/auth.mock.ts.template +20 -82
  152. package/src/ng-add/files/src/app/core/store/auth/auth.store.spec.ts.template +217 -0
  153. package/src/ng-add/files/src/app/core/store/auth/auth.store.ts.template +36 -172
  154. package/src/ng-add/files/src/app/core/store/user/user.mock.ts.template +18 -15
  155. package/src/ng-add/files/src/app/core/store/user/user.model.ts.template +7 -8
  156. package/src/ng-add/files/src/app/core/store/user/user.store.ts.template +14 -10
  157. package/src/ng-add/files/src/app/core/store/user-context/user-context.mock.ts.template +20 -8
  158. package/src/ng-add/files/src/app/core/store/user-context/user-context.model.ts.template +5 -6
  159. package/src/ng-add/files/src/app/core/store/user-context/user-context.store.ts.template +14 -10
  160. package/src/ng-add/files/src/app/core/store/user-private/user-private.mock.ts.template +20 -7
  161. package/src/ng-add/files/src/app/core/store/user-private/user-private.model.ts.template +6 -6
  162. package/src/ng-add/files/src/app/core/store/user-private/user-private.store.ts.template +14 -10
  163. package/src/ng-add/files/src/app/core/testing/app-mocks.ts.template +42 -0
  164. package/src/ng-add/files/src/app/first-time/auth-action/auth-action.component.html.template +4 -0
  165. package/src/ng-add/files/src/app/first-time/auth-action/auth-action.component.scss.template +1 -0
  166. package/src/ng-add/files/src/app/first-time/auth-action/auth-action.component.ts.template +38 -0
  167. package/src/ng-add/files/src/app/first-time/consent/consent.component.html.template +2 -1
  168. package/src/ng-add/files/src/app/first-time/consent/consent.component.scss.template +7 -3
  169. package/src/ng-add/files/src/app/first-time/consent/consent.component.spec.ts.template +31 -11
  170. package/src/ng-add/files/src/app/first-time/consent/consent.component.ts.template +16 -1
  171. package/src/ng-add/files/src/app/first-time/consent/consent.guard.ts.template +5 -1
  172. package/src/ng-add/files/src/app/first-time/early-access/early-access.component.spec.ts.template +27 -16
  173. package/src/ng-add/files/src/app/first-time/early-access/early-access.component.ts.template +102 -49
  174. package/src/ng-add/files/src/app/first-time/early-access/early-access.guard.ts.template +5 -1
  175. package/src/ng-add/files/src/app/first-time/early-access/survey-form/survey-form.component.html.template +2 -1
  176. package/src/ng-add/files/src/app/first-time/early-access/survey-form/survey-form.component.scss.template +7 -3
  177. package/src/ng-add/files/src/app/first-time/early-access/survey-form/survey-form.component.spec.ts.template +20 -6
  178. package/src/ng-add/files/src/app/first-time/early-access/survey-form/survey-form.component.ts.template +2 -0
  179. package/src/ng-add/files/src/app/first-time/early-access/waitlist-view/waitlist-view.component.spec.ts.template +4 -5
  180. package/src/ng-add/files/src/app/first-time/email-link/email-link.component.html.template +18 -0
  181. package/src/ng-add/files/src/app/first-time/email-link/email-link.component.scss.template +2 -0
  182. package/src/ng-add/files/src/app/first-time/email-link/email-link.component.spec.ts.template +56 -0
  183. package/src/ng-add/files/src/app/first-time/email-link/email-link.component.ts.template +91 -0
  184. package/src/ng-add/files/src/app/first-time/first-time-routing.spec.ts.template +11 -7
  185. package/src/ng-add/files/src/app/first-time/landing/hero/hero.component.html.template +19 -7
  186. package/src/ng-add/files/src/app/first-time/landing/hero/hero.component.scss.template +51 -0
  187. package/src/ng-add/files/src/app/first-time/landing/hero/hero.component.ts.template +44 -5
  188. package/src/ng-add/files/src/app/first-time/landing/landing.component.html.template +2 -1
  189. package/src/ng-add/files/src/app/first-time/landing/landing.component.scss.template +12 -8
  190. package/src/ng-add/files/src/app/first-time/landing/landing.component.spec.ts.template +33 -10
  191. package/src/ng-add/files/src/app/first-time/landing/landing.component.ts.template +6 -19
  192. package/src/ng-add/files/src/app/first-time/login/login.component.html.template +58 -6
  193. package/src/ng-add/files/src/app/first-time/login/login.component.scss.template +151 -22
  194. package/src/ng-add/files/src/app/first-time/login/login.component.spec.ts.template +30 -32
  195. package/src/ng-add/files/src/app/first-time/login/login.component.ts.template +85 -31
  196. package/src/ng-add/files/src/app/first-time/onboarding/onboarding.component.spec.ts.template +4 -2
  197. package/src/ng-add/files/src/app/first-time/onboarding/onboarding.component.ts.template +1 -1
  198. package/src/ng-add/files/src/app/main/account-profile/account-profile.component.html.template +12 -0
  199. package/src/ng-add/files/src/app/main/account-profile/account-profile.component.scss.template +39 -0
  200. package/src/ng-add/files/src/app/main/account-profile/account-profile.component.spec.ts.template +68 -0
  201. package/src/ng-add/files/src/app/main/account-profile/account-profile.component.ts.template +20 -0
  202. package/src/ng-add/files/src/app/main/account-profile/delete-guest-card/delete-guest-card.component.html.template +24 -0
  203. package/src/ng-add/files/src/app/main/account-profile/delete-guest-card/delete-guest-card.component.scss.template +50 -0
  204. package/src/ng-add/files/src/app/main/account-profile/delete-guest-card/delete-guest-card.component.spec.ts.template +65 -0
  205. package/src/ng-add/files/src/app/main/account-profile/delete-guest-card/delete-guest-card.component.ts.template +59 -0
  206. package/src/ng-add/files/src/app/main/account-profile/guest-deletion-dialog.component.ts.template +51 -0
  207. package/src/ng-add/files/src/app/main/account-profile/profile-details-card/profile-details-card.component.html.template +50 -0
  208. package/src/ng-add/files/src/app/main/account-profile/profile-details-card/profile-details-card.component.scss.template +137 -0
  209. package/src/ng-add/files/src/app/main/account-profile/profile-details-card/profile-details-card.component.spec.ts.template +57 -0
  210. package/src/ng-add/files/src/app/main/account-profile/profile-details-card/profile-details-card.component.ts.template +59 -0
  211. package/src/ng-add/files/src/app/main/account-profile/sign-in-methods-card/sign-in-methods-card.component.html.template +133 -0
  212. package/src/ng-add/files/src/app/main/account-profile/sign-in-methods-card/sign-in-methods-card.component.scss.template +207 -0
  213. package/src/ng-add/files/src/app/main/account-profile/sign-in-methods-card/sign-in-methods-card.component.spec.ts.template +74 -0
  214. package/src/ng-add/files/src/app/main/account-profile/sign-in-methods-card/sign-in-methods-card.component.ts.template +130 -0
  215. package/src/ng-add/files/src/app/main/home/home.component.spec.ts.template +4 -5
  216. package/src/ng-add/files/src/app/main/home/home.component.ts.template +1 -6
  217. package/src/ng-add/files/src/app/shared/guest-warning-bar/guest-warning-bar.component.html.template +15 -0
  218. package/src/ng-add/files/src/app/shared/guest-warning-bar/guest-warning-bar.component.scss.template +79 -0
  219. package/src/ng-add/files/src/app/shared/guest-warning-bar/guest-warning-bar.component.spec.ts.template +59 -0
  220. package/src/ng-add/files/src/app/shared/guest-warning-bar/guest-warning-bar.component.ts.template +44 -0
  221. package/src/ng-add/files/src/app/shared/navbar/navbar.component.html.template +45 -15
  222. package/src/ng-add/files/src/app/shared/navbar/navbar.component.scss.template +103 -19
  223. package/src/ng-add/files/src/app/shared/navbar/navbar.component.spec.ts.template +73 -9
  224. package/src/ng-add/files/src/app/shared/navbar/navbar.component.ts.template +46 -18
  225. package/src/ng-add/files/src/environments/environment.prod.ts.template +1 -0
  226. package/src/ng-add/files/src/environments/environment.test.ts.template +1 -0
  227. package/src/ng-add/files/src/environments/environment.ts.template +1 -1
  228. package/src/ng-add/files/tsconfig.spec.json.template +3 -1
  229. package/src/ng-add/index.js +7 -0
  230. package/src/ng-add/index.js.map +1 -1
  231. package/src/shared/entity-registry.d.ts +8 -0
  232. package/src/shared/entity-registry.js +28 -0
  233. package/src/shared/entity-registry.js.map +1 -0
  234. package/tsconfig.json +2 -2
  235. package/.agents/skills/publish-npm/SKILL.md +0 -37
  236. package/.agents/skills/publish-npm/eval.yaml +0 -32
  237. package/.agents/skills/publish-npm/fixtures/package-v21.json.template +0 -8
  238. package/.husky/commit-msg +0 -1
  239. package/.husky/pre-commit +0 -1
  240. package/.t4g/agent-memory.db +0 -0
  241. package/src/component/index_spec.d.ts +0 -1
  242. package/src/component/index_spec.js +0 -68
  243. package/src/component/index_spec.js.map +0 -1
  244. package/src/entity/index_spec.d.ts +0 -1
  245. package/src/entity/index_spec.js +0 -153
  246. package/src/entity/index_spec.js.map +0 -1
  247. package/src/guard/index_spec.d.ts +0 -1
  248. package/src/guard/index_spec.js +0 -64
  249. package/src/guard/index_spec.js.map +0 -1
  250. package/src/ng-add/files/bigquery/scripts/export_entities.py.template +0 -143
  251. package/src/ng-add/files/bigquery/scripts/run_query.py.template +0 -167
  252. package/src/ng-add/files/src/app/core/firebase/cached-listeners.service.ts.template +0 -494
  253. package/src/ng-add/files/src/app/core/firebase/database.service.ts.template +0 -56
  254. package/src/ng-add/files/src/app/core/firebase/firebase.mock.service.ts.template +0 -366
  255. package/src/ng-add/files/src/app/core/firebase/firebase.service.ts.template +0 -342
  256. package/src/ng-add/files/src/app/core/firebase/simulate-load.spec.ts.template +0 -104
  257. package/src/ng-add/files/src/app/core/firebase/simulate-stream.spec.ts.template +0 -127
  258. package/src/ng-add/files/src/app/core/firebase/simulation.mock.ts.template +0 -38
  259. package/src/ng-add/files/src/app/core/firebase/stream-multiplexer.ts.template +0 -445
  260. package/src/ng-add/files/src/app/core/logging/logging.service.spec.ts.template +0 -118
  261. package/src/ng-add/files/src/app/core/logging/logging.service.ts.template +0 -168
  262. package/src/ng-add/files/src/app/core/store/app.model.ts.template +0 -21
  263. package/src/ng-add/files/src/app/core/store/app.store.spec.ts.template +0 -920
  264. package/src/ng-add/files/src/app/core/store/app.store.ts.template +0 -1317
  265. package/src/ng-add/files/src/app/core/store/batch-write.firebase.service.ts.template +0 -58
  266. package/src/ng-add/files/src/app/core/store/batch-write.mock.service.ts.template +0 -105
  267. package/src/ng-add/files/src/app/core/store/batch-write.service.ts.template +0 -126
  268. package/src/ng-add/files/src/app/shared/redeployment-warning/redeployment-warning.component.html.template +0 -9
  269. package/src/ng-add/files/src/app/shared/redeployment-warning/redeployment-warning.component.scss.template +0 -46
  270. package/src/ng-add/files/src/app/shared/redeployment-warning/redeployment-warning.component.spec.ts.template +0 -69
  271. package/src/ng-add/files/src/app/shared/redeployment-warning/redeployment-warning.component.ts.template +0 -39
  272. package/src/ng-add/files/src/app/shared/redeployment-warning/redeployment-warning.service.spec.ts.template +0 -122
  273. package/src/ng-add/files/src/app/shared/redeployment-warning/redeployment-warning.service.ts.template +0 -88
@@ -1,494 +0,0 @@
1
- import { Inject, Injectable, WritableSignal, inject, DestroyRef, computed } from '@angular/core';
2
- import { toObservable } from '@angular/core/rxjs-interop';
3
- import { Subject, Observable, merge, forkJoin, of, from, pipe } from 'rxjs';
4
- import { startWith, pairwise, share, tap, pluck, mergeMap, filter, takeUntil, skipUntil, buffer, skip, switchMap, map, take } from 'rxjs/operators';
5
- import { setEntities, setEntity, removeEntities, SelectEntityId } from '@ngrx/signals/entities';
6
- import { EntityLoadQuery, EntityStreamQuery, entityInQueryResults } from '../store/app.store';
7
- import { QueryParams, QueryOptions, AnyEntity } from '../store/app.model';
8
- import { DocumentChange } from '@angular/fire/firestore';
9
- import { DATABASE_SERVICE, DatabaseService } from './database.service';
10
- import { StreamMultiplexer } from './stream-multiplexer';
11
- import { getLogger } from '../logging/logging.service';
12
-
13
- const queryLogger = getLogger('query');
14
-
15
- const selectId: SelectEntityId<AnyEntity> = (entity) => entity.__id;
16
-
17
- export interface CachedConnection {
18
- queryKey: string;
19
- registeredSet: Set<DestroyRef>;
20
- }
21
-
22
-
23
- /**
24
- * CachedListenersService manages database connections and their lifecycles to
25
- * ensure optimal performance, prevent memory leaks, and solve the N+1 query problem.
26
- *
27
- * Responsibilities:
28
- * 1. **Listener Pooling**: Deduplicates active Firestore snapshot listeners. If multiple
29
- * components request a stream for the exact same query, only one actual database
30
- * connection is opened.
31
- * 2. **Reference Counting & Lifecycle Management**: Tracks which components are using
32
- * which stream via their Angular `DestroyRef`. When a component is destroyed, its
33
- * reference is removed.
34
- * 3. **Graceful Teardown**: Implements a 5-second grace period before fully closing a
35
- * database connection after its last reference drops. This prevents UI flicker and
36
- * unnecessary DB reads if the user navigates away and immediately back.
37
- * 4. **Load Time Tracking (One-shot Loads)**: Tracks `lastLoadTime` for general queries
38
- * and precise `entityLoadTime` for optimized batch equality queries. This enables
39
- * incremental (delta-only) fetching, drastically reducing bandwidth by only fetching
40
- * entities modified since the last load.
41
- */
42
- @Injectable({
43
- providedIn: 'root',
44
- })
45
- export class CachedListenersService {
46
- /** Cached connections by loadKey. */
47
- private connectionByQueryKey: Record<string, CachedConnection> = {};
48
-
49
- /** Active multiplexers by collection.field */
50
- private streamMultiplexers = new Map<string, StreamMultiplexer>();
51
-
52
- /** Close connection events. */
53
- private closeConnection$: Subject<string> = new Subject<string>();
54
-
55
-
56
- /** Load state across the app by queryKey. Stores last load time in milliseconds. */
57
- private lastLoadTime: Record<string, number> = {};
58
-
59
- /** Per-entity load times for optimized equality queries. Key: "collection.field:value" */
60
- private entityLoadTime: Record<string, number> = {};
61
-
62
- getEntityLoadTime(collection: string, field: string, value: string): number {
63
- return this.entityLoadTime[`${collection}.${field}:${value}`] || -1;
64
- }
65
-
66
- setEntityLoadTime(collection: string, field: string, value: string, time: number): void {
67
- this.entityLoadTime[`${collection}.${field}:${value}`] = time;
68
- }
69
-
70
- /** Define a unique key for each connection. */
71
- private getQueryKey(collection: string, queryParams: QueryParams, queryOptions: QueryOptions): string {
72
- let queryOptionsString = '';
73
- if (queryOptions) {
74
- if (queryOptions.orderBy) {
75
- queryOptionsString = queryOptionsString.concat(`orderBy${queryOptions.orderBy}`);
76
- }
77
- if (queryOptions.limit) {
78
- queryOptionsString = queryOptionsString.concat(`limit${queryOptions.limit}`);
79
- }
80
- if (queryOptions.startAt) {
81
- queryOptionsString = queryOptionsString.concat(`startAt${queryOptions.startAt}`);
82
- }
83
- if (queryOptions.startAfter) {
84
- queryOptionsString = queryOptionsString.concat(`startAfter${queryOptions.startAfter}`);
85
- }
86
- if (queryOptions.endAt) {
87
- queryOptionsString = queryOptionsString.concat(`endAt${queryOptions.endAt}`);
88
- }
89
- if (queryOptions.endBefore) {
90
- queryOptionsString = queryOptionsString.concat(`endBefore${queryOptions.endBefore}`);
91
- }
92
- }
93
- return `${collection}.${queryParams.sort()}.${queryOptionsString}`;
94
- }
95
-
96
- /**
97
- * Clear cached connection states and last load times.
98
- * NOTE: This is strictly intended for resetting state between test cases
99
- * in unit/integration tests and should not be used in dev/production environments
100
- * to avoid unexpected stream disconnections.
101
- */
102
- clearCache(): void {
103
- for (const key of Object.keys(this.connectionByQueryKey)) {
104
- const connection = this.connectionByQueryKey[key];
105
- if (connection) {
106
- this.closeConnection$.next(key);
107
- connection.registeredSet.clear();
108
- }
109
- }
110
- this.connectionByQueryKey = {};
111
-
112
- for (const multiplexer of this.streamMultiplexers.values()) {
113
- multiplexer.teardownAll();
114
- }
115
- this.streamMultiplexers.clear();
116
- this.lastLoadTime = {};
117
- this.entityLoadTime = {};
118
- }
119
-
120
- /** Return whether a stream exists for this query. */
121
- isStreamForQuery(collection: string, queryParams: QueryParams, queryOptions: QueryOptions): boolean {
122
- const queryKey = this.getQueryKey(collection, queryParams, queryOptions);
123
- return !!this.connectionByQueryKey[queryKey];
124
- }
125
-
126
- /** Return whether a specific ID is currently being streamed by a multiplexer. */
127
- isIdStreamed(collection: string, field: string, id: string): boolean {
128
- const multiplexerKey = `${collection}.${field}`;
129
- const multiplexer = this.streamMultiplexers.get(multiplexerKey);
130
- return multiplexer ? multiplexer.isIdActive(id) : false;
131
- }
132
-
133
- /** Get the last load time for a particular query. */
134
- getLastLoadTime(collection: string, queryParams: QueryParams, queryOptions: QueryOptions): number {
135
- // If there are queryOptions, we don't support saving load times
136
- if (queryOptions && Object.keys(queryOptions).length > 0) return -1;
137
-
138
- const queryKey = this.getQueryKey(collection, queryParams, queryOptions);
139
- return this.lastLoadTime[queryKey] || -1;
140
- }
141
-
142
- /** Set the last load time for a particular query. */
143
- setLastLoadTime(collection: string, queryParams: QueryParams, queryOptions: QueryOptions, time: number): void {
144
- // If there are queryOptions, we don't support saving load times
145
- if (queryOptions && Object.keys(queryOptions).length > 0) return;
146
-
147
- const queryKey = this.getQueryKey(collection, queryParams, queryOptions);
148
- this.lastLoadTime[queryKey] = time;
149
- }
150
-
151
- /** Gets a cached connection if one exists. */
152
- private getConnection(collection: string, queryParams: QueryParams, queryOptions: QueryOptions): CachedConnection {
153
- const queryKey = this.getQueryKey(collection, queryParams, queryOptions);
154
- return this.connectionByQueryKey[queryKey];
155
- }
156
-
157
- /**
158
- * Main function called by the outside.
159
- */
160
- public async processStreamQuery<T extends AnyEntity>(
161
- collection: string,
162
- store,
163
- queryParams: QueryParams,
164
- queryOptions: QueryOptions,
165
- injector,
166
- streamQueries?: (entity: T) => EntityStreamQuery<AnyEntity>[],
167
- options?: {
168
- loading?: WritableSignal<boolean>,
169
- },
170
- ): Promise<CachedConnection> {
171
- queryLogger.log(`[CachedListenersService] processStreamQuery called for collection: '${collection}', query:`, JSON.stringify(queryParams));
172
- // console.log("PROCESS QUERY: " + this.getQueryKey(collection, queryParams, queryOptions));
173
-
174
- // Get destroyRef for the component that called processStreamQuery
175
- // (which will be used to determine when to trigger unsubscribe)
176
- const destroyRef = injector.get(DestroyRef);
177
-
178
- // get connection and process the immediate query
179
- let connection = this.getConnection(collection, queryParams, queryOptions);
180
-
181
- if (connection) {
182
- // if the connection already exists, don't need to create a new connection,
183
- // but may need to add the DestroyRef if it doesn't already exist
184
- if (!connection.registeredSet.has(destroyRef)) {
185
- connection.registeredSet.add(destroyRef);
186
- }
187
- } else {
188
- // if the connection does not exist, create it and initialize the
189
- // registeredSet to include destroyRef
190
- // this function also will subscribe and link to the store
191
- connection = this.createConnection<T>(collection, store, queryParams, queryOptions, destroyRef);
192
- this.connectionByQueryKey[connection.queryKey] = connection;
193
- }
194
-
195
- // Unregister from the connection when the component is destroyed
196
- // Disconnects the "virtual" connection. If this was the only DestroyRef,
197
- // then actually unsubscribe
198
- destroyRef.onDestroy(() => {
199
- // Add a 5-second delay so we don't have to reconnect multiple times
200
- // if the next view happens to use the same stream
201
- setTimeout(() => {
202
- // If the destroyRef is not in the set, it means this connection was already
203
- // cleared/cleaned up (e.g., via clearCache() in tests), so we bail out.
204
- if (!connection.registeredSet.has(destroyRef)) {
205
- return;
206
- }
207
-
208
- connection.registeredSet.delete(destroyRef);
209
- if (connection.registeredSet.size === 0) {
210
- // Verify that this connection is still the active connection in the cache map.
211
- // This is essential to prevent stale callbacks (e.g. from a previous test case
212
- // that was cleared via clearCache()) from overwriting a new active connection
213
- // in the cache or triggering premature disconnections.
214
- if (this.connectionByQueryKey[connection.queryKey] === connection) {
215
- this.closeConnection$.next(connection.queryKey);
216
- this.connectionByQueryKey[connection.queryKey] = undefined;
217
- }
218
- }
219
- }, 5000);
220
- });
221
-
222
- // For every new entity on the stream, process the nested streamQueries
223
- if (streamQueries) {
224
- // get the entities we're streaming as a signal. we do it here rather than
225
- // using the firestore stream so that we can always get the latest version
226
- // without needing to multicast the original stream to all future components
227
- // querying for the stream
228
- const streamEntities = computed(() => {
229
- return store.selectEntities(queryParams, queryOptions);
230
- });
231
-
232
- // convert to an observable, convert to the changes, then subscribe
233
- // note: we do not need takeUntil for unsubscribing because toObservable will
234
- // unsubscribe once the injector context (passed in from the component/container) is destroyed
235
- toObservable(streamEntities, { injector }).pipe(
236
- // convert to entityMap to more easily compare
237
- map((entities) => {
238
- const entityMap = {};
239
- for (const entity of entities) {
240
- entityMap[entity.__id] = entity;
241
- }
242
- return entityMap;
243
- }),
244
- // compare current with prior including the first
245
- startWith({}),
246
- pairwise(),
247
- // get the changedEntities
248
- map(([prevEntities, currEntities]) => {
249
- const changedEntities = [];
250
- for (const key in currEntities) {
251
- if (!(key in prevEntities)) {
252
- // the entity was added
253
- changedEntities.push({
254
- type: 'added',
255
- doc: currEntities[key],
256
- });
257
- } else if (currEntities[key]['_deleted']) {
258
- // the entity was removed
259
- changedEntities.push({
260
- type: 'removed',
261
- doc: currEntities[key],
262
- });
263
- } else if (currEntities[key]['_updatedAt'] !== prevEntities[key]['_updatedAt']) {
264
- // the entity was modified
265
- changedEntities.push({
266
- type: 'modified',
267
- doc: currEntities[key],
268
- });
269
- }
270
- }
271
-
272
- return changedEntities;
273
- }),
274
- // We don't need the removed ones for nested streamQueries (but I just
275
- // included it above for debugging purposes so we can see all changes)
276
- map((changes) => changes.filter((c) => c.type !== 'removed')),
277
- filter((changes) => changes.length > 0),
278
- ).subscribe(async (changes) => {
279
- // create a matrix of queries, each row corresponding to a given entity
280
- const queriesByEntity = changes.map((change) => streamQueries(change.doc));
281
-
282
- // transpose the matrix so each row corresponds to all queries for the same query type
283
- const queriesByQueryType = queriesByEntity[0].map((_, colIndex) => queriesByEntity.map((row) => row[colIndex]));
284
-
285
- // Process all query types concurrently
286
- await Promise.all(queriesByQueryType.map(async (queriesForOneType) => {
287
- // Seeing if we can optimize by collapsing equality queries into 'in' queries
288
- const optimizedQueries = EntityStreamQuery.optimize(queriesForOneType);
289
-
290
- // Process queries concurrently using Promise.all
291
- await Promise.all(optimizedQueries.filter((q) => !!q).map(async (query) => {
292
- const isSimpleChild = (!query.queryOptions || Object.keys(query.queryOptions).length === 0) &&
293
- query.queryParams.length === 1 &&
294
- (query.queryParams[0][1] === '==' || query.queryParams[0][1] === 'in');
295
-
296
- if (isSimpleChild) {
297
- const childField = query.queryParams[0][0];
298
- const childOp = query.queryParams[0][1];
299
- const childVal = query.queryParams[0][2];
300
- const childIds = childOp === 'in' ? childVal : [childVal];
301
- queryLogger.log(`[CachedListenersService] Nested query optimized to simple stream query: ${childField} in [${childIds}]`);
302
- await this.processSimpleStreamQuery(query.collection, childField, childIds, query.store, injector, query.streamQueries, { loading: options?.loading });
303
- } else {
304
- queryLogger.log(`[CachedListenersService] Nested query falling back to standard stream query:`, JSON.stringify(query.queryParams));
305
- await this.processStreamQuery(query.collection, query.store, query.queryParams, query.queryOptions, injector, query.streamQueries, { loading: options?.loading });
306
- }
307
- }));
308
- }));
309
- });
310
- } else {
311
- // We'll turn off the loading indicator the first time there is a query that doesn't have nested queries
312
- // (ideally we'd want to turn if off after each of the streams have gotten their first entities, but I
313
- // don't think we can do that easily and this won't be too off)
314
- options?.loading?.set(false);
315
- }
316
-
317
- return connection;
318
- }
319
-
320
- /**
321
- * Optimized fast-path for simple streaming queries (e.g., `id in [1, 2, 3]`).
322
- * Instead of managing distinct complex RxJS subscription chains for every component, this delegates
323
- * ID registration to a centralized `StreamMultiplexer` (per collection/field).
324
- *
325
- * It also handles nested `streamQueries` (e.g. streaming a post's author) by listening to changes
326
- * to the parent entities, diffing them (`pairwise`), and setting up streams for the new children.
327
- */
328
- public async processSimpleStreamQuery<T extends AnyEntity>(
329
- collection: string,
330
- field: string,
331
- ids: string[],
332
- store: any,
333
- injector: any,
334
- streamQueries?: (entity: T) => EntityStreamQuery<AnyEntity>[],
335
- options?: { loading?: WritableSignal<boolean> },
336
- ): Promise<void> {
337
- queryLogger.log(`[CachedListenersService] processSimpleStreamQuery called for collection: '${collection}', field: '${field}', ids: [${ids}]`);
338
-
339
- if (!ids || ids.length === 0) {
340
- options?.loading?.set(false);
341
- return;
342
- }
343
-
344
- const destroyRef = injector.get(DestroyRef);
345
- const multiplexerKey = `${collection}.${field}`;
346
-
347
- let multiplexer = this.streamMultiplexers.get(multiplexerKey);
348
- if (!multiplexer) {
349
- multiplexer = new StreamMultiplexer(collection, field, this.db, store);
350
- this.streamMultiplexers.set(multiplexerKey, multiplexer);
351
- }
352
- multiplexer.registerIds(ids, destroyRef);
353
-
354
- if (streamQueries) {
355
- // 1. We select the entities from the store.
356
- // Because `app.store.ts` caches identical array references, `filteredSignal` will NOT trigger
357
- // spurious emissions if the underlying data has not actually changed.
358
- const filteredSignal = computed(() => {
359
- return store.selectEntities([[field, 'in', ids]], {});
360
- });
361
-
362
- // 2. We convert the signal to an observable to perform pairwise diffing.
363
- // This is necessary because if a parent entity is added or modified, we need to re-evaluate
364
- // its nested `streamQueries` (e.g., if a post's authorId changes, we must query the new author).
365
- toObservable(filteredSignal, { injector }).pipe(
366
- map((entities) => {
367
- const entityMap = {};
368
- for (const entity of entities) {
369
- entityMap[entity.__id] = entity;
370
- }
371
- return entityMap;
372
- }),
373
- startWith({}),
374
- pairwise(),
375
- map(([prevEntities, currEntities]) => {
376
- // 3. Diff the current entities against the previous entities to determine exactly
377
- // what was added, removed, or modified. We rely on the `_deleted` flag and `_updatedAt`.
378
- const changedEntities = [];
379
- for (const key in currEntities) {
380
- if (!(key in prevEntities)) {
381
- changedEntities.push({ type: 'added', doc: currEntities[key] });
382
- } else if (currEntities[key]['_deleted']) {
383
- changedEntities.push({ type: 'removed', doc: currEntities[key] });
384
- } else if (currEntities[key]['_updatedAt'] !== prevEntities[key]['_updatedAt']) {
385
- changedEntities.push({ type: 'modified', doc: currEntities[key] });
386
- }
387
- }
388
- return changedEntities;
389
- }),
390
- map((changes) => changes.filter((c) => c.type !== 'removed')),
391
- filter((changes) => changes.length > 0),
392
- ).subscribe(async (changes) => {
393
- // 4. For every changed entity, evaluate its nested stream queries.
394
- const queriesByEntity = changes.map((change) => streamQueries(change.doc));
395
- if (queriesByEntity.length === 0 || queriesByEntity[0].length === 0) return;
396
-
397
- // 5. Transpose the matrix so each row corresponds to all queries of the same query type.
398
- // This allows us to group and optimize queries (e.g., combining 5 single equality queries into 1 'in' query).
399
- const queriesByQueryType = queriesByEntity[0].map((_, colIndex) => queriesByEntity.map((row) => row[colIndex]));
400
-
401
- await Promise.all(queriesByQueryType.map(async (queriesForOneType) => {
402
- const optimizedQueries = EntityStreamQuery.optimize(queriesForOneType);
403
- await Promise.all(optimizedQueries.filter((q) => !!q).map(async (query) => {
404
- const isSimpleChild = (!query.queryOptions || Object.keys(query.queryOptions).length === 0) &&
405
- query.queryParams.length === 1 &&
406
- (query.queryParams[0][1] === '==' || query.queryParams[0][1] === 'in');
407
-
408
- if (isSimpleChild) {
409
- const childField = query.queryParams[0][0];
410
- const childOp = query.queryParams[0][1];
411
- const childVal = query.queryParams[0][2];
412
- const childIds = childOp === 'in' ? childVal : [childVal];
413
- queryLogger.log(`[CachedListenersService] Nested query optimized to simple stream query: ${childField} in [${childIds}]`);
414
- await this.processSimpleStreamQuery(query.collection, childField, childIds, query.store, injector, query.streamQueries, { loading: options?.loading });
415
- } else {
416
- queryLogger.log(`[CachedListenersService] Nested query falling back to standard stream query:`, JSON.stringify(query.queryParams));
417
- await this.processStreamQuery(query.collection, query.store, query.queryParams, query.queryOptions, injector, query.streamQueries, { loading: options?.loading });
418
- }
419
- }));
420
- }));
421
- });
422
- }
423
-
424
- // We'll turn off the loading indicator right away since we don't have a good way
425
- // to know when all individual streams are initialized yet.
426
- options?.loading?.set(false);
427
- }
428
-
429
- private createConnection<T>(collection: string, store: any, queryParams: QueryParams, queryOptions: QueryOptions, destroyRef: DestroyRef): CachedConnection {
430
- // console.log("CONNECT " + this.getQueryKey(collection, queryParams, queryOptions));
431
-
432
- // ------------ DEFINE OBSERVABLES FOR DISCONNECTING ------------------------------
433
-
434
- const queryKey = this.getQueryKey(collection, queryParams, queryOptions);
435
- const disconnectObs$ = this.closeConnection$.pipe(
436
- filter((qk) => qk === queryKey),
437
- take(1),
438
- // tap(a => { console.log("DISCONNECT: " + queryKey) }),
439
- share(),
440
- );
441
-
442
- // ------------ HANDLE PATCHING TO STORE ------------------------------------------
443
-
444
- // Handle patching to the store
445
- this.db.streamEntitiesChanges(collection, queryParams, queryOptions).pipe(
446
- takeUntil(disconnectObs$),
447
- ).subscribe((fbPayload: Array<{ type: string, docData: AnyEntity }>) => {
448
- // Handle all the added entities
449
- const entitiesToAdd = fbPayload
450
- .filter((dc) => dc.type === 'added' && !dc.docData['_deleted'])
451
- .map((dc) => dc.docData);
452
-
453
- // Handle all the modified entities
454
- const entitiesToModify = fbPayload
455
- .filter((dc) => dc.type === 'modified' && !dc.docData['_deleted'])
456
- .map((dc) => dc.docData);
457
-
458
- // Handle all the removed entities
459
- const entitiesToRemove = fbPayload
460
- .filter((dc) => dc.type === 'modified' && dc.docData['_deleted'])
461
- .map((dc) => dc.docData['__id']);
462
-
463
- // Handle changes of the 'removed' type. In general, firebase 'removed'
464
- // could be due to no longer matching the stream query rather than being
465
- // deleted from the DB. this is why we use soft deletes (set _deleted to true).
466
- // We could still get 'removed' entries if there are manual deletions in the
467
- // database or when firestore is syncing updates after temporarily using
468
- // entities cached to IndexedDB.
469
- const entitiesToModify2 = fbPayload
470
- .filter((dc) => dc.type === 'removed' && !entityInQueryResults(dc.docData, queryParams, queryOptions))
471
- .map((dc) => dc.docData);
472
-
473
- const entitiesToRemove2 = fbPayload
474
- .filter((dc) => dc.type === 'removed' && entityInQueryResults(dc.docData, queryParams, queryOptions))
475
- .map((dc) => dc.docData['__id']);
476
-
477
- // Patch all the changes to the store
478
- store.handleStreamChanges(
479
- entitiesToAdd,
480
- [...entitiesToModify, ...entitiesToModify2],
481
- [...entitiesToRemove, ...entitiesToRemove2],
482
- );
483
- });
484
-
485
- return {
486
- queryKey: this.getQueryKey(collection, queryParams, queryOptions),
487
- registeredSet: new Set<DestroyRef>([destroyRef]),
488
- };
489
- }
490
-
491
- constructor(
492
- @Inject(DATABASE_SERVICE) private db: DatabaseService,
493
- ) { }
494
- }
@@ -1,56 +0,0 @@
1
- import { InjectionToken, Injector } from '@angular/core';
2
- import { QueryParams, QueryOptions, AnyEntity } from '../store/app.model';
3
- import { Observable } from 'rxjs';
4
- import { User } from '@angular/fire/auth';
5
- import { WriteBatchI } from '../store/batch-write.service';
6
-
7
- export interface DatabaseService {
8
- createId(): string;
9
- afUser(): Observable<{ uid: string, email: string, displayName: string, photoURL: string } | null>;
10
- login(providerId: string, scope?: string): any;
11
- loginLink(error): void;
12
- logout(): any;
13
- streamEntity<T>(collectionName: string, id: string): Observable<T>;
14
- streamEntities<T>(collectionName, queryParams, queryOptions?): Observable<T[]>;
15
- streamEntitiesChanges<T>(collectionName, queryParams, queryOptions?): Observable<{
16
- type: string;
17
- docData: T;
18
- }[]>;
19
- getEntity<T>(collectionName: string, id: string): Promise<T>;
20
- getEntities<S>(
21
- collectionName: string,
22
- queryParams: [string, string, any][],
23
- queryOptions?: { [index: string]: any },
24
- ): Promise<S[]>;
25
- count(
26
- collectionName: string,
27
- queryParams: QueryParams,
28
- queryOptions?: QueryOptions,
29
- ): Promise<number>;
30
- aggregate<S extends { [k: string]: number }>(
31
- collectionName: string,
32
- queryParams: QueryParams,
33
- queryOptions: QueryOptions,
34
- aggregateParams: { [K in keyof S]: [string] | [string, string] },
35
- ): Promise<{ [K in keyof S]: number }>;
36
- addEntity(
37
- collectionName: string,
38
- entity: AnyEntity,
39
- batch?: WriteBatchI,
40
- ): Promise<any>;
41
- updateEntity(
42
- collectionName: string,
43
- id: string,
44
- changes: Partial<AnyEntity>,
45
- batch?: WriteBatchI,
46
- ): Promise<any>;
47
- removeEntity(
48
- collectionName: string,
49
- id: string,
50
- batch?: WriteBatchI,
51
- ): Promise<any>;
52
- incrementEntityField(collectionName, id, field, delta): Promise<void>;
53
- }
54
-
55
- // InjectionToken that can be swapped out for
56
- export const DATABASE_SERVICE = new InjectionToken<DatabaseService>('DatabaseService');