@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.
- package/CHANGELOG.md +44 -0
- package/README.md +266 -1
- package/package.json +34 -7
- package/src/component/files/__name@dasherize__/__name@dasherize__.component.spec.ts.template +4 -5
- package/src/component/files/__name@dasherize__/__name@dasherize__.component.ts.template +1 -1
- package/src/entity/files/__name@dasherize__/__name@dasherize__.mock.ts.template +16 -7
- package/src/entity/files/__name@dasherize__/__name@dasherize__.model.ts.template +13 -6
- package/src/entity/files/__name@dasherize__/__name@dasherize__.store.ts.template +18 -10
- package/src/entity/index.js +61 -49
- package/src/entity/index.js.map +1 -1
- package/src/entity/schema.json +4 -0
- package/src/guard/files/__name@dasherize__.guard.spec.ts.template +0 -1
- package/src/ng-add/files/.github/workflows/angular-github-ci.yml.template +3 -0
- package/src/ng-add/files/.gitignore.template +5 -0
- package/src/ng-add/files/analytics/datasets.js.template +206 -0
- package/src/ng-add/files/analytics/entity_sources.js.template +58 -0
- package/src/ng-add/files/analytics/entity_sources.test.js.template +57 -0
- package/src/ng-add/files/analytics/lib/api_query.js.template +87 -0
- package/src/ng-add/files/analytics/lib/api_query.test.js.template +84 -0
- package/src/ng-add/files/analytics/lib/bigquery_query_compatibility.test.js.template +53 -0
- package/src/ng-add/files/analytics/lib/dataset_schema.js.template +53 -0
- package/src/ng-add/files/analytics/lib/dataset_schema.test.js.template +34 -0
- package/src/ng-add/files/analytics/lib/entity_sync.js.template +397 -0
- package/src/ng-add/files/analytics/lib/entity_sync.test.js.template +212 -0
- package/src/ng-add/files/analytics/lib/identifier_salt.js.template +57 -0
- package/src/ng-add/files/analytics/lib/identifier_salt.test.js.template +36 -0
- package/src/ng-add/files/analytics/lib/snapshot_files.js.template +46 -0
- package/src/ng-add/files/analytics/lib/snapshot_files.test.js.template +67 -0
- package/src/ng-add/files/analytics/lib/sqlite.js.template +92 -0
- package/src/ng-add/files/analytics/lib/upload_entities.js.template +81 -0
- package/src/ng-add/files/analytics/lib/upload_entities.test.js.template +86 -0
- package/src/ng-add/files/analytics/proxy.conf.json.template +7 -0
- package/src/ng-add/files/analytics/scripts/refresh_snapshot.js.template +518 -0
- package/src/ng-add/files/analytics/scripts/start.js.template +88 -0
- package/src/ng-add/files/analytics/server/server.js.template +212 -0
- package/src/ng-add/files/angular.json.template +80 -1
- package/src/ng-add/files/bigquery/queries/active_time_by_route.sql.template +27 -8
- package/src/ng-add/files/bigquery/queries/active_user_windows.sql.template +67 -0
- package/src/ng-add/files/bigquery/queries/dashboard_route_visits.sql.template +47 -0
- package/src/ng-add/files/bigquery/queries/data_quality.sql.template +323 -0
- package/src/ng-add/files/bigquery/queries/onboarding_funnel.sql.template +512 -0
- package/src/ng-add/files/bigquery/queries/onboarding_stage_observations.sql.template +134 -0
- package/src/ng-add/files/bigquery/queries/weekly_retention_cohorts.sql.template +90 -0
- package/src/ng-add/files/bigquery/scripts/export_entities.js.template +120 -0
- package/src/ng-add/files/bigquery/scripts/init_views.js.template +57 -0
- package/src/ng-add/files/bigquery/scripts/run_query.js.template +141 -0
- package/src/ng-add/files/bigquery/views/events_flat.sql.template +27 -12
- package/src/ng-add/files/bigquery/views/logs_latest.sql.template +16 -3
- package/src/ng-add/files/docs-infra/analytics-guide.md.template +270 -25
- package/src/ng-add/files/docs-infra/analytics-workbench-guide.md.template +307 -0
- package/src/ng-add/files/docs-infra/authentication-architecture.md.template +300 -0
- package/src/ng-add/files/docs-infra/email-infrastructure.md.template +43 -0
- package/src/ng-add/files/docs-infra/firestore-index-checker.md.template +87 -0
- package/src/ng-add/files/docs-infra/infrastructure-guide.md.template +123 -38
- package/src/ng-add/files/docs-infra/load-system-architecture.md.template +15 -1
- package/src/ng-add/files/docs-infra/querying-strategy.md.template +14 -0
- package/src/ng-add/files/docs-infra/stream-system-architecture.md.template +21 -7
- package/src/ng-add/files/eslint.config.js.template +22 -3
- package/src/ng-add/files/firebase.json.template +6 -0
- package/src/ng-add/files/firestore.indexes.json.template +23 -0
- package/src/ng-add/files/firestore.rules.spec.ts.template +84 -15
- package/src/ng-add/files/firestore.rules.template +29 -17
- package/src/ng-add/files/functions/.gitignore.template +3 -0
- package/src/ng-add/files/functions/package.json.template +13 -0
- package/src/ng-add/files/functions/src/email.ts.template +23 -0
- package/src/ng-add/files/functions/src/index.ts.template +44 -0
- package/src/ng-add/files/functions/tsconfig.json.template +13 -0
- package/src/ng-add/files/jest.config.ts.template +3 -2
- package/src/ng-add/files/package.json.template +41 -16
- package/src/ng-add/files/projects/analytics/src/app/analytics-api.service.ts.template +130 -0
- package/src/ng-add/files/projects/analytics/src/app/app.component.html.template +77 -0
- package/src/ng-add/files/projects/analytics/src/app/app.component.scss.template +240 -0
- package/src/ng-add/files/projects/analytics/src/app/app.component.ts.template +96 -0
- package/src/ng-add/files/projects/analytics/src/app/app.routes.ts.template +11 -0
- package/src/ng-add/files/projects/analytics/src/app/dashboard-pages.spec.ts.template +151 -0
- package/src/ng-add/files/projects/analytics/src/app/data-quality/data-quality-page/data-quality-page.component.html.template +39 -0
- package/src/ng-add/files/projects/analytics/src/app/data-quality/data-quality-page/data-quality-page.component.scss.template +1 -0
- package/src/ng-add/files/projects/analytics/src/app/data-quality/data-quality-page/data-quality-page.component.ts.template +95 -0
- package/src/ng-add/files/projects/analytics/src/app/engagement/engagement-page/engagement-page.component.html.template +47 -0
- package/src/ng-add/files/projects/analytics/src/app/engagement/engagement-page/engagement-page.component.scss.template +1 -0
- package/src/ng-add/files/projects/analytics/src/app/engagement/engagement-page/engagement-page.component.ts.template +120 -0
- package/src/ng-add/files/projects/analytics/src/app/onboarding/onboarding-page/onboarding-page.component.html.template +40 -0
- package/src/ng-add/files/projects/analytics/src/app/onboarding/onboarding-page/onboarding-page.component.scss.template +1 -0
- package/src/ng-add/files/projects/analytics/src/app/onboarding/onboarding-page/onboarding-page.component.ts.template +98 -0
- package/src/ng-add/files/projects/analytics/src/app/overview/overview-page/overview-page.component.html.template +35 -0
- package/src/ng-add/files/projects/analytics/src/app/overview/overview-page/overview-page.component.scss.template +1 -0
- package/src/ng-add/files/projects/analytics/src/app/overview/overview-page/overview-page.component.ts.template +84 -0
- package/src/ng-add/files/projects/analytics/src/app/routes/routes-page/routes-page.component.html.template +42 -0
- package/src/ng-add/files/projects/analytics/src/app/routes/routes-page/routes-page.component.scss.template +1 -0
- package/src/ng-add/files/projects/analytics/src/app/routes/routes-page/routes-page.component.ts.template +110 -0
- package/src/ng-add/files/projects/analytics/src/app/shared/analytics-utils.ts.template +43 -0
- package/src/ng-add/files/projects/analytics/src/app/shared/chart-theme.ts.template +42 -0
- package/src/ng-add/files/projects/analytics/src/app/shared/dashboard-layout.scss.template +239 -0
- package/src/ng-add/files/projects/analytics/src/app/shared/dashboard-table/dashboard-table.component.html.template +76 -0
- package/src/ng-add/files/projects/analytics/src/app/shared/dashboard-table/dashboard-table.component.scss.template +128 -0
- package/src/ng-add/files/projects/analytics/src/app/shared/dashboard-table/dashboard-table.component.spec.ts.template +31 -0
- package/src/ng-add/files/projects/analytics/src/app/shared/dashboard-table/dashboard-table.component.ts.template +153 -0
- package/src/ng-add/files/projects/analytics/src/app/shared/funnel-chart/funnel-chart.component.html.template +16 -0
- package/src/ng-add/files/projects/analytics/src/app/shared/funnel-chart/funnel-chart.component.scss.template +63 -0
- package/src/ng-add/files/projects/analytics/src/app/shared/funnel-chart/funnel-chart.component.ts.template +52 -0
- package/src/ng-add/files/projects/analytics/src/app/shared/metric-card/metric-card.component.html.template +5 -0
- package/src/ng-add/files/projects/analytics/src/app/shared/metric-card/metric-card.component.scss.template +56 -0
- package/src/ng-add/files/projects/analytics/src/app/shared/metric-card/metric-card.component.spec.ts.template +30 -0
- package/src/ng-add/files/projects/analytics/src/app/shared/metric-card/metric-card.component.ts.template +15 -0
- package/src/ng-add/files/projects/analytics/src/app/shared/quality-chart/quality-chart.component.html.template +9 -0
- package/src/ng-add/files/projects/analytics/src/app/shared/quality-chart/quality-chart.component.scss.template +43 -0
- package/src/ng-add/files/projects/analytics/src/app/shared/quality-chart/quality-chart.component.ts.template +62 -0
- package/src/ng-add/files/projects/analytics/src/app/shared/route-distribution-chart/route-distribution-chart.component.html.template +9 -0
- package/src/ng-add/files/projects/analytics/src/app/shared/route-distribution-chart/route-distribution-chart.component.scss.template +33 -0
- package/src/ng-add/files/projects/analytics/src/app/shared/route-distribution-chart/route-distribution-chart.component.ts.template +82 -0
- package/src/ng-add/files/projects/analytics/src/app/shared/route-traffic-chart/route-traffic-chart.component.html.template +15 -0
- package/src/ng-add/files/projects/analytics/src/app/shared/route-traffic-chart/route-traffic-chart.component.scss.template +45 -0
- package/src/ng-add/files/projects/analytics/src/app/shared/route-traffic-chart/route-traffic-chart.component.ts.template +55 -0
- package/src/ng-add/files/projects/analytics/src/app/shared/status-message/status-message.component.html.template +18 -0
- package/src/ng-add/files/projects/analytics/src/app/shared/status-message/status-message.component.scss.template +45 -0
- package/src/ng-add/files/projects/analytics/src/app/shared/status-message/status-message.component.ts.template +15 -0
- package/src/ng-add/files/projects/analytics/src/app/vega-chart/vega-chart.component.ts.template +121 -0
- package/src/ng-add/files/projects/analytics/src/index.html.template +19 -0
- package/src/ng-add/files/projects/analytics/src/main.ts.template +16 -0
- package/src/ng-add/files/projects/analytics/src/styles.scss.template +28 -0
- package/src/ng-add/files/projects/analytics/tsconfig.app.json.template +13 -0
- package/src/ng-add/files/projects/analytics/tsconfig.spec.json.template +15 -0
- package/src/ng-add/files/src/app/admin/admin-panel/admin-panel.component.html.template +3 -1
- package/src/ng-add/files/src/app/admin/admin-panel/admin-panel.component.spec.ts.template +10 -13
- package/src/ng-add/files/src/app/admin/admin-panel/admin-panel.component.ts.template +2 -0
- package/src/ng-add/files/src/app/admin/admin-panel/admin-settings/admin-settings.component.spec.ts.template +4 -5
- package/src/ng-add/files/src/app/admin/admin-panel/admin-user-list/admin-user-list.component.spec.ts.template +11 -12
- package/src/ng-add/files/src/app/admin/admin-panel/admin-user-list/admin-user-list.component.ts.template +7 -7
- 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
- package/src/ng-add/files/src/app/admin/admin-panel/admin-user-list/admin-user-table/admin-user-table.component.ts.template +3 -2
- package/src/ng-add/files/src/app/app.component.html.template +3 -3
- package/src/ng-add/files/src/app/app.component.scss.template +1 -1
- package/src/ng-add/files/src/app/app.component.spec.ts.template +4 -5
- package/src/ng-add/files/src/app/app.component.ts.template +3 -2
- package/src/ng-add/files/src/app/app.config.ts.template +21 -15
- package/src/ng-add/files/src/app/app.routes.ts.template +6 -0
- package/src/ng-add/files/src/app/auth-routing.spec.ts.template +13 -9
- package/src/ng-add/files/src/app/core/analytics/time-analytics.service.spec.ts.template +46 -29
- package/src/ng-add/files/src/app/core/analytics/time-analytics.service.ts.template +27 -18
- package/src/ng-add/files/src/app/core/auth/auth.providers.spec.ts.template +112 -0
- package/src/ng-add/files/src/app/core/auth/auth.providers.ts.template +48 -0
- package/src/ng-add/files/src/app/core/auth/auth.service.ts.template +14 -23
- package/src/ng-add/files/src/app/core/auth/guards/require-admin.guard.spec.ts.template +27 -0
- package/src/ng-add/files/src/app/core/auth/guards/require-admin.guard.ts.template +3 -2
- package/src/ng-add/files/src/app/core/auth/guards/require-auth-and-consent.guard.ts.template +7 -2
- package/src/ng-add/files/src/app/core/firebase/data.providers.prod.ts.template +21 -0
- package/src/ng-add/files/src/app/core/firebase/data.providers.ts.template +13 -0
- package/src/ng-add/files/src/app/core/local-storage/session.service.spec.ts.template +43 -0
- package/src/ng-add/files/src/app/core/local-storage/session.service.ts.template +7 -0
- package/src/ng-add/files/src/app/core/store/app-data.spec.ts.template +76 -0
- package/src/ng-add/files/src/app/core/store/auth/auth.mock.ts.template +20 -82
- package/src/ng-add/files/src/app/core/store/auth/auth.store.spec.ts.template +217 -0
- package/src/ng-add/files/src/app/core/store/auth/auth.store.ts.template +36 -172
- package/src/ng-add/files/src/app/core/store/user/user.mock.ts.template +18 -15
- package/src/ng-add/files/src/app/core/store/user/user.model.ts.template +7 -8
- package/src/ng-add/files/src/app/core/store/user/user.store.ts.template +14 -10
- package/src/ng-add/files/src/app/core/store/user-context/user-context.mock.ts.template +20 -8
- package/src/ng-add/files/src/app/core/store/user-context/user-context.model.ts.template +5 -6
- package/src/ng-add/files/src/app/core/store/user-context/user-context.store.ts.template +14 -10
- package/src/ng-add/files/src/app/core/store/user-private/user-private.mock.ts.template +20 -7
- package/src/ng-add/files/src/app/core/store/user-private/user-private.model.ts.template +6 -6
- package/src/ng-add/files/src/app/core/store/user-private/user-private.store.ts.template +14 -10
- package/src/ng-add/files/src/app/core/testing/app-mocks.ts.template +42 -0
- package/src/ng-add/files/src/app/first-time/auth-action/auth-action.component.html.template +4 -0
- package/src/ng-add/files/src/app/first-time/auth-action/auth-action.component.scss.template +1 -0
- package/src/ng-add/files/src/app/first-time/auth-action/auth-action.component.ts.template +38 -0
- package/src/ng-add/files/src/app/first-time/consent/consent.component.html.template +2 -1
- package/src/ng-add/files/src/app/first-time/consent/consent.component.scss.template +7 -3
- package/src/ng-add/files/src/app/first-time/consent/consent.component.spec.ts.template +31 -11
- package/src/ng-add/files/src/app/first-time/consent/consent.component.ts.template +16 -1
- package/src/ng-add/files/src/app/first-time/consent/consent.guard.ts.template +5 -1
- package/src/ng-add/files/src/app/first-time/early-access/early-access.component.spec.ts.template +27 -16
- package/src/ng-add/files/src/app/first-time/early-access/early-access.component.ts.template +102 -49
- package/src/ng-add/files/src/app/first-time/early-access/early-access.guard.ts.template +5 -1
- package/src/ng-add/files/src/app/first-time/early-access/survey-form/survey-form.component.html.template +2 -1
- package/src/ng-add/files/src/app/first-time/early-access/survey-form/survey-form.component.scss.template +7 -3
- package/src/ng-add/files/src/app/first-time/early-access/survey-form/survey-form.component.spec.ts.template +20 -6
- package/src/ng-add/files/src/app/first-time/early-access/survey-form/survey-form.component.ts.template +2 -0
- package/src/ng-add/files/src/app/first-time/early-access/waitlist-view/waitlist-view.component.spec.ts.template +4 -5
- package/src/ng-add/files/src/app/first-time/email-link/email-link.component.html.template +18 -0
- package/src/ng-add/files/src/app/first-time/email-link/email-link.component.scss.template +2 -0
- package/src/ng-add/files/src/app/first-time/email-link/email-link.component.spec.ts.template +56 -0
- package/src/ng-add/files/src/app/first-time/email-link/email-link.component.ts.template +91 -0
- package/src/ng-add/files/src/app/first-time/first-time-routing.spec.ts.template +11 -7
- package/src/ng-add/files/src/app/first-time/landing/hero/hero.component.html.template +19 -7
- package/src/ng-add/files/src/app/first-time/landing/hero/hero.component.scss.template +51 -0
- package/src/ng-add/files/src/app/first-time/landing/hero/hero.component.ts.template +44 -5
- package/src/ng-add/files/src/app/first-time/landing/landing.component.html.template +2 -1
- package/src/ng-add/files/src/app/first-time/landing/landing.component.scss.template +12 -8
- package/src/ng-add/files/src/app/first-time/landing/landing.component.spec.ts.template +33 -10
- package/src/ng-add/files/src/app/first-time/landing/landing.component.ts.template +6 -19
- package/src/ng-add/files/src/app/first-time/login/login.component.html.template +58 -6
- package/src/ng-add/files/src/app/first-time/login/login.component.scss.template +151 -22
- package/src/ng-add/files/src/app/first-time/login/login.component.spec.ts.template +30 -32
- package/src/ng-add/files/src/app/first-time/login/login.component.ts.template +85 -31
- package/src/ng-add/files/src/app/first-time/onboarding/onboarding.component.spec.ts.template +4 -2
- package/src/ng-add/files/src/app/first-time/onboarding/onboarding.component.ts.template +1 -1
- package/src/ng-add/files/src/app/main/account-profile/account-profile.component.html.template +12 -0
- package/src/ng-add/files/src/app/main/account-profile/account-profile.component.scss.template +39 -0
- package/src/ng-add/files/src/app/main/account-profile/account-profile.component.spec.ts.template +68 -0
- package/src/ng-add/files/src/app/main/account-profile/account-profile.component.ts.template +20 -0
- package/src/ng-add/files/src/app/main/account-profile/delete-guest-card/delete-guest-card.component.html.template +24 -0
- package/src/ng-add/files/src/app/main/account-profile/delete-guest-card/delete-guest-card.component.scss.template +50 -0
- package/src/ng-add/files/src/app/main/account-profile/delete-guest-card/delete-guest-card.component.spec.ts.template +65 -0
- package/src/ng-add/files/src/app/main/account-profile/delete-guest-card/delete-guest-card.component.ts.template +59 -0
- package/src/ng-add/files/src/app/main/account-profile/guest-deletion-dialog.component.ts.template +51 -0
- package/src/ng-add/files/src/app/main/account-profile/profile-details-card/profile-details-card.component.html.template +50 -0
- package/src/ng-add/files/src/app/main/account-profile/profile-details-card/profile-details-card.component.scss.template +137 -0
- package/src/ng-add/files/src/app/main/account-profile/profile-details-card/profile-details-card.component.spec.ts.template +57 -0
- package/src/ng-add/files/src/app/main/account-profile/profile-details-card/profile-details-card.component.ts.template +59 -0
- package/src/ng-add/files/src/app/main/account-profile/sign-in-methods-card/sign-in-methods-card.component.html.template +133 -0
- package/src/ng-add/files/src/app/main/account-profile/sign-in-methods-card/sign-in-methods-card.component.scss.template +207 -0
- package/src/ng-add/files/src/app/main/account-profile/sign-in-methods-card/sign-in-methods-card.component.spec.ts.template +74 -0
- package/src/ng-add/files/src/app/main/account-profile/sign-in-methods-card/sign-in-methods-card.component.ts.template +130 -0
- package/src/ng-add/files/src/app/main/home/home.component.spec.ts.template +4 -5
- package/src/ng-add/files/src/app/main/home/home.component.ts.template +1 -6
- package/src/ng-add/files/src/app/shared/guest-warning-bar/guest-warning-bar.component.html.template +15 -0
- package/src/ng-add/files/src/app/shared/guest-warning-bar/guest-warning-bar.component.scss.template +79 -0
- package/src/ng-add/files/src/app/shared/guest-warning-bar/guest-warning-bar.component.spec.ts.template +59 -0
- package/src/ng-add/files/src/app/shared/guest-warning-bar/guest-warning-bar.component.ts.template +44 -0
- package/src/ng-add/files/src/app/shared/navbar/navbar.component.html.template +45 -15
- package/src/ng-add/files/src/app/shared/navbar/navbar.component.scss.template +103 -19
- package/src/ng-add/files/src/app/shared/navbar/navbar.component.spec.ts.template +73 -9
- package/src/ng-add/files/src/app/shared/navbar/navbar.component.ts.template +46 -18
- package/src/ng-add/files/src/environments/environment.prod.ts.template +1 -0
- package/src/ng-add/files/src/environments/environment.test.ts.template +1 -0
- package/src/ng-add/files/src/environments/environment.ts.template +1 -1
- package/src/ng-add/files/tsconfig.spec.json.template +3 -1
- package/src/ng-add/index.js +7 -0
- package/src/ng-add/index.js.map +1 -1
- package/src/shared/entity-registry.d.ts +8 -0
- package/src/shared/entity-registry.js +28 -0
- package/src/shared/entity-registry.js.map +1 -0
- package/tsconfig.json +2 -2
- package/.agents/skills/publish-npm/SKILL.md +0 -37
- package/.agents/skills/publish-npm/eval.yaml +0 -32
- package/.agents/skills/publish-npm/fixtures/package-v21.json.template +0 -8
- package/.husky/commit-msg +0 -1
- package/.husky/pre-commit +0 -1
- package/.t4g/agent-memory.db +0 -0
- package/src/component/index_spec.d.ts +0 -1
- package/src/component/index_spec.js +0 -68
- package/src/component/index_spec.js.map +0 -1
- package/src/entity/index_spec.d.ts +0 -1
- package/src/entity/index_spec.js +0 -153
- package/src/entity/index_spec.js.map +0 -1
- package/src/guard/index_spec.d.ts +0 -1
- package/src/guard/index_spec.js +0 -64
- package/src/guard/index_spec.js.map +0 -1
- package/src/ng-add/files/bigquery/scripts/export_entities.py.template +0 -143
- package/src/ng-add/files/bigquery/scripts/run_query.py.template +0 -167
- package/src/ng-add/files/src/app/core/firebase/cached-listeners.service.ts.template +0 -494
- package/src/ng-add/files/src/app/core/firebase/database.service.ts.template +0 -56
- package/src/ng-add/files/src/app/core/firebase/firebase.mock.service.ts.template +0 -366
- package/src/ng-add/files/src/app/core/firebase/firebase.service.ts.template +0 -342
- package/src/ng-add/files/src/app/core/firebase/simulate-load.spec.ts.template +0 -104
- package/src/ng-add/files/src/app/core/firebase/simulate-stream.spec.ts.template +0 -127
- package/src/ng-add/files/src/app/core/firebase/simulation.mock.ts.template +0 -38
- package/src/ng-add/files/src/app/core/firebase/stream-multiplexer.ts.template +0 -445
- package/src/ng-add/files/src/app/core/logging/logging.service.spec.ts.template +0 -118
- package/src/ng-add/files/src/app/core/logging/logging.service.ts.template +0 -168
- package/src/ng-add/files/src/app/core/store/app.model.ts.template +0 -21
- package/src/ng-add/files/src/app/core/store/app.store.spec.ts.template +0 -920
- package/src/ng-add/files/src/app/core/store/app.store.ts.template +0 -1317
- package/src/ng-add/files/src/app/core/store/batch-write.firebase.service.ts.template +0 -58
- package/src/ng-add/files/src/app/core/store/batch-write.mock.service.ts.template +0 -105
- package/src/ng-add/files/src/app/core/store/batch-write.service.ts.template +0 -126
- package/src/ng-add/files/src/app/shared/redeployment-warning/redeployment-warning.component.html.template +0 -9
- package/src/ng-add/files/src/app/shared/redeployment-warning/redeployment-warning.component.scss.template +0 -46
- package/src/ng-add/files/src/app/shared/redeployment-warning/redeployment-warning.component.spec.ts.template +0 -69
- package/src/ng-add/files/src/app/shared/redeployment-warning/redeployment-warning.component.ts.template +0 -39
- package/src/ng-add/files/src/app/shared/redeployment-warning/redeployment-warning.service.spec.ts.template +0 -122
- package/src/ng-add/files/src/app/shared/redeployment-warning/redeployment-warning.service.ts.template +0 -88
|
@@ -0,0 +1,217 @@
|
|
|
1
|
+
import { TestBed } from '@angular/core/testing';
|
|
2
|
+
import { Injector } from '@angular/core';
|
|
3
|
+
import { Router } from '@angular/router';
|
|
4
|
+
import { BehaviorSubject, Subject } from 'rxjs';
|
|
5
|
+
import { signalStore } from '@ngrx/signals';
|
|
6
|
+
import { dataTimestampNow, withEntitiesAndDBMethods } from '@tech4good/platform-data';
|
|
7
|
+
import { CachedListenersService } from '@tech4good/platform-data';
|
|
8
|
+
import { AuthSession, AUTH_ACCESS, AuthAccess, PROFILE_PROVISIONER, ProfileProvisioner } from '@tech4good/platform-auth';
|
|
9
|
+
import { DATA_ACCESS } from '@tech4good/platform-data';
|
|
10
|
+
import { provideAppAuthLifecycle } from '../../auth/auth.providers';
|
|
11
|
+
import { UserContextStore } from '../user-context/user-context.store';
|
|
12
|
+
import { UserStore } from '../user/user.store';
|
|
13
|
+
import { SessionService } from '../../local-storage/session.service';
|
|
14
|
+
import { AuthStore } from './auth.store';
|
|
15
|
+
|
|
16
|
+
describe('AuthStore session teardown', () => {
|
|
17
|
+
it('waits for refresh provisioning before listener teardown and auth-state cleanup on logout', async () => {
|
|
18
|
+
const session: AuthSession = {
|
|
19
|
+
uid: 'refresh-user',
|
|
20
|
+
email: 'user@example.com',
|
|
21
|
+
displayName: 'Test User',
|
|
22
|
+
photoURL: null,
|
|
23
|
+
isAnonymous: false,
|
|
24
|
+
emailVerified: true,
|
|
25
|
+
emailLinkEnabled: false,
|
|
26
|
+
providerIds: ['google.com'],
|
|
27
|
+
};
|
|
28
|
+
const authSession = new BehaviorSubject<AuthSession | null>(null);
|
|
29
|
+
let finishProvisioning!: () => void;
|
|
30
|
+
const provisioning = new Promise<void>((resolve) => {
|
|
31
|
+
finishProvisioning = resolve;
|
|
32
|
+
});
|
|
33
|
+
const db = {
|
|
34
|
+
afUser: jest.fn().mockReturnValue(authSession),
|
|
35
|
+
ensureUserProfile: jest.fn().mockReturnValue(provisioning),
|
|
36
|
+
logout: jest.fn().mockResolvedValue(undefined),
|
|
37
|
+
} as unknown as AuthAccess & ProfileProvisioner;
|
|
38
|
+
const userStore = {
|
|
39
|
+
selectEntity: jest.fn().mockReturnValue(null),
|
|
40
|
+
load: jest.fn().mockResolvedValue(undefined),
|
|
41
|
+
stream: jest.fn(),
|
|
42
|
+
reset: jest.fn(),
|
|
43
|
+
};
|
|
44
|
+
const resetOnlyStore = { reset: jest.fn() };
|
|
45
|
+
const cachedListeners = { teardownAllStreams: jest.fn() };
|
|
46
|
+
const sessionService = { resetSessionId: jest.fn() };
|
|
47
|
+
|
|
48
|
+
TestBed.configureTestingModule({
|
|
49
|
+
providers: [
|
|
50
|
+
AuthStore,
|
|
51
|
+
{ provide: AUTH_ACCESS, useValue: db },
|
|
52
|
+
{ provide: PROFILE_PROVISIONER, useValue: db },
|
|
53
|
+
{ provide: DATA_ACCESS, useValue: db },
|
|
54
|
+
...provideAppAuthLifecycle(async () => {
|
|
55
|
+
if ('deleteAnonymousAccount' in db) await (db as { deleteAnonymousAccount(): Promise<void> }).deleteAnonymousAccount();
|
|
56
|
+
}),
|
|
57
|
+
{ provide: UserStore, useValue: userStore },
|
|
58
|
+
{ provide: UserContextStore, useValue: resetOnlyStore },
|
|
59
|
+
{ provide: SessionService, useValue: sessionService },
|
|
60
|
+
{
|
|
61
|
+
provide: Router,
|
|
62
|
+
useValue: {
|
|
63
|
+
navigate: jest.fn().mockResolvedValue(true),
|
|
64
|
+
},
|
|
65
|
+
},
|
|
66
|
+
{ provide: CachedListenersService, useValue: cachedListeners },
|
|
67
|
+
],
|
|
68
|
+
});
|
|
69
|
+
const authStore = TestBed.inject(AuthStore);
|
|
70
|
+
authStore.loadAuth();
|
|
71
|
+
authSession.next(session);
|
|
72
|
+
await Promise.resolve();
|
|
73
|
+
expect(db.ensureUserProfile).toHaveBeenCalledWith(session);
|
|
74
|
+
|
|
75
|
+
const logout = authStore.logout({ doNotRoute: true });
|
|
76
|
+
await Promise.resolve();
|
|
77
|
+
expect(cachedListeners.teardownAllStreams).not.toHaveBeenCalled();
|
|
78
|
+
expect(db.logout).not.toHaveBeenCalled();
|
|
79
|
+
expect(userStore.reset).not.toHaveBeenCalled();
|
|
80
|
+
|
|
81
|
+
finishProvisioning();
|
|
82
|
+
await logout;
|
|
83
|
+
|
|
84
|
+
expect(userStore.stream).toHaveBeenCalledTimes(1);
|
|
85
|
+
expect(cachedListeners.teardownAllStreams).toHaveBeenCalledTimes(1);
|
|
86
|
+
expect(userStore.reset).toHaveBeenCalledTimes(1);
|
|
87
|
+
expect(resetOnlyStore.reset).toHaveBeenCalledTimes(1);
|
|
88
|
+
expect(sessionService.resetSessionId).toHaveBeenCalledTimes(1);
|
|
89
|
+
expect(db.logout).toHaveBeenCalledTimes(1);
|
|
90
|
+
expect(authStore.afUser()).toBeNull();
|
|
91
|
+
expect(cachedListeners.teardownAllStreams.mock.invocationCallOrder[0]).toBeLessThan(
|
|
92
|
+
userStore.reset.mock.invocationCallOrder[0],
|
|
93
|
+
);
|
|
94
|
+
expect(userStore.reset.mock.invocationCallOrder[0]).toBeLessThan(db.logout.mock.invocationCallOrder[0]);
|
|
95
|
+
expect(userStore.stream.mock.invocationCallOrder[0]).toBeLessThan(
|
|
96
|
+
cachedListeners.teardownAllStreams.mock.invocationCallOrder[0],
|
|
97
|
+
);
|
|
98
|
+
});
|
|
99
|
+
|
|
100
|
+
for (const guest of [false, true]) {
|
|
101
|
+
it(`retains domain records and load history while clearing auth state on ${guest ? 'guest deletion' : 'logout'}`, async () => {
|
|
102
|
+
const session: AuthSession = {
|
|
103
|
+
uid: 'signed-in-user', email: null, displayName: null, photoURL: null,
|
|
104
|
+
isAnonymous: guest, emailVerified: false, emailLinkEnabled: false, providerIds: [],
|
|
105
|
+
};
|
|
106
|
+
const source = new Subject();
|
|
107
|
+
const db = {
|
|
108
|
+
signInWithGoogle: jest.fn().mockResolvedValue(session),
|
|
109
|
+
signInAnonymously: jest.fn().mockResolvedValue(session),
|
|
110
|
+
ensureUserProfile: jest.fn().mockResolvedValue(undefined),
|
|
111
|
+
logout: jest.fn().mockResolvedValue(undefined),
|
|
112
|
+
deleteAnonymousAccount: jest.fn().mockResolvedValue(undefined),
|
|
113
|
+
streamEntitiesChanges: () => source,
|
|
114
|
+
};
|
|
115
|
+
const userStore = {
|
|
116
|
+
selectEntity: jest.fn().mockReturnValue({ __id: session.uid }),
|
|
117
|
+
load: jest.fn().mockResolvedValue(undefined), stream: jest.fn(), reset: jest.fn(),
|
|
118
|
+
};
|
|
119
|
+
const userContextStore = { reset: jest.fn() };
|
|
120
|
+
const sessionService = { resetSessionId: jest.fn() };
|
|
121
|
+
const router = { navigate: jest.fn().mockResolvedValue(true) };
|
|
122
|
+
// A real shared domain store, with no registration in the auth flow.
|
|
123
|
+
const DomainStore = signalStore({ providedIn: 'root' }, withEntitiesAndDBMethods('domainExamples'));
|
|
124
|
+
TestBed.configureTestingModule({ providers: [
|
|
125
|
+
AuthStore,
|
|
126
|
+
{ provide: AUTH_ACCESS, useValue: db },
|
|
127
|
+
{ provide: PROFILE_PROVISIONER, useValue: db },
|
|
128
|
+
{ provide: DATA_ACCESS, useValue: db },
|
|
129
|
+
...provideAppAuthLifecycle(async () => {
|
|
130
|
+
if ('deleteAnonymousAccount' in db) await (db as { deleteAnonymousAccount(): Promise<void> }).deleteAnonymousAccount();
|
|
131
|
+
}),
|
|
132
|
+
{ provide: UserStore, useValue: userStore },
|
|
133
|
+
{ provide: UserContextStore, useValue: userContextStore },
|
|
134
|
+
{ provide: SessionService, useValue: sessionService },
|
|
135
|
+
{ provide: Router, useValue: router },
|
|
136
|
+
] });
|
|
137
|
+
const auth = TestBed.inject(AuthStore);
|
|
138
|
+
const domain = TestBed.inject(DomainStore);
|
|
139
|
+
const cache = TestBed.inject(CachedListenersService);
|
|
140
|
+
const timestamp = dataTimestampNow();
|
|
141
|
+
domain.init([{ __id: 'retained', _createdAt: timestamp, _updatedAt: timestamp, _deleted: false }]);
|
|
142
|
+
await domain.stream([], {}, TestBed.inject(Injector));
|
|
143
|
+
cache.setLastLoadTime('domainExamples', [], {}, 100);
|
|
144
|
+
cache.setEntityLoadTime('domainExamples', '__id', 'retained', 100);
|
|
145
|
+
if (guest) await auth.loginAnonymously();
|
|
146
|
+
else await auth.signInWithGoogle();
|
|
147
|
+
expect(auth.user()?.__id).toBe(session.uid);
|
|
148
|
+
expect(source.observed).toBe(true);
|
|
149
|
+
|
|
150
|
+
if (guest) await auth.deleteAnonymousAccount();
|
|
151
|
+
else await auth.logout();
|
|
152
|
+
|
|
153
|
+
expect(domain.selectEntity('retained')?.__id).toBe('retained');
|
|
154
|
+
expect(source.observed).toBe(false);
|
|
155
|
+
expect(cache.getLastLoadTime('domainExamples', [], {})).toBe(100);
|
|
156
|
+
expect(cache.getEntityLoadTime('domainExamples', '__id', 'retained')).toBe(100);
|
|
157
|
+
expect(userStore.reset).toHaveBeenCalledTimes(1);
|
|
158
|
+
expect(userContextStore.reset).toHaveBeenCalledTimes(1);
|
|
159
|
+
expect(sessionService.resetSessionId).toHaveBeenCalledTimes(1);
|
|
160
|
+
expect(db.deleteAnonymousAccount).toHaveBeenCalledTimes(guest ? 1 : 0);
|
|
161
|
+
expect(db.logout).toHaveBeenCalledTimes(1);
|
|
162
|
+
expect(auth.afUser()).toBeNull();
|
|
163
|
+
expect(auth.user()).toBeNull();
|
|
164
|
+
expect(router.navigate).toHaveBeenCalledWith(['/landing']);
|
|
165
|
+
});
|
|
166
|
+
}
|
|
167
|
+
|
|
168
|
+
it('sets isLoadingLogin to true during completeEmailSignInLink', async () => {
|
|
169
|
+
const session: AuthSession = {
|
|
170
|
+
uid: 'new-email-user',
|
|
171
|
+
email: 'new@example.com',
|
|
172
|
+
displayName: null,
|
|
173
|
+
photoURL: null,
|
|
174
|
+
isAnonymous: false,
|
|
175
|
+
emailVerified: true,
|
|
176
|
+
emailLinkEnabled: true,
|
|
177
|
+
providerIds: ['password'],
|
|
178
|
+
};
|
|
179
|
+
let isLoadingDuringCall = false;
|
|
180
|
+
const db = {
|
|
181
|
+
afUser: jest.fn().mockReturnValue(new BehaviorSubject<AuthSession | null>(null)),
|
|
182
|
+
completeEmailSignInLink: jest.fn().mockImplementation(async () => {
|
|
183
|
+
isLoadingDuringCall = authStore.isLoadingLogin();
|
|
184
|
+
return session;
|
|
185
|
+
}),
|
|
186
|
+
ensureUserProfile: jest.fn().mockResolvedValue(undefined),
|
|
187
|
+
} as unknown as AuthAccess & ProfileProvisioner;
|
|
188
|
+
const userStore = {
|
|
189
|
+
selectEntity: jest.fn().mockReturnValue(null),
|
|
190
|
+
load: jest.fn().mockResolvedValue(undefined),
|
|
191
|
+
stream: jest.fn(),
|
|
192
|
+
};
|
|
193
|
+
|
|
194
|
+
TestBed.configureTestingModule({
|
|
195
|
+
providers: [
|
|
196
|
+
AuthStore,
|
|
197
|
+
{ provide: AUTH_ACCESS, useValue: db },
|
|
198
|
+
{ provide: PROFILE_PROVISIONER, useValue: db },
|
|
199
|
+
{ provide: DATA_ACCESS, useValue: db },
|
|
200
|
+
...provideAppAuthLifecycle(async () => {
|
|
201
|
+
if ('deleteAnonymousAccount' in db) await (db as { deleteAnonymousAccount(): Promise<void> }).deleteAnonymousAccount();
|
|
202
|
+
}),
|
|
203
|
+
{ provide: UserStore, useValue: userStore },
|
|
204
|
+
{ provide: UserContextStore, useValue: { reset: jest.fn() } },
|
|
205
|
+
{ provide: Router, useValue: { navigate: jest.fn().mockResolvedValue(true) } },
|
|
206
|
+
{ provide: CachedListenersService, useValue: { teardownAllStreams: jest.fn() } },
|
|
207
|
+
],
|
|
208
|
+
});
|
|
209
|
+
const authStore = TestBed.inject(AuthStore);
|
|
210
|
+
|
|
211
|
+
expect(authStore.isLoadingLogin()).toBe(false);
|
|
212
|
+
await authStore.completeEmailSignInLink('https://example.com/link', 'new@example.com');
|
|
213
|
+
expect(isLoadingDuringCall).toBe(true);
|
|
214
|
+
expect(authStore.isLoadingLogin()).toBe(false);
|
|
215
|
+
expect(authStore.afUser()).toEqual(session);
|
|
216
|
+
});
|
|
217
|
+
});
|
|
@@ -1,187 +1,51 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import { signalStore,
|
|
3
|
-
import {
|
|
4
|
-
import {
|
|
5
|
-
import { DATABASE_SERVICE, DatabaseService } from '../../firebase/database.service';
|
|
6
|
-
import { firstValueFrom, EMPTY, of, pipe, from } from 'rxjs';
|
|
7
|
-
import { tap, catchError, switchMap, map } from 'rxjs/operators';
|
|
1
|
+
import { Injector, computed, inject } from '@angular/core';
|
|
2
|
+
import { signalStore, withMethods, withComputed } from '@ngrx/signals';
|
|
3
|
+
import { withAuthSession } from '@tech4good/platform-auth';
|
|
4
|
+
import { firstValueFrom } from 'rxjs';
|
|
8
5
|
import { Router } from '@angular/router';
|
|
6
|
+
import { MatDialog } from '@angular/material/dialog';
|
|
9
7
|
import { UserStore } from '../user/user.store';
|
|
10
|
-
import {
|
|
11
|
-
import { setEntity } from '@ngrx/signals/entities';
|
|
12
|
-
|
|
13
|
-
type State = {
|
|
14
|
-
afUser: { uid: string, email: string, displayName: string, photoURL: string } | null;
|
|
15
|
-
isLoadingLogin: boolean;
|
|
16
|
-
}
|
|
17
|
-
|
|
18
|
-
const initialState: State = {
|
|
19
|
-
afUser: null,
|
|
20
|
-
isLoadingLogin: false,
|
|
21
|
-
};
|
|
8
|
+
import { GuestDeletionDialogComponent } from 'src/app/main/account-profile/guest-deletion-dialog.component';
|
|
22
9
|
|
|
10
|
+
/** Shared auth mechanics, with this app's user selector, dialog and navigation. */
|
|
23
11
|
export const AuthStore = signalStore(
|
|
24
12
|
{ providedIn: 'root' },
|
|
25
|
-
|
|
13
|
+
withAuthSession(),
|
|
26
14
|
withComputed((store, userStore = inject(UserStore)) => ({
|
|
27
15
|
user: computed(() => {
|
|
28
16
|
const afUser = store.afUser();
|
|
29
|
-
if (!afUser) return null;
|
|
17
|
+
if (!afUser || store.authStatus() !== 'ready') return null;
|
|
30
18
|
return userStore.selectEntity(afUser.uid) || null;
|
|
31
19
|
}),
|
|
32
20
|
})),
|
|
33
|
-
withMethods((store,
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
switchMap((afUser) => {
|
|
49
|
-
if (afUser) {
|
|
50
|
-
// We perform a blocking 'load()' first to ensure the UserStore is populated
|
|
51
|
-
// with the database user data before we continue. This ensures the 'user'
|
|
52
|
-
// computed signal is populated instantly for any route guards.
|
|
53
|
-
return from(userStore.load([['__id', '==', afUser.uid]], {})).pipe(
|
|
54
|
-
switchMap(() => {
|
|
55
|
-
// After the initial load completes, we set up a background 'stream()'.
|
|
56
|
-
// This ensures the UserStore stays continuously in sync with any
|
|
57
|
-
// real-time backend database updates (e.g. from cloud functions).
|
|
58
|
-
userStore.stream([['__id', '==', afUser.uid]], {}, injector);
|
|
59
|
-
|
|
60
|
-
// Pass the afUser down the pipe to the tap() handler.
|
|
61
|
-
return of(afUser);
|
|
62
|
-
}),
|
|
63
|
-
catchError((e) => {
|
|
64
|
-
console.error('[AuthStore loadAuth] streamEntity error:', e);
|
|
65
|
-
return EMPTY;
|
|
66
|
-
}),
|
|
67
|
-
);
|
|
68
|
-
} else {
|
|
69
|
-
// If signed out, just pass null down.
|
|
70
|
-
return of(null);
|
|
71
|
-
}
|
|
72
|
-
}),
|
|
73
|
-
|
|
74
|
-
// 3. Update the local AuthStore state and handle brand new signups.
|
|
75
|
-
tap(async (afUser: State['afUser']) => {
|
|
76
|
-
if (!afUser) {
|
|
77
|
-
patchState(store, { afUser: null });
|
|
78
|
-
} else {
|
|
79
|
-
patchState(store, { afUser });
|
|
80
|
-
const dbUser = userStore.selectEntity(afUser.uid);
|
|
81
|
-
|
|
82
|
-
if (!dbUser && !store.isLoadingLogin()) {
|
|
83
|
-
// afUser exists but dbUser doesn't exist yet, we should create it
|
|
84
|
-
const newUser = {
|
|
85
|
-
__id: afUser.uid,
|
|
86
|
-
name: afUser.displayName || afUser.email,
|
|
87
|
-
photoURL: afUser.photoURL || null,
|
|
88
|
-
isAdmin: false,
|
|
89
|
-
consented: false,
|
|
90
|
-
accessState: AccessState.SUBMIT_INTEREST,
|
|
91
|
-
};
|
|
92
|
-
try {
|
|
93
|
-
await db.addEntity('users', newUser);
|
|
94
|
-
await db.addEntity('userPrivates', {
|
|
95
|
-
__id: afUser.uid,
|
|
96
|
-
email: afUser.email,
|
|
97
|
-
});
|
|
98
|
-
} catch (e) {
|
|
99
|
-
console.error(`[AuthStore loadAuth] Error creating new user:`, e);
|
|
100
|
-
}
|
|
101
|
-
}
|
|
102
|
-
}
|
|
103
|
-
}),
|
|
104
|
-
)),
|
|
105
|
-
async login(provider: string, params: {
|
|
106
|
-
scope?: string,
|
|
107
|
-
doNotRoute: boolean
|
|
108
|
-
} = { doNotRoute: false }): Promise<void> {
|
|
109
|
-
patchState(store, { isLoadingLogin: true });
|
|
110
|
-
|
|
111
|
-
try {
|
|
112
|
-
const loginResult = await db.login(provider, params.scope);
|
|
113
|
-
const afUser = loginResult.user;
|
|
114
|
-
patchState(store, { afUser });
|
|
115
|
-
|
|
116
|
-
const dbUser: User = await db.getEntity('users', afUser.uid);
|
|
117
|
-
|
|
118
|
-
const navLocation = ['/home'];
|
|
119
|
-
// update the user if there is already a dbUser
|
|
120
|
-
if (dbUser) {
|
|
121
|
-
const changes = {
|
|
122
|
-
name: afUser.displayName || afUser.email,
|
|
123
|
-
photoURL: afUser.photoURL || null,
|
|
124
|
-
};
|
|
125
|
-
try {
|
|
126
|
-
await userStore.update(dbUser.__id, changes);
|
|
127
|
-
await db.addEntity('userPrivates', {
|
|
128
|
-
__id: dbUser.__id,
|
|
129
|
-
email: afUser.email,
|
|
130
|
-
});
|
|
131
|
-
|
|
132
|
-
if (!params || !params.doNotRoute) {
|
|
133
|
-
router.navigate(navLocation, { queryParamsHandling: 'preserve' });
|
|
134
|
-
}
|
|
135
|
-
} catch (e) {
|
|
136
|
-
console.error(e);
|
|
137
|
-
throw e;
|
|
138
|
-
}
|
|
139
|
-
} else {
|
|
140
|
-
const newUser = {
|
|
141
|
-
__id: afUser.uid,
|
|
142
|
-
name: afUser.displayName || afUser.email,
|
|
143
|
-
photoURL: afUser.photoURL || null,
|
|
144
|
-
isAdmin: false,
|
|
145
|
-
consented: false,
|
|
146
|
-
accessState: AccessState.SUBMIT_INTEREST,
|
|
147
|
-
};
|
|
148
|
-
try {
|
|
149
|
-
await userStore.add(newUser);
|
|
150
|
-
await db.addEntity('userPrivates', {
|
|
151
|
-
__id: afUser.uid,
|
|
152
|
-
email: afUser.email,
|
|
153
|
-
});
|
|
154
|
-
|
|
155
|
-
if (!params || !params.doNotRoute) {
|
|
156
|
-
router.navigate(navLocation, { queryParamsHandling: 'preserve' });
|
|
157
|
-
}
|
|
158
|
-
} catch (e) {
|
|
159
|
-
console.error(`[AuthStore login] Error creating new user:`, e);
|
|
160
|
-
throw e;
|
|
161
|
-
}
|
|
162
|
-
}
|
|
163
|
-
} catch (e) {
|
|
164
|
-
switch (e.code) {
|
|
165
|
-
case 'auth/account-exists-with-different-credential': {
|
|
166
|
-
db.loginLink(e);
|
|
21
|
+
withMethods((store, router = inject(Router), injector = inject(Injector)) => ({
|
|
22
|
+
async deleteAnonymousAccount(): Promise<void> {
|
|
23
|
+
await store.deleteGuestAccount();
|
|
24
|
+
await router.navigate(['/landing']);
|
|
25
|
+
},
|
|
26
|
+
async logout(params?: { doNotRoute: boolean }): Promise<void> {
|
|
27
|
+
try {
|
|
28
|
+
const session = store.afUser();
|
|
29
|
+
if (session?.isAnonymous) {
|
|
30
|
+
const dialog = injector.get(MatDialog, null);
|
|
31
|
+
if (dialog) {
|
|
32
|
+
const result = await firstValueFrom(dialog.open(GuestDeletionDialogComponent).afterClosed());
|
|
33
|
+
if (result === 'save') {
|
|
34
|
+
await router.navigate(['/account']);
|
|
35
|
+
return;
|
|
167
36
|
}
|
|
37
|
+
if (result !== true) return;
|
|
168
38
|
}
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
patchState(store, { isLoadingLogin: false });
|
|
172
|
-
}
|
|
173
|
-
},
|
|
174
|
-
async logout(params?: { doNotRoute: boolean }): Promise<void> {
|
|
175
|
-
try {
|
|
176
|
-
await db.logout();
|
|
177
|
-
if (!params || !params.doNotRoute) {
|
|
178
|
-
router.navigate(['/landing']);
|
|
179
|
-
}
|
|
180
|
-
} catch (e) {
|
|
181
|
-
console.error(e);
|
|
182
|
-
throw e;
|
|
39
|
+
await this.deleteAnonymousAccount();
|
|
40
|
+
return;
|
|
183
41
|
}
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
42
|
+
|
|
43
|
+
await store.signOut();
|
|
44
|
+
if (!params || !params.doNotRoute) await router.navigate(['/landing']);
|
|
45
|
+
} catch (e) {
|
|
46
|
+
console.error(e);
|
|
47
|
+
throw e;
|
|
48
|
+
}
|
|
49
|
+
},
|
|
50
|
+
})),
|
|
187
51
|
);
|
|
@@ -1,13 +1,15 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import { withEntitiesForMockDB } from '
|
|
1
|
+
import { dataTimestampNow } from '@tech4good/platform-data';
|
|
2
|
+
import { defineEntityMock, withEntitiesForMockDB } from '@tech4good/platform-data/testing';
|
|
3
3
|
import { signalStore } from '@ngrx/signals';
|
|
4
|
-
import { User, AccessState } from './user.model';
|
|
4
|
+
import { User, AccessState, userEntity } from './user.model';
|
|
5
5
|
|
|
6
|
+
/** Mock backend storage; frontend entity stores read from it through MockDataService. */
|
|
6
7
|
export const UserMockDB = signalStore(
|
|
7
8
|
{ providedIn: 'root' },
|
|
8
|
-
withEntitiesForMockDB<User>(
|
|
9
|
+
withEntitiesForMockDB<User>(userEntity.collection),
|
|
9
10
|
);
|
|
10
11
|
|
|
12
|
+
/** Build a complete stored record for tests, allowing domain fields and metadata to be overridden. */
|
|
11
13
|
export function createMockUser(overrides?: Partial<User>): User {
|
|
12
14
|
return {
|
|
13
15
|
__id: 'mock-user-id',
|
|
@@ -15,8 +17,8 @@ export function createMockUser(overrides?: Partial<User>): User {
|
|
|
15
17
|
isAdmin: false,
|
|
16
18
|
accessState: AccessState.DONE,
|
|
17
19
|
consented: true,
|
|
18
|
-
_createdAt:
|
|
19
|
-
_updatedAt:
|
|
20
|
+
_createdAt: dataTimestampNow(),
|
|
21
|
+
_updatedAt: dataTimestampNow(),
|
|
20
22
|
_deleted: false,
|
|
21
23
|
...overrides,
|
|
22
24
|
};
|
|
@@ -28,8 +30,8 @@ export const MOCK_USER_WAITING: User = {
|
|
|
28
30
|
accessState: AccessState.WAITING,
|
|
29
31
|
isAdmin: false,
|
|
30
32
|
consented: false,
|
|
31
|
-
_createdAt:
|
|
32
|
-
_updatedAt:
|
|
33
|
+
_createdAt: dataTimestampNow(),
|
|
34
|
+
_updatedAt: dataTimestampNow(),
|
|
33
35
|
_deleted: false,
|
|
34
36
|
};
|
|
35
37
|
|
|
@@ -39,8 +41,8 @@ export const MOCK_USER_DONE: User = {
|
|
|
39
41
|
accessState: AccessState.DONE,
|
|
40
42
|
isAdmin: false,
|
|
41
43
|
consented: false,
|
|
42
|
-
_createdAt:
|
|
43
|
-
_updatedAt:
|
|
44
|
+
_createdAt: dataTimestampNow(),
|
|
45
|
+
_updatedAt: dataTimestampNow(),
|
|
44
46
|
_deleted: false,
|
|
45
47
|
};
|
|
46
48
|
|
|
@@ -53,14 +55,15 @@ export const USER_DB: User[] = [
|
|
|
53
55
|
{
|
|
54
56
|
__id: '1',
|
|
55
57
|
name: 'User A',
|
|
56
|
-
photoURL: 'http://loremflickr.com/100/100?lock=1',
|
|
57
58
|
isAdmin: true,
|
|
58
|
-
consented:
|
|
59
|
-
accessState: AccessState.
|
|
60
|
-
_createdAt:
|
|
61
|
-
_updatedAt:
|
|
59
|
+
consented: true,
|
|
60
|
+
accessState: AccessState.DONE,
|
|
61
|
+
_createdAt: dataTimestampNow(),
|
|
62
|
+
_updatedAt: dataTimestampNow(),
|
|
62
63
|
_deleted: false,
|
|
63
64
|
},
|
|
64
65
|
...MOCK_USER_LIST,
|
|
65
66
|
];
|
|
66
67
|
|
|
68
|
+
/** Discovered mock wiring; tests can replace seeds through provideAppMocks({ collections: ... }). */
|
|
69
|
+
export const userMock = defineEntityMock(userEntity, { store: UserMockDB, seeds: USER_DB });
|
|
@@ -1,17 +1,13 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { defineEntity, DataEntity, DataTimestamp } from '@tech4good/platform-data';
|
|
2
2
|
|
|
3
3
|
/** user data */
|
|
4
|
-
export interface User {
|
|
5
|
-
__id: string;
|
|
6
|
-
_createdAt?: Timestamp;
|
|
7
|
-
_updatedAt?: Timestamp;
|
|
8
|
-
_deleted?: boolean;
|
|
4
|
+
export interface User extends DataEntity {
|
|
9
5
|
name: string;
|
|
10
|
-
photoURL?: string;
|
|
6
|
+
photoURL?: string | null;
|
|
11
7
|
isAdmin: boolean;
|
|
12
8
|
accessState: AccessState;
|
|
13
9
|
consented: boolean;
|
|
14
|
-
joinedWaitlistAt?:
|
|
10
|
+
joinedWaitlistAt?: DataTimestamp;
|
|
15
11
|
/** Admin-only: routes where auth guards are bypassed for testing/debugging. */
|
|
16
12
|
adminOverridePaths?: string[];
|
|
17
13
|
}
|
|
@@ -22,3 +18,6 @@ export enum AccessState {
|
|
|
22
18
|
CONSENT = '03 - consent', // on consent form
|
|
23
19
|
DONE = 'done', // finished with the access flow
|
|
24
20
|
}
|
|
21
|
+
|
|
22
|
+
/** Collection identity discovered by t4g-entities; keep the name literal and this export in the model file. */
|
|
23
|
+
export const userEntity = defineEntity<User>({ collection: 'users' });
|
|
@@ -1,41 +1,45 @@
|
|
|
1
1
|
import { inject, effect, WritableSignal } from '@angular/core';
|
|
2
2
|
import { signalStore, patchState, withState, withMethods } from '@ngrx/signals';
|
|
3
3
|
import { withEntities, removeEntity, updateEntity, setEntity, removeEntities, setEntities } from '@ngrx/signals/entities';
|
|
4
|
-
import { EntityLoadQuery, EntityStreamQuery, selectEntities, processLoadQueries, withEntitiesAndDBMethods } from '
|
|
5
|
-
import { QueryParams, QueryOptions
|
|
6
|
-
import {
|
|
4
|
+
import { EntityLoadQuery, EntityStreamQuery, selectEntities, processLoadQueries, withEntitiesAndDBMethods } from '@tech4good/platform-data';
|
|
5
|
+
import { QueryParams, QueryOptions } from '@tech4good/platform-data';
|
|
6
|
+
import { DataEntity } from '@tech4good/platform-data';
|
|
7
|
+
import { User, userEntity } from '../user/user.model';
|
|
7
8
|
|
|
9
|
+
/** Nested one-shot load descriptor; construction alone does not fetch records. */
|
|
8
10
|
export class LoadUser extends EntityLoadQuery<User> {
|
|
9
11
|
constructor(
|
|
10
12
|
store,
|
|
11
13
|
queryParams: QueryParams,
|
|
12
14
|
queryOptions: QueryOptions,
|
|
13
|
-
loadQueries?: (entity: User) => EntityLoadQuery<
|
|
15
|
+
loadQueries?: (entity: User) => EntityLoadQuery<DataEntity>[],
|
|
14
16
|
) {
|
|
15
|
-
super(
|
|
17
|
+
super(userEntity.collection, store, queryParams, queryOptions, loadQueries);
|
|
16
18
|
}
|
|
17
19
|
|
|
18
|
-
static create(store, queryParams: QueryParams, queryOptions: QueryOptions, loadQueries?: (entity: User) => EntityLoadQuery<
|
|
20
|
+
static create(store, queryParams: QueryParams, queryOptions: QueryOptions, loadQueries?: (entity: User) => EntityLoadQuery<DataEntity>[]): LoadUser {
|
|
19
21
|
return new LoadUser(store, queryParams, queryOptions, loadQueries);
|
|
20
22
|
}
|
|
21
23
|
}
|
|
22
24
|
|
|
25
|
+
/** Nested live-query descriptor, scoped to the calling component by its injector. */
|
|
23
26
|
export class StreamUser extends EntityStreamQuery<User> {
|
|
24
27
|
constructor(
|
|
25
28
|
store,
|
|
26
29
|
queryParams: QueryParams,
|
|
27
30
|
queryOptions: QueryOptions,
|
|
28
|
-
streamQueries?: (entity: User) => EntityStreamQuery<
|
|
31
|
+
streamQueries?: (entity: User) => EntityStreamQuery<DataEntity>[],
|
|
29
32
|
) {
|
|
30
|
-
super(
|
|
33
|
+
super(userEntity.collection, store, queryParams, queryOptions, streamQueries);
|
|
31
34
|
}
|
|
32
35
|
|
|
33
|
-
static create(store, queryParams: QueryParams, queryOptions: QueryOptions, streamQueries?: (entity: User) => EntityStreamQuery<
|
|
36
|
+
static create(store, queryParams: QueryParams, queryOptions: QueryOptions, streamQueries?: (entity: User) => EntityStreamQuery<DataEntity>[]): StreamUser {
|
|
34
37
|
return new StreamUser(store, queryParams, queryOptions, streamQueries);
|
|
35
38
|
}
|
|
36
39
|
}
|
|
37
40
|
|
|
41
|
+
/** One shared root store for this collection. The app explicitly chooses when to clear its records. */
|
|
38
42
|
export const UserStore = signalStore(
|
|
39
43
|
{ providedIn: 'root' },
|
|
40
|
-
withEntitiesAndDBMethods<User>(
|
|
44
|
+
withEntitiesAndDBMethods<User>(userEntity.collection),
|
|
41
45
|
);
|
|
@@ -1,21 +1,31 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import { UserContext } from './user-context.model';
|
|
3
|
-
import { withEntitiesForMockDB } from '
|
|
1
|
+
import { dataTimestampNow } from '@tech4good/platform-data';
|
|
2
|
+
import { UserContext, userContextEntity } from './user-context.model';
|
|
3
|
+
import { defineEntityMock, withEntitiesForMockDB } from '@tech4good/platform-data/testing';
|
|
4
4
|
import { signalStore } from '@ngrx/signals';
|
|
5
5
|
import { USER_DB } from '../user/user.mock';
|
|
6
6
|
|
|
7
|
+
/** Mock backend storage; frontend entity stores read from it through MockDataService. */
|
|
7
8
|
export const UserContextMockDB = signalStore(
|
|
8
9
|
{ providedIn: 'root' },
|
|
9
|
-
withEntitiesForMockDB<UserContext>(
|
|
10
|
+
withEntitiesForMockDB<UserContext>(userContextEntity.collection),
|
|
10
11
|
);
|
|
11
12
|
|
|
13
|
+
/** Build a complete stored record for tests, allowing domain fields and metadata to be overridden. */
|
|
14
|
+
export function createMockUserContext(overrides?: Partial<UserContext>): UserContext {
|
|
15
|
+
return {
|
|
16
|
+
__id: 'mock-context-id', __userId: 'mock-user-id', questionOne: '', questionTwo: '',
|
|
17
|
+
_createdAt: dataTimestampNow(), _updatedAt: dataTimestampNow(), _deleted: false,
|
|
18
|
+
...overrides,
|
|
19
|
+
};
|
|
20
|
+
}
|
|
21
|
+
|
|
12
22
|
export const MOCK_USERCONTEXT_WAITING: UserContext = {
|
|
13
23
|
__id: 'uc-waiting',
|
|
14
24
|
__userId: 'u1',
|
|
15
25
|
questionOne: 'Response to question one',
|
|
16
26
|
questionTwo: 'Response to question two',
|
|
17
|
-
_createdAt:
|
|
18
|
-
_updatedAt:
|
|
27
|
+
_createdAt: dataTimestampNow(),
|
|
28
|
+
_updatedAt: dataTimestampNow(),
|
|
19
29
|
_deleted: false,
|
|
20
30
|
};
|
|
21
31
|
|
|
@@ -29,11 +39,13 @@ export const USERCONTEXT_DB = [
|
|
|
29
39
|
__userId: USER_DB[0].__id,
|
|
30
40
|
questionOne: 'test',
|
|
31
41
|
questionTwo: 'test',
|
|
32
|
-
_createdAt:
|
|
33
|
-
_updatedAt:
|
|
42
|
+
_createdAt: dataTimestampNow(),
|
|
43
|
+
_updatedAt: dataTimestampNow(),
|
|
34
44
|
_deleted: false,
|
|
35
45
|
},
|
|
36
46
|
...MOCK_USERCONTEXT_LIST,
|
|
37
47
|
];
|
|
38
48
|
|
|
39
49
|
|
|
50
|
+
/** Discovered mock wiring; tests can replace seeds through provideAppMocks({ collections: ... }). */
|
|
51
|
+
export const userContextMock = defineEntityMock(userContextEntity, { store: UserContextMockDB, seeds: USERCONTEXT_DB });
|
|
@@ -1,11 +1,10 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { defineEntity, DataEntity } from '@tech4good/platform-data';
|
|
2
2
|
|
|
3
|
-
export interface UserContext {
|
|
4
|
-
__id: string;
|
|
3
|
+
export interface UserContext extends DataEntity {
|
|
5
4
|
__userId: string;
|
|
6
5
|
questionOne: string;
|
|
7
6
|
questionTwo: string;
|
|
8
|
-
_createdAt?: Timestamp;
|
|
9
|
-
_updatedAt?: Timestamp;
|
|
10
|
-
_deleted?: boolean;
|
|
11
7
|
}
|
|
8
|
+
|
|
9
|
+
/** Collection identity discovered by t4g-entities; keep the name literal and this export in the model file. */
|
|
10
|
+
export const userContextEntity = defineEntity<UserContext>({ collection: 'userContexts' });
|