@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
package/src/entity/index_spec.js
DELETED
|
@@ -1,153 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
const tslib_1 = require("tslib");
|
|
4
|
-
const schematics_1 = require("@angular-devkit/schematics");
|
|
5
|
-
const testing_1 = require("@angular-devkit/schematics/testing");
|
|
6
|
-
const path = tslib_1.__importStar(require("path"));
|
|
7
|
-
const collectionPath = path.join(__dirname, '../collection.json');
|
|
8
|
-
/**
|
|
9
|
-
* Creates a minimal workspace tree with angular.json and the stub files
|
|
10
|
-
* that the entity schematic expects to modify (app.model.ts and
|
|
11
|
-
* firebase.mock.service.ts with their marker comments).
|
|
12
|
-
*/
|
|
13
|
-
function createWorkspaceTree() {
|
|
14
|
-
const tree = new testing_1.UnitTestTree(schematics_1.Tree.empty());
|
|
15
|
-
// Minimal angular.json for workspace resolution
|
|
16
|
-
tree.create('/angular.json', JSON.stringify({
|
|
17
|
-
version: 1,
|
|
18
|
-
projects: {
|
|
19
|
-
'test-app': {
|
|
20
|
-
projectType: 'application',
|
|
21
|
-
root: '',
|
|
22
|
-
sourceRoot: 'src',
|
|
23
|
-
prefix: 'app',
|
|
24
|
-
},
|
|
25
|
-
},
|
|
26
|
-
}));
|
|
27
|
-
// Stub app.model.ts with the marker comments the entity schematic searches for
|
|
28
|
-
tree.create('/src/app/core/store/app.model.ts', [
|
|
29
|
-
"// Entity Models",
|
|
30
|
-
"import { User } from './user/user.model';",
|
|
31
|
-
"",
|
|
32
|
-
"export type AnyEntity =",
|
|
33
|
-
" User;",
|
|
34
|
-
].join('\n'));
|
|
35
|
-
// Stub firebase.mock.service.ts with the marker comments the entity schematic searches for
|
|
36
|
-
tree.create('/src/app/core/firebase/firebase.mock.service.ts', [
|
|
37
|
-
"import { Injector, inject } from '@angular/core';",
|
|
38
|
-
"// Entity Model DB Data",
|
|
39
|
-
"",
|
|
40
|
-
"export class FirebaseMockService {",
|
|
41
|
-
" readonly DB = {",
|
|
42
|
-
" 'users': inject(UserMockDB),",
|
|
43
|
-
" };",
|
|
44
|
-
"",
|
|
45
|
-
" constructor(private injector: Injector) {",
|
|
46
|
-
" // Init Entity Models",
|
|
47
|
-
" this.DB['users'].init(USER_DB);",
|
|
48
|
-
" }",
|
|
49
|
-
"}",
|
|
50
|
-
"",
|
|
51
|
-
"export function provideFirebaseMock({",
|
|
52
|
-
" users,",
|
|
53
|
-
"}: {",
|
|
54
|
-
" users?: any[];",
|
|
55
|
-
"}) {",
|
|
56
|
-
" const service = new FirebaseMockService(injector);",
|
|
57
|
-
" if (users) service.DB['users'].init(users);",
|
|
58
|
-
"}",
|
|
59
|
-
].join('\n'));
|
|
60
|
-
return tree;
|
|
61
|
-
}
|
|
62
|
-
describe('entity', () => {
|
|
63
|
-
const runner = new testing_1.SchematicTestRunner('schematics', collectionPath);
|
|
64
|
-
it('should generate entity files when given a name', async () => {
|
|
65
|
-
const tree = await runner.runSchematic('entity', {
|
|
66
|
-
name: 'session',
|
|
67
|
-
project: 'test-app',
|
|
68
|
-
path: 'src/app/core/store',
|
|
69
|
-
}, createWorkspaceTree());
|
|
70
|
-
// Verify the expected entity files are generated
|
|
71
|
-
expect(tree.files).toContain('/src/app/core/store/session/session.model.ts');
|
|
72
|
-
expect(tree.files).toContain('/src/app/core/store/session/session.store.ts');
|
|
73
|
-
expect(tree.files).toContain('/src/app/core/store/session/session.mock.ts');
|
|
74
|
-
});
|
|
75
|
-
it('should add the entity import and type to app.model.ts', async () => {
|
|
76
|
-
const tree = await runner.runSchematic('entity', {
|
|
77
|
-
name: 'session',
|
|
78
|
-
project: 'test-app',
|
|
79
|
-
path: 'src/app/core/store',
|
|
80
|
-
}, createWorkspaceTree());
|
|
81
|
-
const appModel = tree.readContent('/src/app/core/store/app.model.ts');
|
|
82
|
-
// Should add the import for the new entity
|
|
83
|
-
expect(appModel).toContain("import { Session } from './session/session.model';");
|
|
84
|
-
// Should add the entity to the AnyEntity union type
|
|
85
|
-
expect(appModel).toContain('Session |');
|
|
86
|
-
});
|
|
87
|
-
it('should add the mock DB entries to firebase.mock.service.ts', async () => {
|
|
88
|
-
const tree = await runner.runSchematic('entity', {
|
|
89
|
-
name: 'session',
|
|
90
|
-
project: 'test-app',
|
|
91
|
-
path: 'src/app/core/store',
|
|
92
|
-
}, createWorkspaceTree());
|
|
93
|
-
const fbMock = tree.readContent('/src/app/core/firebase/firebase.mock.service.ts');
|
|
94
|
-
// Should add the mock DB import
|
|
95
|
-
expect(fbMock).toContain('SessionMockDB');
|
|
96
|
-
expect(fbMock).toContain('SESSION_DB');
|
|
97
|
-
// Should add the DB entry
|
|
98
|
-
expect(fbMock).toContain("'sessions': inject(SessionMockDB)");
|
|
99
|
-
// Should add the init call
|
|
100
|
-
expect(fbMock).toContain("this.DB['sessions'].init(SESSION_DB)");
|
|
101
|
-
// Should add the provideFirebaseMock parameter
|
|
102
|
-
expect(fbMock).toContain('sessions,');
|
|
103
|
-
expect(fbMock).toContain('sessions?: any[]');
|
|
104
|
-
});
|
|
105
|
-
it('should warn when path is outside src/app/core/store', async () => {
|
|
106
|
-
let warningMessage = '';
|
|
107
|
-
runner.logger.subscribe(entry => {
|
|
108
|
-
if (entry.level === 'warn') {
|
|
109
|
-
warningMessage = entry.message;
|
|
110
|
-
}
|
|
111
|
-
});
|
|
112
|
-
await runner.runSchematic('entity', {
|
|
113
|
-
name: 'session',
|
|
114
|
-
project: 'test-app',
|
|
115
|
-
path: 'src/app/some-other-place',
|
|
116
|
-
}, createWorkspaceTree());
|
|
117
|
-
expect(warningMessage).toContain('outside of src/app/core/store');
|
|
118
|
-
});
|
|
119
|
-
it('should redirect path to src/app/core/store when mockRedirect is true', async () => {
|
|
120
|
-
const tree = await runner.runSchematic('entity', {
|
|
121
|
-
name: 'session',
|
|
122
|
-
project: 'test-app',
|
|
123
|
-
path: 'src/app/some-other-place',
|
|
124
|
-
mockRedirect: true,
|
|
125
|
-
}, createWorkspaceTree());
|
|
126
|
-
// Verify files generated in redirected path
|
|
127
|
-
expect(tree.files).toContain('/src/app/core/store/session/session.model.ts');
|
|
128
|
-
expect(tree.files).toContain('/src/app/core/store/session/session.store.ts');
|
|
129
|
-
expect(tree.files).toContain('/src/app/core/store/session/session.mock.ts');
|
|
130
|
-
expect(tree.files).not.toContain('/src/app/some-other-place/session/session.model.ts');
|
|
131
|
-
});
|
|
132
|
-
it('should add dev stub security rules to firestore.rules if the file exists', async () => {
|
|
133
|
-
const workspace = createWorkspaceTree();
|
|
134
|
-
workspace.create('/firestore.rules', [
|
|
135
|
-
"rules_version = '2';",
|
|
136
|
-
"service cloud.firestore {",
|
|
137
|
-
" match /databases/{database}/documents {",
|
|
138
|
-
" // ─── Default deny ───",
|
|
139
|
-
" }",
|
|
140
|
-
"}",
|
|
141
|
-
].join('\n'));
|
|
142
|
-
const tree = await runner.runSchematic('entity', {
|
|
143
|
-
name: 'session',
|
|
144
|
-
project: 'test-app',
|
|
145
|
-
path: 'src/app/core/store',
|
|
146
|
-
}, workspace);
|
|
147
|
-
const rules = tree.readContent('/firestore.rules');
|
|
148
|
-
expect(rules).toContain('Sessions (DEV STUB — replace in /feature-harden-implement)');
|
|
149
|
-
expect(rules).toContain('match /sessions/{docId}');
|
|
150
|
-
expect(rules).toContain('allow read, write: if request.auth != null;');
|
|
151
|
-
});
|
|
152
|
-
});
|
|
153
|
-
//# sourceMappingURL=index_spec.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"index_spec.js","sourceRoot":"","sources":["index_spec.ts"],"names":[],"mappings":";;;AAAA,2DAAkD;AAClD,gEAAuF;AACvF,mDAA6B;AAE7B,MAAM,cAAc,GAAG,IAAI,CAAC,IAAI,CAAC,SAAS,EAAE,oBAAoB,CAAC,CAAC;AAElE;;;;GAIG;AACH,SAAS,mBAAmB;IAC1B,MAAM,IAAI,GAAG,IAAI,sBAAY,CAAC,iBAAI,CAAC,KAAK,EAAE,CAAC,CAAC;IAE5C,gDAAgD;IAChD,IAAI,CAAC,MAAM,CAAC,eAAe,EAAE,IAAI,CAAC,SAAS,CAAC;QAC1C,OAAO,EAAE,CAAC;QACV,QAAQ,EAAE;YACR,UAAU,EAAE;gBACV,WAAW,EAAE,aAAa;gBAC1B,IAAI,EAAE,EAAE;gBACR,UAAU,EAAE,KAAK;gBACjB,MAAM,EAAE,KAAK;aACd;SACF;KACF,CAAC,CAAC,CAAC;IAEJ,+EAA+E;IAC/E,IAAI,CAAC,MAAM,CAAC,kCAAkC,EAAE;QAC9C,kBAAkB;QAClB,2CAA2C;QAC3C,EAAE;QACF,yBAAyB;QACzB,SAAS;KACV,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC,CAAC;IAEd,2FAA2F;IAC3F,IAAI,CAAC,MAAM,CAAC,iDAAiD,EAAE;QAC7D,mDAAmD;QACnD,yBAAyB;QACzB,EAAE;QACF,oCAAoC;QACpC,mBAAmB;QACnB,kCAAkC;QAClC,MAAM;QACN,EAAE;QACF,6CAA6C;QAC7C,2BAA2B;QAC3B,qCAAqC;QACrC,KAAK;QACL,GAAG;QACH,EA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AE,oBAAoB;SAC3B,EAAE,SAAS,CAAC,CAAC;QAEd,MAAM,KAAK,GAAG,IAAI,CAAC,WAAW,CAAC,kBAAkB,CAAC,CAAC;QACnD,MAAM,CAAC,KAAK,CAAC,CAAC,SAAS,CAAC,4DAA4D,CAAC,CAAC;QACtF,MAAM,CAAC,KAAK,CAAC,CAAC,SAAS,CAAC,yBAAyB,CAAC,CAAC;QACnD,MAAM,CAAC,KAAK,CAAC,CAAC,SAAS,CAAC,6CAA6C,CAAC,CAAC;IACzE,CAAC,CAAC,CAAC;AACL,CAAC,CAAC,CAAC"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export {};
|
package/src/guard/index_spec.js
DELETED
|
@@ -1,64 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
const tslib_1 = require("tslib");
|
|
4
|
-
const schematics_1 = require("@angular-devkit/schematics");
|
|
5
|
-
const testing_1 = require("@angular-devkit/schematics/testing");
|
|
6
|
-
const path = tslib_1.__importStar(require("path"));
|
|
7
|
-
const collectionPath = path.join(__dirname, '../collection.json');
|
|
8
|
-
/**
|
|
9
|
-
* Creates a minimal workspace tree with angular.json to satisfy
|
|
10
|
-
* getWorkspace() and buildDefaultPath() calls in the schematic.
|
|
11
|
-
*/
|
|
12
|
-
function createWorkspaceTree() {
|
|
13
|
-
const tree = new testing_1.UnitTestTree(schematics_1.Tree.empty());
|
|
14
|
-
tree.create('/angular.json', JSON.stringify({
|
|
15
|
-
version: 1,
|
|
16
|
-
projects: {
|
|
17
|
-
'test-app': {
|
|
18
|
-
projectType: 'application',
|
|
19
|
-
root: '',
|
|
20
|
-
sourceRoot: 'src',
|
|
21
|
-
prefix: 'app',
|
|
22
|
-
},
|
|
23
|
-
},
|
|
24
|
-
}));
|
|
25
|
-
return tree;
|
|
26
|
-
}
|
|
27
|
-
describe('guard', () => {
|
|
28
|
-
const runner = new testing_1.SchematicTestRunner('schematics', collectionPath);
|
|
29
|
-
it('should generate guard files when given a name', async () => {
|
|
30
|
-
const tree = await runner.runSchematic('guard', {
|
|
31
|
-
name: 'require-profile',
|
|
32
|
-
project: 'test-app',
|
|
33
|
-
inDirectory: true,
|
|
34
|
-
path: 'src/app',
|
|
35
|
-
}, createWorkspaceTree());
|
|
36
|
-
// Verify the expected guard files are generated
|
|
37
|
-
expect(tree.files).toContain('/src/app/require-profile.guard.ts');
|
|
38
|
-
expect(tree.files).toContain('/src/app/require-profile.guard.spec.ts');
|
|
39
|
-
});
|
|
40
|
-
it('should use the camelized name in the guard export and handleAccess in spec', async () => {
|
|
41
|
-
const tree = await runner.runSchematic('guard', {
|
|
42
|
-
name: 'require-profile',
|
|
43
|
-
project: 'test-app',
|
|
44
|
-
inDirectory: true,
|
|
45
|
-
path: 'src/app',
|
|
46
|
-
}, createWorkspaceTree());
|
|
47
|
-
const guardContent = tree.readContent('/src/app/require-profile.guard.ts');
|
|
48
|
-
expect(guardContent).toContain('export const requireProfile: CanActivateFn');
|
|
49
|
-
expect(guardContent).toContain('export function handleAccess');
|
|
50
|
-
const specContent = tree.readContent('/src/app/require-profile.guard.spec.ts');
|
|
51
|
-
expect(specContent).toContain("describe('requireProfile (handleAccess)'");
|
|
52
|
-
});
|
|
53
|
-
it('should abort when inDirectory is false', async () => {
|
|
54
|
-
const tree = await runner.runSchematic('guard', {
|
|
55
|
-
name: 'require-profile',
|
|
56
|
-
project: 'test-app',
|
|
57
|
-
inDirectory: false,
|
|
58
|
-
path: 'src/app',
|
|
59
|
-
}, createWorkspaceTree());
|
|
60
|
-
// When inDirectory is false, the schematic returns noop — no files generated
|
|
61
|
-
expect(tree.files).not.toContain('/src/app/require-profile.guard.ts');
|
|
62
|
-
});
|
|
63
|
-
});
|
|
64
|
-
//# sourceMappingURL=index_spec.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"index_spec.js","sourceRoot":"","sources":["index_spec.ts"],"names":[],"mappings":";;;AAAA,2D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EAAE,iBAAiB;YACvB,OAAO,EAAE,UAAU;YACnB,WAAW,EAAE,IAAI;YACjB,IAAI,EAAE,SAAS;SAChB,EAAE,mBAAmB,EAAE,CAAC,CAAC;QAE1B,MAAM,YAAY,GAAG,IAAI,CAAC,WAAW,CAAC,mCAAmC,CAAC,CAAC;QAC3E,MAAM,CAAC,YAAY,CAAC,CAAC,SAAS,CAAC,4CAA4C,CAAC,CAAC;QAC7E,MAAM,CAAC,YAAY,CAAC,CAAC,SAAS,CAAC,8BAA8B,CAAC,CAAC;QAE/D,MAAM,WAAW,GAAG,IAAI,CAAC,WAAW,CAAC,wCAAwC,CAAC,CAAC;QAC/E,MAAM,CAAC,WAAW,CAAC,CAAC,SAAS,CAAC,0CAA0C,CAAC,CAAC;IAC5E,CAAC,CAAC,CAAC;IAEH,EAAE,CAAC,wCAAwC,EAAE,KAAK,IAAI,EAAE;QACtD,MAAM,IAAI,GAAG,MAAM,MAAM,CAAC,YAAY,CAAC,OAAO,EAAE;YAC9C,IAAI,EAAE,iBAAiB;YACvB,OAAO,EAAE,UAAU;YACnB,WAAW,EAAE,KAAK;YAClB,IAAI,EAAE,SAAS;SAChB,EAAE,mBAAmB,EAAE,CAAC,CAAC;QAE1B,6EAA6E;QAC7E,MAAM,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC,GAAG,CAAC,SAAS,CAAC,mCAAmC,CAAC,CAAC;IACxE,CAAC,CAAC,CAAC;AACL,CAAC,CAAC,CAAC"}
|
|
@@ -1,143 +0,0 @@
|
|
|
1
|
-
#!/usr/bin/env python3
|
|
2
|
-
"""
|
|
3
|
-
Firestore Entity Exporter
|
|
4
|
-
|
|
5
|
-
This script exports any specified Firestore collection to a local JSON or CSV file.
|
|
6
|
-
Useful for pulling low-volume, PII-sensitive collections (like user responses)
|
|
7
|
-
on-demand to run Jupyter notebook analyses without storing them persistently in BigQuery.
|
|
8
|
-
|
|
9
|
-
Usage:
|
|
10
|
-
# Export to JSON
|
|
11
|
-
python bigquery/scripts/export_entities.py --collection <collection-name> --output data.json
|
|
12
|
-
|
|
13
|
-
# Export to CSV
|
|
14
|
-
python bigquery/scripts/export_entities.py --collection <collection-name> --output data.csv
|
|
15
|
-
"""
|
|
16
|
-
|
|
17
|
-
import argparse
|
|
18
|
-
import csv
|
|
19
|
-
import json
|
|
20
|
-
import os
|
|
21
|
-
import sys
|
|
22
|
-
from datetime import datetime
|
|
23
|
-
|
|
24
|
-
try:
|
|
25
|
-
import firebase_admin
|
|
26
|
-
from firebase_admin import credentials, firestore
|
|
27
|
-
from google.api_core.datetime_helpers import DatetimeWithNanoseconds
|
|
28
|
-
except ImportError:
|
|
29
|
-
print("Error: Required packages missing. Please install dependencies:")
|
|
30
|
-
print(" pip install firebase-admin google-api-core")
|
|
31
|
-
sys.exit(1)
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
def parse_value(val):
|
|
35
|
-
"""Recursively converts Firestore Timestamp objects and other non-JSON-serializable types."""
|
|
36
|
-
if isinstance(val, DatetimeWithNanoseconds):
|
|
37
|
-
return val.isoformat()
|
|
38
|
-
elif isinstance(val, datetime):
|
|
39
|
-
return val.isoformat()
|
|
40
|
-
elif isinstance(val, dict):
|
|
41
|
-
return {k: parse_value(v) for k, v in val.items()}
|
|
42
|
-
elif isinstance(val, list):
|
|
43
|
-
return [parse_value(x) for x in val]
|
|
44
|
-
return val
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
def main():
|
|
48
|
-
parser = argparse.ArgumentParser(description="Export Firestore collections to JSON or CSV.")
|
|
49
|
-
parser.add_argument(
|
|
50
|
-
"--collection",
|
|
51
|
-
required=True,
|
|
52
|
-
help="Name of the Firestore collection to export",
|
|
53
|
-
)
|
|
54
|
-
parser.add_argument(
|
|
55
|
-
"--output",
|
|
56
|
-
required=True,
|
|
57
|
-
help="Local file path for the export (must end in .json or .csv)",
|
|
58
|
-
)
|
|
59
|
-
parser.add_argument(
|
|
60
|
-
"--credentials",
|
|
61
|
-
help="Path to the Firebase service account key JSON file. "
|
|
62
|
-
"If omitted, falls back to GOOGLE_APPLICATION_CREDENTIALS env var.",
|
|
63
|
-
)
|
|
64
|
-
args = parser.parse_args()
|
|
65
|
-
|
|
66
|
-
# 1. Initialize Firebase App
|
|
67
|
-
if not firebase_admin._apps:
|
|
68
|
-
try:
|
|
69
|
-
if args.credentials:
|
|
70
|
-
cred = credentials.Certificate(args.credentials)
|
|
71
|
-
firebase_admin.initialize_app(cred)
|
|
72
|
-
elif os.environ.get("GOOGLE_APPLICATION_CREDENTIALS"):
|
|
73
|
-
cred = credentials.Certificate(os.environ["GOOGLE_APPLICATION_CREDENTIALS"])
|
|
74
|
-
firebase_admin.initialize_app(cred)
|
|
75
|
-
else:
|
|
76
|
-
# Attempt to load Application Default Credentials
|
|
77
|
-
firebase_admin.initialize_app()
|
|
78
|
-
except Exception as e:
|
|
79
|
-
print("Authentication Error: Could not initialize Firebase Admin SDK.")
|
|
80
|
-
print("Please either:")
|
|
81
|
-
print(" 1. Download a service account JSON file from Firebase Console -> Project Settings -> Service accounts.")
|
|
82
|
-
print(" 2. Pass it using --credentials /path/to/key.json")
|
|
83
|
-
print(" 3. Or run: export GOOGLE_APPLICATION_CREDENTIALS='/path/to/key.json'")
|
|
84
|
-
print(f"Details: {e}")
|
|
85
|
-
sys.exit(1)
|
|
86
|
-
|
|
87
|
-
db = firestore.client()
|
|
88
|
-
collection_ref = db.collection(args.collection)
|
|
89
|
-
|
|
90
|
-
print(f"Fetching documents from collection '{args.collection}'...")
|
|
91
|
-
docs = list(collection_ref.stream())
|
|
92
|
-
print(f"Retrieved {len(docs)} documents.")
|
|
93
|
-
|
|
94
|
-
if not docs:
|
|
95
|
-
print("No documents found. Exiting.")
|
|
96
|
-
return
|
|
97
|
-
|
|
98
|
-
# 2. Extract and format data
|
|
99
|
-
flat_data = []
|
|
100
|
-
headers = set()
|
|
101
|
-
|
|
102
|
-
for doc in docs:
|
|
103
|
-
doc_dict = doc.to_dict()
|
|
104
|
-
doc_dict["__id"] = doc.id # Include primary document ID
|
|
105
|
-
parsed_dict = parse_value(doc_dict)
|
|
106
|
-
flat_data.append(parsed_dict)
|
|
107
|
-
headers.update(parsed_dict.keys())
|
|
108
|
-
|
|
109
|
-
# Sort headers to ensure consistent column ordering in CSV, placing __id first
|
|
110
|
-
headers = sorted(list(headers))
|
|
111
|
-
if "__id" in headers:
|
|
112
|
-
headers.remove("__id")
|
|
113
|
-
headers.insert(0, "__id")
|
|
114
|
-
|
|
115
|
-
# 3. Write output
|
|
116
|
-
output_path = args.output
|
|
117
|
-
ext = os.path.splitext(output_path)[1].lower()
|
|
118
|
-
|
|
119
|
-
if ext == ".json":
|
|
120
|
-
with open(output_path, "w", encoding="utf-8") as f:
|
|
121
|
-
json.dump(flat_data, f, indent=2, ensure_ascii=False)
|
|
122
|
-
print(f"Successfully exported data to JSON: {output_path}")
|
|
123
|
-
|
|
124
|
-
elif ext == ".csv":
|
|
125
|
-
with open(output_path, "w", encoding="utf-8", newline="") as f:
|
|
126
|
-
writer = csv.DictWriter(f, fieldnames=headers, extrasaction="ignore")
|
|
127
|
-
writer.writeheader()
|
|
128
|
-
for row in flat_data:
|
|
129
|
-
csv_row = {}
|
|
130
|
-
for k, v in row.items():
|
|
131
|
-
if isinstance(v, (dict, list)):
|
|
132
|
-
csv_row[k] = json.dumps(v, ensure_ascii=False)
|
|
133
|
-
else:
|
|
134
|
-
csv_row[k] = v
|
|
135
|
-
writer.writerow(csv_row)
|
|
136
|
-
print(f"Successfully exported data to CSV: {output_path}")
|
|
137
|
-
else:
|
|
138
|
-
print(f"Error: Unknown output format '{ext}'. Must be .json or .csv.")
|
|
139
|
-
sys.exit(1)
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
if __name__ == "__main__":
|
|
143
|
-
main()
|
|
@@ -1,167 +0,0 @@
|
|
|
1
|
-
#!/usr/bin/env python3
|
|
2
|
-
"""
|
|
3
|
-
BigQuery Query Runner
|
|
4
|
-
|
|
5
|
-
Runs a specified SQL query file against Google BigQuery and exports the results
|
|
6
|
-
to JSON, CSV, or a local SQLite database.
|
|
7
|
-
|
|
8
|
-
Usage:
|
|
9
|
-
# Export to JSON
|
|
10
|
-
python bigquery/scripts/run_query.py --project <your-gcp-project-id> --query bigquery/queries/active_time_by_route.sql --output output.json
|
|
11
|
-
|
|
12
|
-
# Export to CSV
|
|
13
|
-
python bigquery/scripts/run_query.py --project <your-gcp-project-id> --query bigquery/queries/active_time_by_route.sql --output output.csv
|
|
14
|
-
|
|
15
|
-
# Export to SQLite
|
|
16
|
-
python bigquery/scripts/run_query.py --project <your-gcp-project-id> --query bigquery/queries/active_time_by_route.sql --output metrics.db --table active_time
|
|
17
|
-
"""
|
|
18
|
-
|
|
19
|
-
import argparse
|
|
20
|
-
import csv
|
|
21
|
-
import json
|
|
22
|
-
import os
|
|
23
|
-
import sqlite3
|
|
24
|
-
import sys
|
|
25
|
-
|
|
26
|
-
try:
|
|
27
|
-
from google.cloud import bigquery
|
|
28
|
-
except ImportError:
|
|
29
|
-
print("Error: Required package 'google-cloud-bigquery' missing. Please install it:")
|
|
30
|
-
print(" pip install google-cloud-bigquery")
|
|
31
|
-
sys.exit(1)
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
def main():
|
|
35
|
-
parser = argparse.ArgumentParser(description="Run BigQuery SQL queries and export results.")
|
|
36
|
-
parser.add_argument(
|
|
37
|
-
"--query",
|
|
38
|
-
required=True,
|
|
39
|
-
help="Path to the SQL file to run (e.g., bigquery/queries/active_time_by_route.sql)",
|
|
40
|
-
)
|
|
41
|
-
parser.add_argument(
|
|
42
|
-
"--output",
|
|
43
|
-
required=True,
|
|
44
|
-
help="Local file path for the export (must end in .json, .csv, or .db/.sqlite)",
|
|
45
|
-
)
|
|
46
|
-
parser.add_argument(
|
|
47
|
-
"--project",
|
|
48
|
-
required=True,
|
|
49
|
-
help="GCP Project ID to run the query against (e.g., <your-gcp-project-id>)",
|
|
50
|
-
)
|
|
51
|
-
parser.add_argument(
|
|
52
|
-
"--table",
|
|
53
|
-
help="Target table name when exporting to a SQLite database. Required if output is SQLite.",
|
|
54
|
-
)
|
|
55
|
-
parser.add_argument(
|
|
56
|
-
"--credentials",
|
|
57
|
-
help="Path to the Google service account key JSON file. "
|
|
58
|
-
"If omitted, falls back to GOOGLE_APPLICATION_CREDENTIALS env var.",
|
|
59
|
-
)
|
|
60
|
-
args = parser.parse_args()
|
|
61
|
-
|
|
62
|
-
# 1. Validate inputs
|
|
63
|
-
if not os.path.exists(args.query):
|
|
64
|
-
print(f"Error: Query file not found at {args.query}")
|
|
65
|
-
sys.exit(1)
|
|
66
|
-
|
|
67
|
-
output_ext = os.path.splitext(args.output)[1].lower()
|
|
68
|
-
is_sqlite = output_ext in [".db", ".sqlite", ".sqlite3"]
|
|
69
|
-
if is_sqlite and not args.table:
|
|
70
|
-
print("Error: --table argument is required when exporting to a SQLite database.")
|
|
71
|
-
sys.exit(1)
|
|
72
|
-
|
|
73
|
-
with open(args.query, "r", encoding="utf-8") as f:
|
|
74
|
-
query_string = f.read()
|
|
75
|
-
|
|
76
|
-
# 2. Initialize BigQuery Client
|
|
77
|
-
try:
|
|
78
|
-
if args.credentials:
|
|
79
|
-
client = bigquery.Client.from_service_account_json(args.credentials, project=args.project)
|
|
80
|
-
else:
|
|
81
|
-
client = bigquery.Client(project=args.project)
|
|
82
|
-
except Exception as e:
|
|
83
|
-
print("Authentication Error: Could not initialize BigQuery Client.")
|
|
84
|
-
print("Please check your credentials or run:")
|
|
85
|
-
print(" export GOOGLE_APPLICATION_CREDENTIALS='/path/to/key.json'")
|
|
86
|
-
print(f"Details: {e}")
|
|
87
|
-
sys.exit(1)
|
|
88
|
-
|
|
89
|
-
# 3. Execute Query
|
|
90
|
-
print(f"Executing query '{args.query}' in project '{args.project}'...")
|
|
91
|
-
try:
|
|
92
|
-
query_job = client.query(query_string)
|
|
93
|
-
results = query_job.result() # Waits for query to complete
|
|
94
|
-
print("Query completed successfully. Fetching rows...")
|
|
95
|
-
except Exception as e:
|
|
96
|
-
print(f"Query Execution Error: {e}")
|
|
97
|
-
sys.exit(1)
|
|
98
|
-
|
|
99
|
-
# Convert rows to a list of dicts for export
|
|
100
|
-
rows = [dict(row) for row in results]
|
|
101
|
-
if not rows:
|
|
102
|
-
print("Query returned 0 rows. Exiting.")
|
|
103
|
-
return
|
|
104
|
-
|
|
105
|
-
# 4. Write Output
|
|
106
|
-
if output_ext == ".json":
|
|
107
|
-
with open(args.output, "w", encoding="utf-8") as f:
|
|
108
|
-
json.dump(rows, f, indent=2, default=str)
|
|
109
|
-
print(f"Successfully exported {len(rows)} rows to JSON: {args.output}")
|
|
110
|
-
|
|
111
|
-
elif output_ext == ".csv":
|
|
112
|
-
headers = list(rows[0].keys())
|
|
113
|
-
with open(args.output, "w", encoding="utf-8", newline="") as f:
|
|
114
|
-
writer = csv.DictWriter(f, fieldnames=headers)
|
|
115
|
-
writer.writeheader()
|
|
116
|
-
for row in rows:
|
|
117
|
-
# Stringify nested structures
|
|
118
|
-
row_clean = {k: (json.dumps(v) if isinstance(v, (dict, list)) else v) for k, v in row.items()}
|
|
119
|
-
writer.writerow(row_clean)
|
|
120
|
-
print(f"Successfully exported {len(rows)} rows to CSV: {args.output}")
|
|
121
|
-
|
|
122
|
-
elif is_sqlite:
|
|
123
|
-
headers = list(rows[0].keys())
|
|
124
|
-
conn = sqlite3.connect(args.output)
|
|
125
|
-
cursor = conn.cursor()
|
|
126
|
-
|
|
127
|
-
# Dynamic table creation based on BigQuery results schema
|
|
128
|
-
# Maps common types, defaults everything else to TEXT
|
|
129
|
-
columns_def = []
|
|
130
|
-
for key, val in rows[0].items():
|
|
131
|
-
if isinstance(val, int):
|
|
132
|
-
col_type = "INTEGER"
|
|
133
|
-
elif isinstance(val, float):
|
|
134
|
-
col_type = "REAL"
|
|
135
|
-
else:
|
|
136
|
-
col_type = "TEXT"
|
|
137
|
-
columns_def.append(f"`{key}` {col_type}")
|
|
138
|
-
|
|
139
|
-
create_table_sql = f"CREATE TABLE IF NOT EXISTS `{args.table}` ({', '.join(columns_def)})"
|
|
140
|
-
cursor.execute(create_table_sql)
|
|
141
|
-
|
|
142
|
-
# Insert rows
|
|
143
|
-
insert_placeholders = ", ".join(["?"] * len(headers))
|
|
144
|
-
insert_sql = f"INSERT INTO `{args.table}` ({', '.join([f'`{h}`' for h in headers])}) VALUES ({insert_placeholders})"
|
|
145
|
-
|
|
146
|
-
insert_data = []
|
|
147
|
-
for row in rows:
|
|
148
|
-
row_data = []
|
|
149
|
-
for header in headers:
|
|
150
|
-
val = row[header]
|
|
151
|
-
if isinstance(val, (dict, list)):
|
|
152
|
-
row_data.append(json.dumps(val))
|
|
153
|
-
else:
|
|
154
|
-
row_data.append(val)
|
|
155
|
-
insert_data.append(tuple(row_data))
|
|
156
|
-
|
|
157
|
-
cursor.executemany(insert_sql, insert_data)
|
|
158
|
-
conn.commit()
|
|
159
|
-
conn.close()
|
|
160
|
-
print(f"Successfully imported {len(rows)} rows into SQLite table '{args.table}': {args.output}")
|
|
161
|
-
else:
|
|
162
|
-
print(f"Error: Unknown output format '{output_ext}'. Must be .json, .csv, or .db/.sqlite.")
|
|
163
|
-
sys.exit(1)
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
if __name__ == "__main__":
|
|
167
|
-
main()
|