@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
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { dataTimestampToDate } from '@tech4good/platform-data';
|
|
1
2
|
import { Component, OnInit, ChangeDetectionStrategy, input, output, inject, WritableSignal, Signal, signal, computed, Inject, Injector } from '@angular/core';
|
|
2
3
|
import { DatePipe } from '@angular/common';
|
|
3
4
|
import { MatTable, MatColumnDef, MatHeaderCellDef, MatHeaderCell, MatCellDef, MatCell, MatHeaderRowDef, MatHeaderRow, MatRowDef, MatRow } from '@angular/material/table';
|
|
@@ -101,10 +102,10 @@ export class AdminUserTableComponent implements OnInit {
|
|
|
101
102
|
|
|
102
103
|
getStateDate(user: User): Date | null {
|
|
103
104
|
if (user.accessState === AccessState.WAITING && user.joinedWaitlistAt) {
|
|
104
|
-
return user.joinedWaitlistAt
|
|
105
|
+
return dataTimestampToDate(user.joinedWaitlistAt);
|
|
105
106
|
}
|
|
106
107
|
const timestamp = user._updatedAt || user._createdAt;
|
|
107
|
-
return timestamp ? timestamp
|
|
108
|
+
return timestamp ? dataTimestampToDate(timestamp) : null;
|
|
108
109
|
}
|
|
109
110
|
|
|
110
111
|
formatAccessState(state: AccessState | 'ALL'): string {
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
<app-dev-status-bar></app-dev-status-bar>
|
|
2
1
|
<div class="content-container">
|
|
3
|
-
<app-
|
|
2
|
+
<app-dev-status-bar></app-dev-status-bar>
|
|
3
|
+
<app-guest-warning-bar></app-guest-warning-bar>
|
|
4
|
+
<t4g-redeployment-warning></t4g-redeployment-warning>
|
|
4
5
|
<router-outlet></router-outlet>
|
|
5
6
|
</div>
|
|
6
|
-
|
|
@@ -2,10 +2,9 @@ import { render } from '@testing-library/angular';
|
|
|
2
2
|
import userEvent from '@testing-library/user-event';
|
|
3
3
|
|
|
4
4
|
import { AppComponent } from './app.component';
|
|
5
|
-
import {
|
|
6
|
-
import {
|
|
7
|
-
import {
|
|
8
|
-
import { BATCH_WRITE_SERVICE } from 'src/app/core/store/batch-write.service';
|
|
5
|
+
import { provideAppMocks } from 'src/app/core/testing/app-mocks';
|
|
6
|
+
import { BatchWriteMockService } from '@tech4good/platform-data/testing';
|
|
7
|
+
import { BATCH_WRITE_SERVICE } from '@tech4good/platform-data';
|
|
9
8
|
import { LOG_SERVICE, LogInDevService } from './core/analytics/log.service';
|
|
10
9
|
|
|
11
10
|
/** Sets up the testing environment for AppComponent using render. */
|
|
@@ -16,7 +15,7 @@ async function setup() {
|
|
|
16
15
|
const view = await render(AppComponent, {
|
|
17
16
|
imports: [],
|
|
18
17
|
providers: [
|
|
19
|
-
|
|
18
|
+
...provideAppMocks(),
|
|
20
19
|
{ provide: BATCH_WRITE_SERVICE, useClass: BatchWriteMockService },
|
|
21
20
|
{ provide: LOG_SERVICE, useClass: LogInDevService },
|
|
22
21
|
],
|
|
@@ -3,9 +3,9 @@ import { Router, NavigationEnd, RouterOutlet } from '@angular/router';
|
|
|
3
3
|
import { RoutingStateService } from './core/router/routing-state.service';
|
|
4
4
|
import { TimeAnalyticsService } from './core/analytics/time-analytics.service';
|
|
5
5
|
import { AuthStore } from './core/store/auth/auth.store';
|
|
6
|
-
import { DetectRedeploymentService } from '
|
|
7
|
-
import { RedeploymentWarningComponent } from './shared/redeployment-warning/redeployment-warning.component';
|
|
6
|
+
import { DetectRedeploymentService, RedeploymentWarningComponent } from '@tech4good/platform-ui';
|
|
8
7
|
import { DevStatusBarComponent } from './shared/dev-status-bar/dev-status-bar.component';
|
|
8
|
+
import { GuestWarningBarComponent } from './shared/guest-warning-bar/guest-warning-bar.component';
|
|
9
9
|
|
|
10
10
|
@Component({
|
|
11
11
|
selector: 'app-root',
|
|
@@ -14,6 +14,7 @@ import { DevStatusBarComponent } from './shared/dev-status-bar/dev-status-bar.co
|
|
|
14
14
|
imports: [
|
|
15
15
|
RedeploymentWarningComponent,
|
|
16
16
|
DevStatusBarComponent,
|
|
17
|
+
GuestWarningBarComponent,
|
|
17
18
|
RouterOutlet,
|
|
18
19
|
],
|
|
19
20
|
})
|
|
@@ -1,17 +1,20 @@
|
|
|
1
|
+
import { provideAppDatabase } from './core/firebase/data.providers';
|
|
2
|
+
import { inject } from '@angular/core';
|
|
3
|
+
import { Firestore } from '@angular/fire/firestore';
|
|
4
|
+
import { PLATFORM_FIREBASE_AUTH } from '@tech4good/platform-auth/firebase';
|
|
5
|
+
import { providePlatformAuth } from '@tech4good/platform-auth';
|
|
6
|
+
import { providePlatformData } from '@tech4good/platform-data';
|
|
7
|
+
import { PLATFORM_FIRESTORE } from '@tech4good/platform-data/firestore';
|
|
8
|
+
import { provideMaterialDataFeedback } from '@tech4good/platform-data/material';
|
|
9
|
+
import { providePlatformLogging } from '@tech4good/platform-logging';
|
|
1
10
|
import { ApplicationConfig, provideBrowserGlobalErrorListeners, provideZonelessChangeDetection } from '@angular/core';
|
|
2
11
|
import { provideRouter, withComponentInputBinding, withPreloading, PreloadAllModules } from '@angular/router';
|
|
3
12
|
import { routes } from './app.routes';
|
|
4
13
|
import { importProvidersFrom } from '@angular/core';
|
|
5
14
|
import { provideFirebaseApp, getApp, initializeApp } from '@angular/fire/app';
|
|
6
15
|
import { provideFirestore, initializeFirestore, persistentLocalCache, persistentMultipleTabManager } from '@angular/fire/firestore';
|
|
7
|
-
import { provideAuth, getAuth } from '@angular/fire/auth';
|
|
16
|
+
import { Auth, provideAuth, getAuth } from '@angular/fire/auth';
|
|
8
17
|
import { environment } from '../environments/environment';
|
|
9
|
-
import { FirebaseService } from './core/firebase/firebase.service';
|
|
10
|
-
import { FirebaseMockService } from './core/firebase/firebase.mock.service';
|
|
11
|
-
import { DATABASE_SERVICE } from './core/firebase/database.service';
|
|
12
|
-
import { BATCH_WRITE_SERVICE } from './core/store/batch-write.service';
|
|
13
|
-
import { BatchWriteMockService } from './core/store/batch-write.mock.service';
|
|
14
|
-
import { BatchWriteDBService } from './core/store/batch-write.firebase.service';
|
|
15
18
|
import { LogInDevService, LogDBService, LOG_SERVICE } from './core/analytics/log.service';
|
|
16
19
|
import { getFunctions, provideFunctions } from '@angular/fire/functions';
|
|
17
20
|
import { getPerformance, providePerformance } from '@angular/fire/performance';
|
|
@@ -40,6 +43,17 @@ const firebaseProviders = !environment.production && environment['mockDB'] ? []
|
|
|
40
43
|
|
|
41
44
|
export const appConfig: ApplicationConfig = {
|
|
42
45
|
providers: [
|
|
46
|
+
// Logging is app-wide; storage and the DevTools handle are development-only.
|
|
47
|
+
providePlatformLogging({
|
|
48
|
+
persist: !environment.production,
|
|
49
|
+
exposeDebugConsole: !environment.production,
|
|
50
|
+
}),
|
|
51
|
+
providePlatformData(),
|
|
52
|
+
providePlatformAuth(),
|
|
53
|
+
{ provide: PLATFORM_FIREBASE_AUTH, useFactory: () => inject(Auth) },
|
|
54
|
+
provideMaterialDataFeedback(),
|
|
55
|
+
{ provide: PLATFORM_FIRESTORE, useFactory: () => inject(Firestore) },
|
|
56
|
+
...provideAppDatabase(),
|
|
43
57
|
provideBrowserGlobalErrorListeners(),
|
|
44
58
|
provideZonelessChangeDetection(),
|
|
45
59
|
provideRouter(
|
|
@@ -52,13 +66,5 @@ export const appConfig: ApplicationConfig = {
|
|
|
52
66
|
provide: LOG_SERVICE,
|
|
53
67
|
useClass: !environment.production ? LogInDevService : LogDBService,
|
|
54
68
|
},
|
|
55
|
-
{
|
|
56
|
-
provide: DATABASE_SERVICE,
|
|
57
|
-
useClass: !environment.production && environment['mockDB'] ? FirebaseMockService : FirebaseService,
|
|
58
|
-
},
|
|
59
|
-
{
|
|
60
|
-
provide: BATCH_WRITE_SERVICE,
|
|
61
|
-
useClass: !environment.production && environment['mockDB'] ? BatchWriteMockService : BatchWriteDBService,
|
|
62
|
-
},
|
|
63
69
|
],
|
|
64
70
|
};
|
|
@@ -12,6 +12,10 @@ export const routes: Routes = [
|
|
|
12
12
|
.then((mod) => mod.LandingComponent), canActivate: [redirectIfAuthenticated] },
|
|
13
13
|
{ path: 'login', loadComponent: () => import('./first-time/login/login.component')
|
|
14
14
|
.then((mod) => mod.LoginComponent), canActivate: [redirectIfAuthenticated] },
|
|
15
|
+
{ path: 'auth/action', loadComponent: () => import('./first-time/auth-action/auth-action.component')
|
|
16
|
+
.then((mod) => mod.AuthActionComponent) },
|
|
17
|
+
{ path: 'email-link', loadComponent: () => import('./first-time/email-link/email-link.component')
|
|
18
|
+
.then((mod) => mod.EmailLinkComponent) },
|
|
15
19
|
// First-Time User Experience Routes (gated pages)
|
|
16
20
|
{ path: 'consent', loadComponent: () => import('./first-time/consent/consent.component')
|
|
17
21
|
.then((mod) => mod.ConsentComponent), canActivate: [requireAuth, consentGuard] },
|
|
@@ -20,6 +24,8 @@ export const routes: Routes = [
|
|
|
20
24
|
{ path: 'onboarding', loadComponent: () => import('./first-time/onboarding/onboarding.component')
|
|
21
25
|
.then((mod) => mod.OnboardingComponent), canActivate: [requireAuthAndConsent] },
|
|
22
26
|
// Main Routes
|
|
27
|
+
{ path: 'account', loadComponent: () => import('./main/account-profile/account-profile.component')
|
|
28
|
+
.then((mod) => mod.AccountProfileComponent), canActivate: [requireAuth] },
|
|
23
29
|
{ path: 'home', loadComponent: () => import('./main/home/home.component')
|
|
24
30
|
.then((mod) => mod.HomeComponent), canActivate: [requireAuthAndConsent] },
|
|
25
31
|
{ path: '', loadComponent: () => import('./first-time/landing/landing.component')
|
|
@@ -5,10 +5,9 @@ import { AuthService } from './core/auth/auth.service';
|
|
|
5
5
|
import { routes } from './app.routes';
|
|
6
6
|
import { of } from 'rxjs';
|
|
7
7
|
import { AccessState, User } from './core/store/user/user.model';
|
|
8
|
-
import {
|
|
9
|
-
import {
|
|
10
|
-
import {
|
|
11
|
-
import { BATCH_WRITE_SERVICE } from './core/store/batch-write.service';
|
|
8
|
+
import { provideAppMocks } from 'src/app/core/testing/app-mocks';
|
|
9
|
+
import { BatchWriteMockService } from '@tech4good/platform-data/testing';
|
|
10
|
+
import { BATCH_WRITE_SERVICE } from '@tech4good/platform-data';
|
|
12
11
|
import { LOG_SERVICE, LogInDevService } from './core/analytics/log.service';
|
|
13
12
|
import { AuthStore } from './core/store/auth/auth.store';
|
|
14
13
|
import { signal } from '@angular/core';
|
|
@@ -18,12 +17,13 @@ import { createMockUser } from './core/store/user/user.mock';
|
|
|
18
17
|
describe('Core Auth Routing', () => {
|
|
19
18
|
let harness: RouterTestingHarness;
|
|
20
19
|
let router: Router;
|
|
21
|
-
let mockAuthService: { resolveUser: jest.Mock };
|
|
20
|
+
let mockAuthService: { resolveUser: jest.Mock; resolveSession: jest.Mock };
|
|
22
21
|
let mockUserSignal: any;
|
|
23
22
|
|
|
24
23
|
beforeEach(async () => {
|
|
25
24
|
mockAuthService = {
|
|
26
25
|
resolveUser: jest.fn().mockReturnValue(of(null)),
|
|
26
|
+
resolveSession: jest.fn().mockReturnValue(of(null)),
|
|
27
27
|
};
|
|
28
28
|
mockUserSignal = signal(null);
|
|
29
29
|
|
|
@@ -32,7 +32,7 @@ describe('Core Auth Routing', () => {
|
|
|
32
32
|
provideRouter(routes),
|
|
33
33
|
{ provide: AuthService, useValue: mockAuthService },
|
|
34
34
|
{ provide: AuthStore, useValue: { user: mockUserSignal, isLoadingLogin: signal(false) } },
|
|
35
|
-
|
|
35
|
+
...provideAppMocks(),
|
|
36
36
|
{ provide: BATCH_WRITE_SERVICE, useClass: BatchWriteMockService },
|
|
37
37
|
{ provide: LOG_SERVICE, useClass: LogInDevService },
|
|
38
38
|
],
|
|
@@ -53,7 +53,7 @@ describe('Core Auth Routing', () => {
|
|
|
53
53
|
expect(router.url).toEqual('/landing');
|
|
54
54
|
});
|
|
55
55
|
|
|
56
|
-
it('should intercept navigation to /admin and redirect to /
|
|
56
|
+
it('should intercept navigation to /admin and redirect through /landing to /home', async () => {
|
|
57
57
|
await harness.navigateByUrl('/admin');
|
|
58
58
|
// Wait for async routing to settle
|
|
59
59
|
await harness.fixture.whenStable();
|
|
@@ -64,6 +64,7 @@ describe('Core Auth Routing', () => {
|
|
|
64
64
|
describe('Authenticated User (Standard)', () => {
|
|
65
65
|
beforeEach(() => {
|
|
66
66
|
mockAuthService.resolveUser.mockReturnValue(of(createMockUser()));
|
|
67
|
+
mockAuthService.resolveSession.mockReturnValue(of({ isAnonymous: false, emailVerified: true }));
|
|
67
68
|
mockUserSignal.set(createMockUser());
|
|
68
69
|
});
|
|
69
70
|
|
|
@@ -73,7 +74,7 @@ describe('Core Auth Routing', () => {
|
|
|
73
74
|
expect(router.url).toEqual('/home');
|
|
74
75
|
});
|
|
75
76
|
|
|
76
|
-
it('should intercept navigation to /admin and redirect to /
|
|
77
|
+
it('should intercept navigation to /admin and redirect to /landing', async () => {
|
|
77
78
|
await harness.navigateByUrl('/admin');
|
|
78
79
|
await harness.fixture.whenStable();
|
|
79
80
|
expect(router.url).toEqual('/home');
|
|
@@ -82,7 +83,10 @@ describe('Core Auth Routing', () => {
|
|
|
82
83
|
|
|
83
84
|
describe('Admin User', () => {
|
|
84
85
|
beforeEach(() => {
|
|
85
|
-
mockAuthService.resolveUser.mockReturnValue(
|
|
86
|
+
mockAuthService.resolveUser.mockReturnValue(
|
|
87
|
+
of(createMockUser({ isAdmin: true, __id: 'admin1' })),
|
|
88
|
+
);
|
|
89
|
+
mockAuthService.resolveSession.mockReturnValue(of({ isAnonymous: false, emailVerified: true }));
|
|
86
90
|
mockUserSignal.set(createMockUser({ isAdmin: true, __id: 'admin1' }));
|
|
87
91
|
});
|
|
88
92
|
|
|
@@ -3,7 +3,7 @@ import { signal, Injector } from '@angular/core';
|
|
|
3
3
|
import { Router, NavigationEnd, Event as RouterEvent } from '@angular/router';
|
|
4
4
|
import { Subject, BehaviorSubject, of } from 'rxjs';
|
|
5
5
|
import { TimeAnalyticsService } from './time-analytics.service';
|
|
6
|
-
import {
|
|
6
|
+
import { AUTH_ACCESS } from '@tech4good/platform-auth';
|
|
7
7
|
import { LOG_SERVICE } from './log.service';
|
|
8
8
|
import { SessionLocalStorageService } from '../local-storage/session-local-storage.service';
|
|
9
9
|
import { SessionService } from '../local-storage/session.service';
|
|
@@ -45,7 +45,7 @@ describe('TimeAnalyticsService', () => {
|
|
|
45
45
|
providers: [
|
|
46
46
|
TimeAnalyticsService,
|
|
47
47
|
{ provide: Router, useValue: routerMock },
|
|
48
|
-
{ provide:
|
|
48
|
+
{ provide: AUTH_ACCESS, useValue: dbMock },
|
|
49
49
|
{ provide: LOG_SERVICE, useValue: logMock },
|
|
50
50
|
{ provide: SessionLocalStorageService, useValue: localMock },
|
|
51
51
|
{ provide: SessionService, useValue: sessionMock },
|
|
@@ -131,13 +131,30 @@ describe('TimeAnalyticsService', () => {
|
|
|
131
131
|
0: 2500,
|
|
132
132
|
1: 'button',
|
|
133
133
|
2: 'search-submit',
|
|
134
|
-
3: 'query-string',
|
|
134
|
+
3: JSON.stringify({ value: 'query-string' }),
|
|
135
135
|
});
|
|
136
136
|
|
|
137
137
|
// Cleanup
|
|
138
138
|
dateSpy.mockRestore();
|
|
139
139
|
});
|
|
140
140
|
|
|
141
|
+
it('keeps authentication attribution inside the four-field properties tuple', () => {
|
|
142
|
+
const properties = {
|
|
143
|
+
method: 'google',
|
|
144
|
+
outcome: 'success',
|
|
145
|
+
authenticatedUserId: 'user-123',
|
|
146
|
+
};
|
|
147
|
+
|
|
148
|
+
service.trackInteraction('onboarding', 'auth_result', properties);
|
|
149
|
+
|
|
150
|
+
expect((service as any).interactionsAtRoute[0]).toEqual({
|
|
151
|
+
0: expect.any(Number),
|
|
152
|
+
1: 'onboarding',
|
|
153
|
+
2: 'auth_result',
|
|
154
|
+
3: JSON.stringify(properties),
|
|
155
|
+
});
|
|
156
|
+
});
|
|
157
|
+
|
|
141
158
|
it('should serialize objects as JSON strings when tracking interactions', () => {
|
|
142
159
|
let currentTime = 1000;
|
|
143
160
|
const dateSpy = jest.spyOn(Date, 'now').mockImplementation(() => currentTime);
|
|
@@ -192,35 +209,35 @@ describe('TimeAnalyticsService', () => {
|
|
|
192
209
|
|
|
193
210
|
service.startTimeLogging();
|
|
194
211
|
|
|
195
|
-
// 1. User routes to /
|
|
212
|
+
// 1. User routes to /home at T=1000
|
|
196
213
|
currentTime = 1000;
|
|
197
|
-
routerEvents$.next(new NavigationEnd(1, '/
|
|
214
|
+
routerEvents$.next(new NavigationEnd(1, '/home', '/home'));
|
|
198
215
|
|
|
199
|
-
const
|
|
200
|
-
service.registerState('
|
|
216
|
+
const itemSignal = signal<string | null>('item-1');
|
|
217
|
+
service.registerState('itemId', itemSignal, TestBed.inject(Injector));
|
|
201
218
|
TestBed.flushEffects();
|
|
202
219
|
|
|
203
220
|
// Initial click at T=1000
|
|
204
221
|
document.dispatchEvent(new Event('click'));
|
|
205
222
|
|
|
206
|
-
// 2. User interacts again on
|
|
223
|
+
// 2. User interacts again on item-1 at T=2000
|
|
207
224
|
currentTime = 2000;
|
|
208
225
|
document.dispatchEvent(new Event('click'));
|
|
209
226
|
|
|
210
|
-
// 3. User changes state to
|
|
227
|
+
// 3. User changes state to item-2 at T=3000
|
|
211
228
|
currentTime = 3000;
|
|
212
|
-
|
|
229
|
+
itemSignal.set('item-2');
|
|
213
230
|
TestBed.flushEffects();
|
|
214
231
|
document.dispatchEvent(new Event('click'));
|
|
215
232
|
|
|
216
|
-
// rawLog should be called for
|
|
233
|
+
// rawLog should be called for item-1
|
|
217
234
|
expect(logService.rawLog).toHaveBeenCalledTimes(1);
|
|
218
|
-
const
|
|
219
|
-
expect(
|
|
220
|
-
expect(
|
|
221
|
-
expect(
|
|
235
|
+
const item1Log = logService.rawLog.mock.calls[0][0];
|
|
236
|
+
expect(item1Log.route).toEqual('/home');
|
|
237
|
+
expect(item1Log.state).toEqual({ itemId: 'item-1' });
|
|
238
|
+
expect(item1Log.time.find((t: any) => t.type === 'active').total).toEqual(1000);
|
|
222
239
|
|
|
223
|
-
// 4. User interacts again on
|
|
240
|
+
// 4. User interacts again on item-2 at T=4000
|
|
224
241
|
currentTime = 4000;
|
|
225
242
|
document.dispatchEvent(new Event('click'));
|
|
226
243
|
|
|
@@ -229,12 +246,12 @@ describe('TimeAnalyticsService', () => {
|
|
|
229
246
|
routerEvents$.next(new NavigationEnd(2, '/profile', '/profile'));
|
|
230
247
|
document.dispatchEvent(new Event('click'));
|
|
231
248
|
|
|
232
|
-
// rawLog should be called for
|
|
249
|
+
// rawLog should be called for item-2
|
|
233
250
|
expect(logService.rawLog).toHaveBeenCalledTimes(2);
|
|
234
|
-
const
|
|
235
|
-
expect(
|
|
236
|
-
expect(
|
|
237
|
-
expect(
|
|
251
|
+
const item2Log = logService.rawLog.mock.calls[1][0];
|
|
252
|
+
expect(item2Log.route).toEqual('/home');
|
|
253
|
+
expect(item2Log.state).toEqual({ itemId: 'item-2' });
|
|
254
|
+
expect(item2Log.time.find((t: any) => t.type === 'active').total).toEqual(2000);
|
|
238
255
|
|
|
239
256
|
dateSpy.mockRestore();
|
|
240
257
|
});
|
|
@@ -247,10 +264,10 @@ describe('TimeAnalyticsService', () => {
|
|
|
247
264
|
service.startTimeLogging();
|
|
248
265
|
|
|
249
266
|
currentTime = 1000;
|
|
250
|
-
routerEvents$.next(new NavigationEnd(1, '/
|
|
267
|
+
routerEvents$.next(new NavigationEnd(1, '/home', '/home'));
|
|
251
268
|
|
|
252
|
-
const
|
|
253
|
-
service.registerState('
|
|
269
|
+
const itemSignal = signal<string | null>('item-100');
|
|
270
|
+
service.registerState('itemId', itemSignal, TestBed.inject(Injector));
|
|
254
271
|
TestBed.flushEffects();
|
|
255
272
|
|
|
256
273
|
document.dispatchEvent(new Event('click'));
|
|
@@ -260,23 +277,23 @@ describe('TimeAnalyticsService', () => {
|
|
|
260
277
|
|
|
261
278
|
// Update signal value and flush Angular signal effects
|
|
262
279
|
currentTime = 3000;
|
|
263
|
-
|
|
280
|
+
itemSignal.set('item-200');
|
|
264
281
|
TestBed.flushEffects();
|
|
265
282
|
document.dispatchEvent(new Event('click'));
|
|
266
283
|
|
|
267
|
-
// Should flush log for
|
|
284
|
+
// Should flush log for item-100
|
|
268
285
|
expect(logService.rawLog).toHaveBeenCalledTimes(1);
|
|
269
286
|
const log1 = logService.rawLog.mock.calls[0][0];
|
|
270
|
-
expect(log1.state).toEqual({
|
|
287
|
+
expect(log1.state).toEqual({ itemId: 'item-100' });
|
|
271
288
|
|
|
272
289
|
currentTime = 4000;
|
|
273
290
|
routerEvents$.next(new NavigationEnd(2, '/profile', '/profile'));
|
|
274
291
|
document.dispatchEvent(new Event('click'));
|
|
275
292
|
|
|
276
|
-
// Should flush log for
|
|
293
|
+
// Should flush log for item-200
|
|
277
294
|
expect(logService.rawLog).toHaveBeenCalledTimes(2);
|
|
278
295
|
const log2 = logService.rawLog.mock.calls[1][0];
|
|
279
|
-
expect(log2.state).toEqual({
|
|
296
|
+
expect(log2.state).toEqual({ itemId: 'item-200' });
|
|
280
297
|
|
|
281
298
|
dateSpy.mockRestore();
|
|
282
299
|
});
|
|
@@ -17,7 +17,7 @@ import {
|
|
|
17
17
|
scan,
|
|
18
18
|
} from 'rxjs/operators';
|
|
19
19
|
import { LOG_SERVICE, LogService } from './log.service';
|
|
20
|
-
import {
|
|
20
|
+
import { AUTH_ACCESS, AuthAccess } from '@tech4good/platform-auth';
|
|
21
21
|
import { SessionLocalStorageService } from '../local-storage/session-local-storage.service';
|
|
22
22
|
import { SessionService } from '../local-storage/session.service';
|
|
23
23
|
|
|
@@ -36,7 +36,7 @@ export interface Interaction {
|
|
|
36
36
|
0: number;
|
|
37
37
|
1: string;
|
|
38
38
|
2: string;
|
|
39
|
-
3: string;
|
|
39
|
+
3: string | null;
|
|
40
40
|
}
|
|
41
41
|
|
|
42
42
|
/**
|
|
@@ -89,7 +89,7 @@ export class TimeAnalyticsService {
|
|
|
89
89
|
|
|
90
90
|
/**
|
|
91
91
|
* Map storing active registered state key-value streams.
|
|
92
|
-
* Key: state dimension name (e.g. '
|
|
92
|
+
* Key: state dimension name (e.g. 'itemId')
|
|
93
93
|
* Value: Observable emitting the current string/null state value
|
|
94
94
|
*/
|
|
95
95
|
private registeredStatesMap = new Map<string, Observable<string | null>>();
|
|
@@ -150,6 +150,15 @@ export class TimeAnalyticsService {
|
|
|
150
150
|
/** Interactions data at latest route. */
|
|
151
151
|
private interactionsAtRoute: Interaction[] = null;
|
|
152
152
|
|
|
153
|
+
/** Serializes every non-null payload as JSON for consistent warehouse parsing. */
|
|
154
|
+
private serializeInteractionData(data: unknown): string | null {
|
|
155
|
+
if (data === null || data === undefined) return null;
|
|
156
|
+
if (typeof data !== 'object') {
|
|
157
|
+
return JSON.stringify({ value: data });
|
|
158
|
+
}
|
|
159
|
+
return JSON.stringify(data);
|
|
160
|
+
}
|
|
161
|
+
|
|
153
162
|
/**
|
|
154
163
|
* Compares two state records for shallow equality.
|
|
155
164
|
* Treats null, undefined, and empty objects `{}` as equal (empty state).
|
|
@@ -267,7 +276,7 @@ export class TimeAnalyticsService {
|
|
|
267
276
|
* `TimeAnalyticsService` flushes the active log document to Firestore and begins a new
|
|
268
277
|
* segment for the new state value.
|
|
269
278
|
*
|
|
270
|
-
* @param key State dimension key (e.g. `'
|
|
279
|
+
* @param key State dimension key (e.g. `'itemId'`)
|
|
271
280
|
* @param valueSignal Signal emitting the current state value string or null
|
|
272
281
|
* @param injector Component's Injector instance (used for `toObservable` and `DestroyRef`)
|
|
273
282
|
*
|
|
@@ -301,14 +310,14 @@ export class TimeAnalyticsService {
|
|
|
301
310
|
// Subscribe to each interaction until unsubscribe, and register that the event occured
|
|
302
311
|
// console.log('REGISTER INTERACTION', `${ix[0]}-${ix[1]}`);
|
|
303
312
|
ix[2].pipe(takeUntil(unsubscribe$)).subscribe((data) => {
|
|
304
|
-
|
|
305
|
-
|
|
306
|
-
|
|
307
|
-
|
|
308
|
-
|
|
309
|
-
}
|
|
313
|
+
const ixLog: Interaction = {
|
|
314
|
+
0: Date.now(),
|
|
315
|
+
1: String(ix[0]),
|
|
316
|
+
2: String(ix[1]),
|
|
317
|
+
3: this.serializeInteractionData(data),
|
|
318
|
+
};
|
|
310
319
|
if (!this.interactionsAtRoute) {
|
|
311
|
-
const newInteractions:
|
|
320
|
+
const newInteractions: Interaction[] = [ixLog];
|
|
312
321
|
this.interactionsAtRoute = newInteractions;
|
|
313
322
|
this.local.setItemForSession(this.IX_KEY, this.interactionsAtRoute);
|
|
314
323
|
// console.log('UPDATE INTERACTIONS', this.interactionsAtRoute);
|
|
@@ -323,12 +332,12 @@ export class TimeAnalyticsService {
|
|
|
323
332
|
|
|
324
333
|
/** Function that can be called by any component to log an interaction event imperatively. */
|
|
325
334
|
public trackInteraction(category: string, action: string, data: any = null) {
|
|
326
|
-
|
|
327
|
-
|
|
328
|
-
|
|
329
|
-
|
|
330
|
-
|
|
331
|
-
}
|
|
335
|
+
const ixLog: Interaction = {
|
|
336
|
+
0: Date.now(),
|
|
337
|
+
1: String(category),
|
|
338
|
+
2: String(action),
|
|
339
|
+
3: this.serializeInteractionData(data),
|
|
340
|
+
};
|
|
332
341
|
if (!this.interactionsAtRoute) {
|
|
333
342
|
const newInteractions: Interaction[] = [ixLog];
|
|
334
343
|
this.interactionsAtRoute = newInteractions;
|
|
@@ -341,7 +350,7 @@ export class TimeAnalyticsService {
|
|
|
341
350
|
|
|
342
351
|
constructor(
|
|
343
352
|
private router: Router,
|
|
344
|
-
@Inject(
|
|
353
|
+
@Inject(AUTH_ACCESS) private db: AuthAccess,
|
|
345
354
|
@Inject(LOG_SERVICE) private log: LogService,
|
|
346
355
|
private local: SessionLocalStorageService,
|
|
347
356
|
private session: SessionService,
|
|
@@ -0,0 +1,112 @@
|
|
|
1
|
+
import { Router } from '@angular/router';
|
|
2
|
+
import { AuthStore } from '../store/auth/auth.store';
|
|
3
|
+
import { TestBed } from '@angular/core/testing';
|
|
4
|
+
import { MockDataService } from '@tech4good/platform-data/testing';
|
|
5
|
+
import { PROFILE_PROVISIONER } from '@tech4good/platform-auth';
|
|
6
|
+
import { provideAppMocks } from '../testing/app-mocks';
|
|
7
|
+
import { createMockUser } from '../store/user/user.mock';
|
|
8
|
+
import { createMockUserPrivate } from '../store/user-private/user-private.mock';
|
|
9
|
+
import { AccessState } from '../store/user/user.model';
|
|
10
|
+
|
|
11
|
+
describe('App profile provisioning', () => {
|
|
12
|
+
it('creates public and private profile data from the authenticated session', async () => {
|
|
13
|
+
TestBed.configureTestingModule({
|
|
14
|
+
providers: provideAppMocks({ disableLatency: true,
|
|
15
|
+
collections: { users: [],
|
|
16
|
+
userPrivates: [] } }),
|
|
17
|
+
});
|
|
18
|
+
const db = TestBed.inject(MockDataService);
|
|
19
|
+
const session = {
|
|
20
|
+
uid: 'user-2',
|
|
21
|
+
email: 'user2@example.com',
|
|
22
|
+
displayName: 'User Two',
|
|
23
|
+
photoURL: 'https://example.com/user-2.jpg',
|
|
24
|
+
isAnonymous: false,
|
|
25
|
+
emailVerified: true,
|
|
26
|
+
emailLinkEnabled: true,
|
|
27
|
+
providerIds: ['password'],
|
|
28
|
+
};
|
|
29
|
+
|
|
30
|
+
await TestBed.inject(PROFILE_PROVISIONER).ensureUserProfile(session);
|
|
31
|
+
|
|
32
|
+
expect(db.DB.users.selectEntity(session.uid)).toEqual(
|
|
33
|
+
expect.objectContaining({
|
|
34
|
+
__id: session.uid,
|
|
35
|
+
name: 'User Two',
|
|
36
|
+
photoURL: 'https://example.com/user-2.jpg',
|
|
37
|
+
}),
|
|
38
|
+
);
|
|
39
|
+
expect(db.DB.userPrivates.selectEntity(session.uid)).toEqual(
|
|
40
|
+
expect.objectContaining({
|
|
41
|
+
__id: session.uid,
|
|
42
|
+
email: 'user2@example.com',
|
|
43
|
+
emailLinkEnabled: true,
|
|
44
|
+
}),
|
|
45
|
+
);
|
|
46
|
+
});
|
|
47
|
+
|
|
48
|
+
it('replaces a generated email name and stale photo when Google profile data becomes available', async () => {
|
|
49
|
+
const uid = 'email-user';
|
|
50
|
+
TestBed.configureTestingModule({
|
|
51
|
+
providers: provideAppMocks({ disableLatency: true,
|
|
52
|
+
collections: { users: [
|
|
53
|
+
createMockUser({
|
|
54
|
+
__id: uid,
|
|
55
|
+
name: 'email-user@example.com',
|
|
56
|
+
photoURL: null,
|
|
57
|
+
isAdmin: false,
|
|
58
|
+
consented: false,
|
|
59
|
+
accessState: AccessState.SUBMIT_INTEREST,
|
|
60
|
+
}),
|
|
61
|
+
],
|
|
62
|
+
userPrivates: [createMockUserPrivate({ __id: uid, email: 'email-user@example.com' })] } }),
|
|
63
|
+
});
|
|
64
|
+
const db = TestBed.inject(MockDataService);
|
|
65
|
+
|
|
66
|
+
await TestBed.inject(PROFILE_PROVISIONER).ensureUserProfile({
|
|
67
|
+
uid,
|
|
68
|
+
email: 'email-user@example.com',
|
|
69
|
+
displayName: 'Google User',
|
|
70
|
+
photoURL: 'https://example.com/google-user.jpg',
|
|
71
|
+
isAnonymous: false,
|
|
72
|
+
emailVerified: true,
|
|
73
|
+
emailLinkEnabled: true,
|
|
74
|
+
providerIds: ['password', 'google.com'],
|
|
75
|
+
});
|
|
76
|
+
|
|
77
|
+
expect(db.DB.users.selectEntity(uid)).toEqual(
|
|
78
|
+
expect.objectContaining({
|
|
79
|
+
name: 'Google User',
|
|
80
|
+
photoURL: 'https://example.com/google-user.jpg',
|
|
81
|
+
}),
|
|
82
|
+
);
|
|
83
|
+
});
|
|
84
|
+
});
|
|
85
|
+
|
|
86
|
+
/** Exercise the actual package feature, profile service and data store together. */
|
|
87
|
+
describe('App auth provider composition', () => {
|
|
88
|
+
it('loads a guest profile, keeps that UID when linking Google, and clears auth on signout', async () => {
|
|
89
|
+
TestBed.configureTestingModule({ providers: [
|
|
90
|
+
...provideAppMocks({ disableLatency: true, collections: { users: [], userPrivates: [] } }),
|
|
91
|
+
{ provide: Router, useValue: { navigate: jest.fn().mockResolvedValue(true) } },
|
|
92
|
+
] });
|
|
93
|
+
const auth = TestBed.inject(AuthStore);
|
|
94
|
+
auth.loadAuth();
|
|
95
|
+
await auth.loginAnonymously();
|
|
96
|
+
const guestUid = auth.afUser()!.uid;
|
|
97
|
+
expect(auth.authStatus()).toBe('ready');
|
|
98
|
+
expect(auth.user()?.__id).toBe(guestUid);
|
|
99
|
+
expect(auth.user()?.isAdmin).toBe(false);
|
|
100
|
+
expect(auth.user()?.consented).toBe(false);
|
|
101
|
+
|
|
102
|
+
await auth.linkGoogle();
|
|
103
|
+
expect(auth.afUser()?.uid).toBe(guestUid);
|
|
104
|
+
expect(auth.afUser()?.isAnonymous).toBe(false);
|
|
105
|
+
expect(auth.user()?.__id).toBe(guestUid);
|
|
106
|
+
expect((await TestBed.inject(MockDataService).getEntity<{ email: string }>('userPrivates', guestUid))?.email).toBe(auth.afUser()?.email);
|
|
107
|
+
|
|
108
|
+
await auth.signOut();
|
|
109
|
+
expect(await auth.whenReady()).toBeNull();
|
|
110
|
+
expect(auth.user()).toBeNull();
|
|
111
|
+
});
|
|
112
|
+
});
|