@tech4good/angular-schematics 18.0.1 → 18.0.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (30) hide show
  1. package/README.md +0 -1
  2. package/package.json +1 -1
  3. package/src/entity/files/__name@dasherize__/__name@dasherize__.mock.ts.template +1 -1
  4. package/src/entity/files/__name@dasherize__/__name@dasherize__.store.ts.template +1 -1
  5. package/src/entity/index.js +8 -4
  6. package/src/entity/index.js.map +1 -1
  7. package/src/init/files/.gitignore.template +3 -0
  8. package/src/init/files/CODE_OF_CONDUCT.md.template +51 -0
  9. package/src/init/files/CONTRIBUTING.md.template +298 -0
  10. package/src/init/files/README.md.template +63 -17
  11. package/src/init/files/angular.json.template +6 -8
  12. package/src/init/files/contributing-docs/coding-standards.md.template +239 -0
  13. package/src/init/files/contributing-docs/using-fixup-commits.md.template +111 -0
  14. package/src/init/files/package.json.template +8 -4
  15. package/src/init/files/src/app/app.config.ts.template +1 -2
  16. package/src/init/files/src/app/core/auth/auth.guard.ts.template +17 -9
  17. package/src/init/files/src/app/core/firebase/cached-listeners.service.ts.template +5 -4
  18. package/src/init/files/src/app/core/firebase/firebase.mock.service.ts.template +3 -4
  19. package/src/init/files/src/app/core/store/app.store.ts.template +13 -3
  20. package/src/init/files/src/app/core/store/user/user.model.ts.template +1 -1
  21. package/src/init/files/src/app/first-time/early-access/early-access.component.ts.template +2 -2
  22. package/src/init/files/src/app/shared/navbar/navbar.component.html.template +1 -1
  23. package/src/init/files/src/app/shared/navbar/navbar.component.scss.template +5 -5
  24. package/src/init/files/src/app/shared/redeployment-warning/redeployment-warning.component.html.template +1 -1
  25. package/src/init/files/src/env.d.ts.template +31 -0
  26. package/src/init/files/src/environments/environment.prod.ts.template +3 -1
  27. package/src/init/files/src/environments/environment.ts.template +2 -1
  28. package/src/init/files/src/index.html.template +7 -7
  29. package/src/init/files/tsconfig.app.json.template +15 -0
  30. /package/src/init/files/{src/assets → public}/images/close-x.svg +0 -0
@@ -0,0 +1,239 @@
1
+ # Coding Standards
2
+
3
+ This is currently partially aspirational as we do not have our CI and prettier setup to enforce these yet. But in general, we'd like to follow the Angular coding standards described below.
4
+
5
+ ## Code Style
6
+
7
+ The **[Google JavaScript Style Guide](https://google.github.io/styleguide/jsguide.html)** serves as the foundation for Causeway's coding style, with additional guidelines specific to TypeScript. The team uses `prettier` to automatically format code, and automatic formatting is enforced by CI.
8
+
9
+ ## Code Practices
10
+
11
+ ### Write Useful Comments
12
+
13
+ Comments that explain what a block of code does are helpful; they can provide clarity faster than following through the code itself.
14
+
15
+ However, comments that explain **why** a block of code exists, or why it does something a certain way, are invaluable. The "why" is often difficult, or sometimes impossible, to discern without consulting the original author. When collaborators are in different locations, this can significantly impact productivity.
16
+
17
+ For example, this is a not-very-useful comment:
18
+ ```typescript
19
+ // Set default tabindex.
20
+ if (!attributes['tabindex']) {
21
+ element.setAttribute('tabindex', '-1');
22
+ }
23
+ ```
24
+
25
+ While this is much more useful:
26
+ ```typescript
27
+ // Unless the user specifies otherwise, the calendar should not be a tab stop.
28
+ // This prevents ngAria from overzealously adding a tabindex to anything with an ng-model.
29
+ if (!attributes['tabindex']) {
30
+ element.setAttribute('tabindex', '-1');
31
+ }
32
+ ```
33
+
34
+ In TypeScript code, use JsDoc-style comments for descriptions (on classes, members, etc.) and `//` style comments for everything else (explanations, background info, etc.).
35
+
36
+ ### API Design
37
+
38
+ #### Boolean Arguments
39
+
40
+ Generally avoid adding boolean arguments to a method in cases where that argument means "do something extra." In these cases, prefer breaking the behavior up into different functions.
41
+
42
+ ```typescript
43
+ // AVOID
44
+ function getTargetElement(createIfNotFound = false) {
45
+ // ...
46
+ }
47
+ ```
48
+
49
+ ```typescript
50
+ // PREFER
51
+ function getExistingTargetElement() {
52
+ // ...
53
+ }
54
+
55
+ function createTargetElement() {
56
+ // ...
57
+ }
58
+ ```
59
+
60
+ This guideline can be relaxed for performance reasons in core framework code.
61
+
62
+ #### Optional Arguments
63
+
64
+ Use optional function arguments only when they make sense for the API or are required for performance. Do not use optional arguments merely for implementation convenience.
65
+
66
+ ### TypeScript
67
+
68
+ #### Typing
69
+
70
+ Avoid using `any` wherever possible. If you find yourself using `any`, consider whether a generic or `unknown` type might be more appropriate.
71
+
72
+ #### Getters and Setters
73
+
74
+ Getters and setters can introduce openings for side effects, add complexity for code readers, and generate additional code when targeting older browsers.
75
+
76
+ * Only use getters and setters for `@Input` properties or when otherwise required for API compatibility.
77
+ * Avoid long or complex getters and setters. If the logic of an accessor would take more than three lines, introduce a new method to contain the logic.
78
+ * A getter should immediately precede its corresponding setter.
79
+ * Decorators such as `@Input` should be applied to the getter and not the setter.
80
+ * Always use a `readonly` property instead of a getter (with no setter) when possible.
81
+
82
+ ```typescript
83
+ /** YES */
84
+ readonly active: boolean;
85
+
86
+ /** NO */
87
+ get active(): boolean {
88
+ // Using a getter solely to make the property read-only.
89
+ return this._active;
90
+ }
91
+ ```
92
+
93
+ #### Iteration
94
+
95
+ Prefer using `for` or `for of` over `Array.prototype.forEach`. The `forEach` API can make debugging harder and may increase overhead due to unnecessary function invocations (though modern browsers typically optimize this well).
96
+
97
+ #### JsDoc Comments
98
+
99
+ All public APIs must have user-facing comments. These are extracted for API documentation and shown in IDEs.
100
+
101
+ Private and internal APIs should have JsDoc when they are not obvious. Ultimately, it is up to the code reviewer to determine what is "obvious," but the rule of thumb is that *most* classes, properties, and methods should have a JsDoc description.
102
+
103
+ Properties should have a concise description of what the property means:
104
+ ```typescript
105
+ /** The label position relative to the checkbox. Defaults to 'after'. */
106
+ @Input() labelPosition: 'before' | 'after' = 'after';
107
+ ```
108
+
109
+ Method blocks should describe what the function does and provide a description for each parameter and the return value:
110
+ ```typescript
111
+ /**
112
+ * Opens a modal dialog containing the given component.
113
+ * @param component Type of the component to load into the dialog.
114
+ * @param config Dialog configuration options.
115
+ * @returns Reference to the newly-opened dialog.
116
+ */
117
+ open<T>(component: ComponentType<T>, config?: MatDialogConfig): MatDialogRef<T> { ... }
118
+ ```
119
+
120
+ Boolean properties and return values should use "Whether..." as opposed to "True if...":
121
+ ```typescript
122
+ /** Whether the button is disabled. */
123
+ disabled: boolean = false;
124
+ ```
125
+
126
+ #### Try-Catch
127
+
128
+ Only use `try-catch` blocks when dealing with genuinely unexpected errors. Don't use `try` to avoid checking for expected error conditions, such as null dereference or out-of-bound array access.
129
+
130
+ Each `try-catch` block **must** include a comment explaining the specific error being caught and why it cannot be prevented.
131
+
132
+ #### Variable Declarations
133
+
134
+ Prefer `const` wherever possible, using `let` only when a value must change. Avoid using `var` unless absolutely necessary.
135
+
136
+ #### `readonly`
137
+
138
+ Use `readonly` members whenever possible to prevent unintended mutations.
139
+
140
+ ### Naming Conventions
141
+
142
+ #### General
143
+
144
+ * Prefer writing out words instead of using abbreviations.
145
+ * Prefer *exact* names over short names (within reason). For example, `labelPosition` is better than `align` because the former more precisely communicates what the property represents.
146
+ * Use `is` and `has` prefixes for boolean properties/methods, except for `@Input()` properties.
147
+ * Name identifiers based on their responsibility. Names should reflect what the code *does*, not how it is used:
148
+
149
+ ```typescript
150
+ /** NO: */
151
+ class DefaultRouteReuseStrategy { }
152
+
153
+ /** YES: */
154
+ class NonStoringRouteReuseStrategy { }
155
+ ```
156
+
157
+ #### Observables
158
+
159
+ Do not suffix observables with `$`.
160
+
161
+ #### Classes
162
+
163
+ * Use PascalCase (UpperCamelCase) for class names.
164
+ * Avoid suffixing class names with `Impl`.
165
+
166
+ #### Interfaces
167
+
168
+ * Do not prefix interfaces with `I`.
169
+ * Avoid suffixing interfaces with `Interface`.
170
+
171
+ #### Functions and Methods
172
+
173
+ Use camelCase (lowerCamelCase) for function and method names.
174
+
175
+ The name of a function should capture the action performed *by* that method rather than describing when the method will be called. For example:
176
+
177
+ ```typescript
178
+ /** AVOID: does not describe what the function does. */
179
+ handleClick() {
180
+ // ...
181
+ }
182
+
183
+ /** PREFER: describes the action performed by the function. */
184
+ activateRipple() {
185
+ // ...
186
+ }
187
+ ```
188
+
189
+ #### Constants and Injection Tokens
190
+
191
+ Use UPPER_SNAKE_CASE for constants and injection tokens.
192
+
193
+ #### Test Classes and Examples
194
+
195
+ Provide test classes and examples with meaningful, descriptive names:
196
+
197
+ ```typescript
198
+ /** PREFER: describes the scenario under test. */
199
+ class FormGroupWithCheckboxAndRadios { /* ... */ }
200
+ class InputWithNgModel { /* ... */ }
201
+
202
+ /** AVOID: does not fully describe the scenario under test. */
203
+ class Comp { /* ... */ }
204
+ class InputComp { /* ... */ }
205
+ ```
206
+
207
+ ### RxJS
208
+
209
+ When importing the `of` function to create an `Observable` from a value, alias the imported function as `observableOf`:
210
+
211
+ ```typescript
212
+ import {of as observableOf} from 'rxjs';
213
+ ```
214
+
215
+ ### Testing
216
+
217
+ #### Test Names
218
+
219
+ Use descriptive names for Jasmine tests. Ideally, test names should read as a sentence, often in the form "it should...".
220
+
221
+ ```typescript
222
+ /** PREFER: describes the scenario under test. */
223
+ describe('Router', () => {
224
+ describe('with the default route reuse strategy', () => {
225
+ it('should not reuse routes upon location change', () => {
226
+ // ...
227
+ });
228
+ });
229
+ });
230
+
231
+ /** AVOID: does not fully describe the scenario under test. */
232
+ describe('Router', () => {
233
+ describe('default strategy', () => {
234
+ it('should work', () => {
235
+ // ...
236
+ });
237
+ });
238
+ });
239
+ ```
@@ -0,0 +1,111 @@
1
+ # Working with fixup commits
2
+
3
+ This document provides information and guidelines for working with fixup commits:
4
+
5
+ - [What are fixup commits](#about-fixup-commits)
6
+ - [Why use fixup commits](#why-fixup-commits)
7
+ - [Creating fixup commits](#create-fixup-commits)
8
+ - [Squashing fixup commits](#squash-fixup-commits)
9
+
10
+ [This blog post](https://thoughtbot.com/blog/autosquashing-git-commits) is also a good resource on
11
+ the subject.
12
+
13
+ ## <a name="about-fixup-commits"></a> What are fixup commits
14
+
15
+ At their core, fixup commits are just regular commits with a special commit message:
16
+ The first line of their commit message starts with "fixup! " (notice the space after "!") followed
17
+ by the first line of the commit message of an earlier commit (it doesn't have to be the immediately
18
+ preceding one).
19
+
20
+ The purpose of a fixup commit is to modify an earlier commit.
21
+ I.e. it allows adding more changes in a new commit, but "marking" them as belonging to an earlier
22
+ commit.
23
+ `Git` provides tools to make it easy to squash fixup commits into the original commit at a later
24
+ time (see [below](#squash-fixup-commits) for details).
25
+
26
+ For example, let's assume you have added the following commits to your branch:
27
+
28
+ ```
29
+ feat: first commit
30
+ fix: second commit
31
+ ```
32
+
33
+ If you want to add more changes to the first commit, you can create a new commit with the commit
34
+ message:
35
+ `fixup! feat: first commit`:
36
+
37
+ ```
38
+ feat: first commit
39
+ fix: second commit
40
+ fixup! feat: first commit
41
+ ```
42
+
43
+ ## <a name="why-fixup-commits"></a> Why use fixup commits
44
+
45
+ So, when are fixup commits useful?
46
+
47
+ During the life of a Pull Request, a reviewer might request changes.
48
+ The Pull Request author can make the requested changes and submit them for another review.
49
+ Normally, these changes should be part of one of the original commits of the Pull Request.
50
+ However, amending an existing commit with the changes makes it difficult for the reviewer to know
51
+ exactly what has changed since the last time they reviewed the Pull Request.
52
+
53
+ Here is where fixup commits come in handy.
54
+ By addressing review feedback in fixup commits, you make it very straight forward for the reviewer
55
+ to see what are the new changes that need to be reviewed and verify that their earlier feedback has
56
+ been addressed.
57
+ This can save a lot of effort, especially on larger Pull Requests (where having to re-review _all_
58
+ the changes is pretty wasteful).
59
+
60
+ When the time comes to merge the Pull Request into the repository, the merge script knows how to
61
+ automatically squash fixup commits with the corresponding regular commits.
62
+
63
+ ## <a name="create-fixup-commits"></a> Creating fixup commits
64
+
65
+ As mentioned [above](#about-fixup-commits), the only thing that differentiates a fixup commit from a
66
+ regular commit is the commit message.
67
+ You can create a fixup commit by specifying an appropriate commit message (
68
+ i.e. `fixup! <original-commit-message-subject>`).
69
+
70
+ In addition, the `git` command-line tool provides an easy way to create a fixup commit
71
+ via [git commit --fixup](https://git-scm.com/docs/git-commit#Documentation/git-commit.txt---fixupltcommitgt):
72
+
73
+ ```sh
74
+ # Create a fixup commit to fix up the last commit on the branch:
75
+ git commit --fixup HEAD ...
76
+
77
+ # Create a fixup commit to fix up commit with SHA <COMMIT_SHA>:
78
+ git commit --fixup <COMMIT_SHA> ...
79
+ ```
80
+
81
+ ## <a name="squash-fixup-commits"></a> Squashing fixup commits
82
+
83
+ As mentioned above, the merge script will automatically squash fixup commits.
84
+ However, sometimes you might want to manually squash a fixup commit.
85
+
86
+ ### Rebasing to squash fixup commits
87
+
88
+ The easiest way to re-order and squash any commit is
89
+ via [rebasing interactively](https://git-scm.com/docs/git-rebase#_interactive_mode). You move a
90
+ commit right after the one you want to squash it into in the rebase TODO list and change the
91
+ corresponding action from `pick` to `fixup`.
92
+
93
+ `Git` can do all these automatically for you if you pass the `--autosquash` option to `git rebase`.
94
+ See the [`git` docs](https://git-scm.com/docs/git-rebase#Documentation/git-rebase.txt---autosquash)
95
+ for more details.
96
+
97
+ ### Additional options
98
+
99
+ You may like to consider some optional configurations:
100
+
101
+ #### Configuring `git` to auto-squash by default
102
+
103
+ By default, `git` will not automatically squash fixup commits when interactively rebasing.
104
+ If you prefer to not have to pass the `--autosquash` option every time, you can change the default
105
+ behavior by setting the `rebase.autoSquash` `git` config option to true.
106
+ See
107
+ the [`git` docs](https://git-scm.com/docs/git-rebase#Documentation/git-rebase.txt-rebaseautoSquash)
108
+ for more details.
109
+
110
+ If you have `rebase.autoSquash` set to true, you can pass the `--no-autosquash` option
111
+ to `git rebase` to override and disable this setting.
@@ -1,6 +1,7 @@
1
1
  {
2
2
  "name": "<%= dasherize(project) %>",
3
- "version": "18.0.1",
3
+ "version": "0.0.0",
4
+ "type": "module",
4
5
  "scripts": {
5
6
  "ng": "ng",
6
7
  "start": "ng serve",
@@ -23,11 +24,13 @@
23
24
  "@angular/platform-browser": "^18.0.0",
24
25
  "@angular/platform-browser-dynamic": "^18.0.0",
25
26
  "@angular/router": "^18.0.0",
26
- "@ngrx/signals": "^18.0.0-rc.2",
27
+ "@ngrx/signals": "^18.0.0",
27
28
  "core-js": "^3.37.1",
28
29
  "cross-fetch": "^4.0.0",
29
30
  "crypto-es": "^2.1.0",
31
+ "dotenv": "^16.4.5",
30
32
  "globalthis": "^1.0.4",
33
+ "ngx-env": "^0.1.0",
31
34
  "proxy-polyfill": "^0.3.2",
32
35
  "rxjs": "~7.8.0",
33
36
  "tslib": "^2.3.0",
@@ -42,10 +45,11 @@
42
45
  "@angular-eslint/template-parser": "^18.1.0",
43
46
  "@angular/cli": "^18.0.7",
44
47
  "@angular/compiler-cli": "^18.0.0",
45
- "@tech4good/angular-schematics": "^18.0.1",
48
+ "@ngx-env/builder": "^18.0.1",
49
+ "@tech4good/angular-schematics": "^18.0.3",
46
50
  "@types/estree": "^1.0.0",
47
51
  "@types/jasmine": "~5.1.0",
48
- "@types/node": "^18.18.0",
52
+ "@types/node": "^18.19.47",
49
53
  "@typescript-eslint/eslint-plugin": "6.10.0",
50
54
  "@typescript-eslint/parser": "6.10.0",
51
55
  "eslint-config-google": "^0.14.0",
@@ -1,5 +1,5 @@
1
1
  import { ApplicationConfig, provideZoneChangeDetection } from '@angular/core';
2
- import { provideRouter, withHashLocation, withComponentInputBinding, withPreloading, PreloadAllModules } from '@angular/router';
2
+ import { provideRouter, withComponentInputBinding, withPreloading, PreloadAllModules } from '@angular/router';
3
3
  import { routes } from './app.routes';
4
4
  import { provideAnimationsAsync } from '@angular/platform-browser/animations/async';
5
5
  import { importProvidersFrom } from '@angular/core';
@@ -43,7 +43,6 @@ export const appConfig: ApplicationConfig = {
43
43
  provideZoneChangeDetection({ eventCoalescing: true }),
44
44
  provideRouter(
45
45
  routes,
46
- withHashLocation(),
47
46
  withComponentInputBinding(),
48
47
  withPreloading(PreloadAllModules),
49
48
  ),
@@ -18,8 +18,10 @@ export class AuthGuard {
18
18
  private router: Router,
19
19
  @Inject(DATABASE_SERVICE) private db: DatabaseService,
20
20
  ) {
21
+ // This is only used when we have a signed in user, so we want to filter
22
+ // out the values before the user has been loaded into the store
21
23
  this.user$ = toObservable(this.authStore.user).pipe(
22
- filter((user) => user !== null),
24
+ filter((user) => !!user),
23
25
  );
24
26
  }
25
27
 
@@ -34,13 +36,20 @@ export class AuthGuard {
34
36
  // - Admin users are also handled (so that only admin users can go to admin pages, including pages they would
35
37
  // typically get rerouted from)
36
38
 
37
- // First handle whether users are logged in. If not, go to landing, otherwise go to the hompage
38
- if (!dbUser && (state.url !== '/' && state.url !== '/landing')) {
39
- this.router.navigate(['/'], { queryParams: next.queryParams });
40
- return of(false);
41
- } else if (!dbUser && (state.url === '/' || state.url === '/landing')) {
42
- return of(true);
43
- } else if (dbUser && (state.url === '/' || state.url === '/landing')) {
39
+ // First handle all not logged in cases. If not logged in, users can only go to landing
40
+ if (!dbUser) {
41
+ if (state.url === '/' || state.url === '/landing' || state.url === '/login') {
42
+ return of(true);
43
+ } else {
44
+ this.router.navigate(['/'], { queryParams: next.queryParams });
45
+ return of(false);
46
+ }
47
+ }
48
+
49
+ // AFTER THIS POINT, THE USER MUST BE LOGGED IN (i.e. dbUser exists)
50
+
51
+ // If logged in and trying to access landing, redirect to the homepage
52
+ if (state.url === '/' || state.url === '/landing' || state.url === '/login') {
44
53
  this.router.navigate(['/home'], { queryParams: next.queryParams });
45
54
  return of(false);
46
55
  }
@@ -54,7 +63,6 @@ export class AuthGuard {
54
63
  return of(true);
55
64
  }
56
65
 
57
-
58
66
  // Then handle whether users have consented. If not, go to consent, otherwise skip past consent.
59
67
  if ((!dbUser.consented || dbUser.accessState === AccessState.CONSENT) && state.url !== '/consent') {
60
68
  this.router.navigate(['/consent'], { queryParams: next.queryParams });
@@ -2,7 +2,6 @@ import { Inject, Injectable, WritableSignal, inject, DestroyRef, computed } from
2
2
  import { toObservable } from '@angular/core/rxjs-interop';
3
3
  import { Subject, Observable, merge, forkJoin, of, from, pipe } from 'rxjs';
4
4
  import { startWith, pairwise, publishLast, publish, publishReplay, refCount, tap, pluck, mergeMap, filter, takeUntil, skipUntil, buffer, skip, switchMap, map, take } from 'rxjs/operators';
5
- import { patchState } from '@ngrx/signals';
6
5
  import { setEntities, setEntity, removeEntities, SelectEntityId } from '@ngrx/signals/entities';
7
6
  import { EntityLoadQuery, EntityStreamQuery, entityInQueryResults } from '../store/app.store';
8
7
  import { QueryParams, QueryOptions, AnyEntity } from '../store/app.model';
@@ -274,9 +273,11 @@ export class CachedListenersService {
274
273
  .map((dc) => dc.docData['__id']);
275
274
 
276
275
  // Patch all the changes to the store
277
- patchState(store, setEntities(entitiesToAdd, { selectId }));
278
- patchState(store, setEntities([...entitiesToModify, ...entitiesToModify2], { selectId }));
279
- patchState(store, removeEntities([...entitiesToRemove, ...entitiesToRemove2]));
276
+ store.handleStreamChanges(
277
+ entitiesToAdd,
278
+ [...entitiesToModify, ...entitiesToModify2],
279
+ [...entitiesToRemove, ...entitiesToRemove2],
280
+ );
280
281
  });
281
282
 
282
283
  return {
@@ -6,8 +6,7 @@ import { environment } from '../../../environments/environment';
6
6
  import { DocumentSnapshot, serverTimestamp, Timestamp, getDoc, getDocs, doc, setDoc, updateDoc, deleteDoc, docData, collection, collectionData, collectionChanges, query, where, orderBy, OrderByDirection, limit, startAt, startAfter, endAt, endBefore, DocumentChange, increment, AggregateQuerySnapshot, AggregateField, AggregateSpec, getAggregateFromServer, getCountFromServer } from '@angular/fire/firestore';
7
7
  import { AnyEntity, QueryParams, QueryOptions } from '../store/app.model';
8
8
  import { DatabaseService } from './database.service';
9
- import { SelectEntityId, setAllEntities } from '@ngrx/signals/entities';
10
- import { patchState } from '@ngrx/signals';
9
+ import { SelectEntityId } from '@ngrx/signals/entities';
11
10
  import { AuthMockDB } from '../store/auth/auth.mock';
12
11
 
13
12
  // Entity Model DB Data
@@ -35,8 +34,8 @@ export class FirebaseMockService implements DatabaseService {
35
34
  private injector: Injector,
36
35
  ) {
37
36
  // Init Entity Models
38
- patchState(this.DB['users'], setAllEntities(USER_DB, { selectId }));
39
- patchState(this.DB['userContexts'], setAllEntities(USERCONTEXT_DB, { selectId }));
37
+ this.DB['users'].init(USER_DB);
38
+ this.DB['userContexts'].init(USERCONTEXT_DB);
40
39
  }
41
40
 
42
41
  /** Creates a unique id */
@@ -1,7 +1,7 @@
1
1
  import { WritableSignal, inject } from '@angular/core';
2
2
  import { Timestamp, writeBatch } from '@angular/fire/firestore';
3
3
  import { patchState, signalStoreFeature, withMethods } from '@ngrx/signals';
4
- import { removeEntities, removeEntity, setEntities, setEntity, updateEntity, withEntities } from '@ngrx/signals/entities';
4
+ import { removeEntities, removeEntity, setEntities, setEntity, updateEntity, withEntities, setAllEntities } from '@ngrx/signals/entities';
5
5
  import { EntityChanges, EntityId, SelectEntityId } from '@ngrx/signals/entities/src/models';
6
6
  import { CachedListenersService } from '../firebase/cached-listeners.service';
7
7
  import { DATABASE_SERVICE, DatabaseService } from '../firebase/database.service';
@@ -58,6 +58,14 @@ export function withEntitiesAndSelectMethods<S extends AnyEntity>() {
58
58
  return signalStoreFeature(
59
59
  withEntities<S>(),
60
60
  withMethods((store) => ({
61
+ init(entities: S[]) {
62
+ patchState(store, setAllEntities<S>(entities, { selectId }));
63
+ },
64
+ handleStreamChanges(entitiesToAdd: S[], entitiesToModify: S[], entitiesToRemove: string[]) {
65
+ patchState(store, setEntities(entitiesToAdd, { selectId }));
66
+ patchState(store, setEntities(entitiesToModify, { selectId }));
67
+ patchState(store, removeEntities(entitiesToRemove));
68
+ },
61
69
  selectEntity(id: string): S {
62
70
  const result = store.entityMap()[id];
63
71
 
@@ -767,7 +775,7 @@ export function selectEntities<T>(entityMap: Record<string, T>, queryParams: Que
767
775
  return e[key] ? !val.some((v) => e[key].includes(v)) : true;
768
776
 
769
777
  case 'in':
770
- return !val.includes(e[key]);
778
+ return val.length > 0 && !val.includes(e[key]);
771
779
 
772
780
  case 'not-in':
773
781
  return val.includes(e[key]);
@@ -923,7 +931,9 @@ export async function processLoadQueries<T extends { __id: string }>(entities: T
923
931
 
924
932
  // Process queries concurrently using Promise.all
925
933
  await Promise.all(optimizedQueries.filter((q) => !!q).map(async (query) => {
926
- await query.store.load(query.queryParams, query.queryOptions, query.loadQueries);
934
+ if (!query.queryParams.some((param) => Array.isArray(param[2]) && param[2].length === 0 && param[1] === 'in')) {
935
+ await query.store.load(query.queryParams, query.queryOptions, query.loadQueries);
936
+ }
927
937
  }));
928
938
  }));
929
939
  }
@@ -23,5 +23,5 @@ export enum AccessState {
23
23
  CONSENT = '01 - consent', // on consent form
24
24
  SUBMIT_INTEREST = '02 - submit interest', // on basic interest form
25
25
  WAITING = '03 - waiting', // on waitlist for early access
26
- DONE = 'done', // finished with the entire flow
26
+ DONE = 'done', // finished with the access flow
27
27
  }
@@ -144,7 +144,7 @@ export class EarlyAccessComponent implements OnInit {
144
144
  mergeMap(async (user) => {
145
145
  const posNum = await this.userStore.count([
146
146
  ['joinedWaitlistAt', '<=', user.joinedWaitlistAt],
147
- ['accessState', '<', AccessState.DONE],
147
+ ['accessState', '==', AccessState.WAITING],
148
148
  ], {});
149
149
  return this.nth(posNum);
150
150
  }),
@@ -155,7 +155,7 @@ export class EarlyAccessComponent implements OnInit {
155
155
  filter((user: User) => !!user.joinedWaitlistAt),
156
156
  mergeMap(async (user) => {
157
157
  const total = await this.userStore.count([
158
- ['accessState', '<', AccessState.DONE],
158
+ ['accessState', '==', AccessState.WAITING],
159
159
  ], {});
160
160
  return `${total}`;
161
161
  }),
@@ -1,5 +1,5 @@
1
1
  <div class="navbar-container">
2
- <!--<img class="logo" src="assets/images/logo.svg">-->
2
+ <!--<img class="logo" src="images/logo.svg">-->
3
3
  @if (currentUser()) {
4
4
  <div class="user-setting-section">
5
5
  <img class="profile-pic" [src]= 'currentUser().photoURL' [matMenuTriggerFor]="menu" #menuTrigger/>
@@ -5,20 +5,20 @@
5
5
  box-shadow: -4px 3px 10px rgba(200, 224, 212, 0.25);
6
6
  display: flex;
7
7
  flex-direction: row;
8
- align-items: center; // Center items vertically
9
- padding: 8px 16px; // Add padding to the container
8
+ align-items: center;
9
+ padding: 8px 16px;
10
10
 
11
11
  .logo {
12
12
  width: 46px;
13
13
  height: 46px;
14
14
  cursor: pointer;
15
- margin-right: 16px; // Add margin between logo and user section
15
+ margin-right: 16px;
16
16
  }
17
17
 
18
18
  .user-setting-section {
19
- margin-left: auto; // Push to the right
19
+ margin-left: auto;
20
20
  display: flex;
21
- align-items: center; // Center items vertically
21
+ align-items: center;
22
22
  color: #2DBDB1;
23
23
  .profile-pic{
24
24
  height: 46px;
@@ -2,7 +2,7 @@
2
2
  <div class="warning-container">
3
3
  <div class="header">
4
4
  <div class="title">This version is out of date!</div>
5
- <img (click)="close()" src="/assets/img/close-x.svg" />
5
+ <img (click)="close()" src="images/close-x.svg" />
6
6
  </div>
7
7
  <button (click)="update()" class="update">Update Now</button>
8
8
  </div>
@@ -0,0 +1,31 @@
1
+ // Define the type of the environment variables.
2
+ declare interface Env {
3
+ readonly NODE_ENV: string;
4
+ NG_APP_FIREBASE_API_KEY: string;
5
+ NG_APP_FIREBASE_LOGS_API_KEY: string;
6
+ NG_APP_FIREBASE_DEV_API_KEY: string;
7
+ // Replace the following with your own environment variables.
8
+ // Example: NGX_VERSION: string;
9
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
10
+ [key: string]: any;
11
+ }
12
+
13
+ // Choose how to access the environment variables.
14
+ // Remove the unused options.
15
+
16
+ // 1. Use import.meta.env.YOUR_ENV_VAR in your code. (conventional)
17
+ declare interface ImportMeta {
18
+ readonly env: Env;
19
+ }
20
+
21
+ // 2. Use _NGX_ENV_.YOUR_ENV_VAR in your code. (customizable)
22
+ // You can modify the name of the variable in angular.json.
23
+ // ngxEnv: {
24
+ // define: '_NGX_ENV_',
25
+ // }
26
+ declare const _NGX_ENV_: Env;
27
+
28
+ // 3. Use process.env.YOUR_ENV_VAR in your code. (deprecated)
29
+ declare namespace NodeJS {
30
+ export interface ProcessEnv extends Env {}
31
+ }
@@ -1,9 +1,11 @@
1
1
  export const environment = {
2
2
  production: true,
3
3
  firebase: {
4
- // REPLACE WITH CONFIG
4
+ apiKey: import.meta.env.NG_APP_FIREBASE_API_KEY,
5
+ // REPLACE WITH REMAINING CONFIG
5
6
  },
6
7
  firebaseLogs: {
8
+ apiKey: import.meta.env.NG_APP_FIREBASE_LOGS_API_KEY,
7
9
  // REPLACE WITH CONFIG
8
10
  },
9
11
  };