@tech4good/angular-schematics 21.3.0 → 21.4.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/.t4g/agent-memory.db +0 -0
- package/CHANGELOG.md +24 -0
- package/package.json +1 -1
- package/src/entity/index.js +42 -9
- package/src/entity/index.js.map +1 -1
- package/src/entity/index_spec.js +42 -8
- package/src/entity/index_spec.js.map +1 -1
- package/src/entity/schema.json +0 -5
- package/src/ng-add/files/.gitignore.template +1 -0
- package/src/ng-add/files/angular.json.template +3 -0
- package/src/ng-add/files/firestore.rules.spec.ts.template +88 -1
- package/src/ng-add/files/firestore.rules.template +9 -0
- package/src/ng-add/files/package.json.template +4 -2
- package/src/ng-add/files/src/app/admin/admin-panel/admin-user-list/admin-user-list.component.spec.ts.template +3 -3
- package/src/ng-add/files/src/app/admin/admin-panel/admin-user-list/admin-user-table/admin-user-table.component.spec.ts.template +0 -1
- package/src/ng-add/files/src/app/app.component.html.template +1 -1
- package/src/ng-add/files/src/app/app.component.scss.template +9 -1
- package/src/ng-add/files/src/app/app.component.spec.ts.template +2 -2
- package/src/ng-add/files/src/app/auth-routing.spec.ts.template +1 -1
- package/src/ng-add/files/src/app/core/analytics/log.service.ts.template +1 -1
- package/src/ng-add/files/src/app/core/analytics/time-analytics.service.spec.ts.template +2 -2
- package/src/ng-add/files/src/app/core/firebase/cached-listeners.service.ts.template +53 -51
- package/src/ng-add/files/src/app/core/firebase/firebase.mock.service.ts.template +6 -0
- package/src/ng-add/files/src/app/core/firebase/simulate-load.spec.ts.template +2 -2
- package/src/ng-add/files/src/app/core/firebase/simulate-stream.spec.ts.template +14 -14
- package/src/ng-add/files/src/app/core/firebase/stream-multiplexer.ts.template +50 -48
- package/src/ng-add/files/src/app/core/logging/logging.service.spec.ts.template +118 -0
- package/src/ng-add/files/src/app/core/logging/logging.service.ts.template +168 -0
- package/src/ng-add/files/src/app/core/store/app.model.ts.template +3 -1
- package/src/ng-add/files/src/app/core/store/app.store.ts.template +11 -9
- package/src/ng-add/files/src/app/core/store/auth/auth.mock.ts.template +5 -4
- package/src/ng-add/files/src/app/core/store/auth/auth.store.ts.template +13 -4
- package/src/ng-add/files/src/app/core/store/user/user.mock.ts.template +0 -4
- package/src/ng-add/files/src/app/core/store/user/user.model.ts.template +0 -1
- package/src/ng-add/files/src/app/core/store/user-private/user-private.mock.ts.template +15 -0
- package/src/ng-add/files/src/app/core/store/user-private/user-private.model.ts.template +9 -0
- package/src/ng-add/files/src/app/core/store/user-private/user-private.store.ts.template +41 -0
- package/src/ng-add/files/src/app/first-time/early-access/early-access.component.spec.ts.template +0 -1
- package/src/ng-add/files/src/app/first-time/early-access/early-access.component.ts.template +1 -1
- package/src/ng-add/files/src/app/first-time/landing/hero/hero.component.ts.template +3 -3
- package/src/ng-add/files/src/app/first-time/landing/landing.component.scss.template +1 -1
- package/src/ng-add/files/src/app/first-time/onboarding/onboarding.component.ts.template +3 -3
- package/src/ng-add/files/src/app/main/home/home.component.spec.ts.template +1 -1
- package/src/ng-add/files/src/app/main/home/home.component.ts.template +4 -4
- package/src/ng-add/files/src/app/shared/dev-status-bar/dev-status-bar.component.scss.template +1 -0
- package/src/ng-add/files/src/app/shared/redeployment-warning/redeployment-warning.service.spec.ts.template +41 -5
- package/src/ng-add/files/src/app/shared/redeployment-warning/redeployment-warning.service.ts.template +25 -2
- package/src/ng-add/files/src/environments/environment.test.ts.template +1 -1
- package/src/shared/statements-adder.d.ts +1 -0
- package/src/shared/statements-adder.js +8 -0
- package/src/shared/statements-adder.js.map +1 -1
- package/src/ng-add/files/src/app/core/firebase/query-logger.ts.template +0 -11
- package/tech4good-angular-schematics-21.0.0.tgz +0 -0
package/.t4g/agent-memory.db
CHANGED
|
Binary file
|
package/CHANGELOG.md
CHANGED
|
@@ -1,3 +1,27 @@
|
|
|
1
|
+
## [21.4.0](https://github.com/tech4good-lab/angular-schematics/compare/v21.3.0...v21.4.0) (2026-07-08)
|
|
2
|
+
|
|
3
|
+
### Features
|
|
4
|
+
|
|
5
|
+
* **entity:** add firestore.rules dev stub generation ([ad20a5f](https://github.com/tech4good-lab/angular-schematics/commit/ad20a5f67ad765111972c852b62f6bacf4dce795))
|
|
6
|
+
* **entity:** remove inDirectory prompt and add store path warning/redirect ([bee2496](https://github.com/tech4good-lab/angular-schematics/commit/bee2496edc99dfec5dbdb99c42f16dc35e629d44))
|
|
7
|
+
* **ng-add:** integrate scoped logging service templates ([26cf441](https://github.com/tech4good-lab/angular-schematics/commit/26cf4414c57a1342aa7440252276e2ef35b9ff88))
|
|
8
|
+
* **ng-add:** split email into userPrivates out of the box ([584b6bc](https://github.com/tech4good-lab/angular-schematics/commit/584b6bc33f8ec235992986229dafc1a59a1e5012))
|
|
9
|
+
* **shared:** add insertBefore utility to statements-adder ([9427c7a](https://github.com/tech4good-lab/angular-schematics/commit/9427c7a7ca1f75e8ed6bb487d13a6918dc3848e0))
|
|
10
|
+
|
|
11
|
+
### Bug Fixes
|
|
12
|
+
|
|
13
|
+
* **entity:** default path to core/store and resolve relative imports ([8ba7965](https://github.com/tech4good-lab/angular-schematics/commit/8ba796521aebf70e56e4444d44fa57ad2b8874fc))
|
|
14
|
+
* **ng-add:** update app component layout and dev status bar flex behavior ([65d7958](https://github.com/tech4good-lab/angular-schematics/commit/65d79581816cd798f83e77b83b180edc4f4403f1))
|
|
15
|
+
* **shared:** detect redeployment immediately if DOM hash differs on startup ([c7517e5](https://github.com/tech4good-lab/angular-schematics/commit/c7517e58ab7b0ae7321ca8cdde697e8053b4bc0b))
|
|
16
|
+
|
|
17
|
+
### Build System
|
|
18
|
+
|
|
19
|
+
* **ng-add:** add deploy scripts to package template ([49d8340](https://github.com/tech4good-lab/angular-schematics/commit/49d834034bb76c300788f73f81eda116b5147582))
|
|
20
|
+
* **ng-add:** bump template dependency for release ([a43065d](https://github.com/tech4good-lab/angular-schematics/commit/a43065d82657626257c49ade148d74844e97c5e2))
|
|
21
|
+
|
|
22
|
+
### Chores
|
|
23
|
+
|
|
24
|
+
* **ng-add:** ignore .impeccable directory in gitignore template ([3e4c5b8](https://github.com/tech4good-lab/angular-schematics/commit/3e4c5b829b3a02852615c844ae9d517dd79ca0c4))
|
|
1
25
|
## [21.3.0](https://github.com/tech4good-lab/angular-schematics/compare/v21.2.0...v21.3.0) (2026-07-03)
|
|
2
26
|
|
|
3
27
|
### Features
|
package/package.json
CHANGED
package/src/entity/index.js
CHANGED
|
@@ -16,7 +16,7 @@ function addInserts(options) {
|
|
|
16
16
|
const allcapsName = core_1.strings.classify(options.name).toUpperCase();
|
|
17
17
|
context.logger.info(`names: ${classifiedName}, ${camelizedName}`);
|
|
18
18
|
// app.model.ts changes
|
|
19
|
-
const appModelPath = '
|
|
19
|
+
const appModelPath = '/src/app/core/store/app.model.ts';
|
|
20
20
|
const appModelText = (0, statements_adder_1.getSourceText)(host, appModelPath);
|
|
21
21
|
context.logger.info(`appModelPath: ${appModelPath}`);
|
|
22
22
|
const entityModelPath = `/${options.path}/` +
|
|
@@ -33,7 +33,7 @@ function addInserts(options) {
|
|
|
33
33
|
` ${classifiedName} |`
|
|
34
34
|
]);
|
|
35
35
|
// firebase.mock.service.ts changes
|
|
36
|
-
const fbMockPath = '
|
|
36
|
+
const fbMockPath = '/src/app/core/firebase/firebase.mock.service.ts';
|
|
37
37
|
const fbMockText = (0, statements_adder_1.getSourceText)(host, fbMockPath);
|
|
38
38
|
const entityMockPath = `/${options.path}/` +
|
|
39
39
|
dasherizedName + '/' +
|
|
@@ -55,12 +55,28 @@ function addInserts(options) {
|
|
|
55
55
|
` ${camelizedName}s?: any[];`,
|
|
56
56
|
` if (${camelizedName}s) service.DB['${camelizedName}s'].init(${camelizedName}s);`
|
|
57
57
|
]);
|
|
58
|
+
// firestore.rules changes
|
|
59
|
+
const rulesPath = '/firestore.rules';
|
|
60
|
+
let rulesInsertChanges = [];
|
|
61
|
+
if (host.exists(rulesPath)) {
|
|
62
|
+
const rulesText = (0, statements_adder_1.getSourceText)(host, rulesPath);
|
|
63
|
+
if (rulesText.includes('// ─── Default deny')) {
|
|
64
|
+
rulesInsertChanges.push((0, statements_adder_1.insertBefore)(rulesText, rulesPath, '// ─── Default deny', `// ─── ${classifiedName}s (DEV STUB — replace in /feature-harden-implement) ───────────────────\n` +
|
|
65
|
+
` match /${camelizedName}s/{docId} {\n` +
|
|
66
|
+
` allow read, write: if request.auth != null;\n` +
|
|
67
|
+
` }\n\n `));
|
|
68
|
+
}
|
|
69
|
+
}
|
|
58
70
|
context.logger.info(`about to start committing`);
|
|
59
71
|
// For each of the files and corresponding set of changes, commit to the tree
|
|
60
|
-
[
|
|
72
|
+
const fileChanges = [
|
|
61
73
|
[appModelPath, insertChangesInAppModel],
|
|
62
74
|
[fbMockPath, insertChangesInFbMock],
|
|
63
|
-
]
|
|
75
|
+
];
|
|
76
|
+
if (rulesInsertChanges.length > 0) {
|
|
77
|
+
fileChanges.push([rulesPath, rulesInsertChanges]);
|
|
78
|
+
}
|
|
79
|
+
fileChanges.forEach(([filePath, insertChanges]) => {
|
|
64
80
|
const declarationRecorder = host.beginUpdate(filePath);
|
|
65
81
|
for (const change of insertChanges) {
|
|
66
82
|
if (change instanceof change_1.InsertChange) {
|
|
@@ -74,11 +90,6 @@ function addInserts(options) {
|
|
|
74
90
|
}
|
|
75
91
|
function entity(options) {
|
|
76
92
|
return async (tree, context) => {
|
|
77
|
-
// Make sure the command is executed in the directory where the component should be generated
|
|
78
|
-
if (!options.inDirectory) {
|
|
79
|
-
context.logger.info("Please navigate to the directory where you want to generate the entity.");
|
|
80
|
-
return (0, schematics_1.noop)();
|
|
81
|
-
}
|
|
82
93
|
const workspace = await (0, workspace_1.getWorkspace)(tree);
|
|
83
94
|
const project = workspace.projects.get(options.project);
|
|
84
95
|
if (!project) {
|
|
@@ -87,6 +98,28 @@ function entity(options) {
|
|
|
87
98
|
if (options.path === undefined) {
|
|
88
99
|
options.path = (0, workspace_1.buildDefaultPath)(project);
|
|
89
100
|
}
|
|
101
|
+
if (options.path && !options.path.includes('src/app/core/store')) {
|
|
102
|
+
context.logger.warn('WARNING: Entity is being generated outside of src/app/core/store. We recommend generating entities in src/app/core/store.');
|
|
103
|
+
let redirect = false;
|
|
104
|
+
if (options.mockRedirect) {
|
|
105
|
+
redirect = true;
|
|
106
|
+
}
|
|
107
|
+
else if (process.stdout.isTTY && options.interactive !== false) {
|
|
108
|
+
const inquirer = await (new Function('return import("inquirer")')()).then((m) => m.default);
|
|
109
|
+
const answers = await inquirer.prompt([
|
|
110
|
+
{
|
|
111
|
+
type: 'confirm',
|
|
112
|
+
name: 'redirect',
|
|
113
|
+
message: 'Would you like to generate this in src/app/core/store instead?',
|
|
114
|
+
default: true
|
|
115
|
+
}
|
|
116
|
+
]);
|
|
117
|
+
redirect = answers.redirect;
|
|
118
|
+
}
|
|
119
|
+
if (redirect) {
|
|
120
|
+
options.path = 'src/app/core/store';
|
|
121
|
+
}
|
|
122
|
+
}
|
|
90
123
|
const parsedPath = (0, parse_name_1.parseName)(options.path, options.name);
|
|
91
124
|
options.name = parsedPath.name;
|
|
92
125
|
options.path = parsedPath.path;
|
package/src/entity/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["index.ts"],"names":[],"mappings":";;
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["index.ts"],"names":[],"mappings":";;AA2HA,wBAuDC;AAlLD,2DAIoC;AAEpC,+DAA0E;AAC1E,yEAA4E;AAC5E,uEAAmE;AACnE,qEAAuF;AACvF,+CAA+C;AAE/C,iEAAuF;AAEvF,SAAS,UAAU,CAAC,OAAY;IAC9B,OAAO,CAAC,IAAU,EAAE,OAAyB,EAAE,EAAE;QAE/C,MAAM,cAAc,GAAG,cAAO,CAAC,QAAQ,CAAC,OAAO,CAAC,IAAI,CAAC,CAAC;QACtD,MAAM,aAAa,GAAG,cAAO,CAAC,QAAQ,CAAC,OAAO,CAAC,IAAI,CAAC,CAAC;QACrD,MA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,kBAAK,EAAC;YACX,UAAU,CAAC,OAAO,CAAC;YACnB,IAAA,sBAAS,EAAC,cAAc,CAAC;SAC1B,CAAC,CAAC;IACL,CAAC,CAAC;AACJ,CAAC"}
|
package/src/entity/index_spec.js
CHANGED
|
@@ -65,7 +65,6 @@ describe('entity', () => {
|
|
|
65
65
|
const tree = await runner.runSchematic('entity', {
|
|
66
66
|
name: 'session',
|
|
67
67
|
project: 'test-app',
|
|
68
|
-
inDirectory: true,
|
|
69
68
|
path: 'src/app/core/store',
|
|
70
69
|
}, createWorkspaceTree());
|
|
71
70
|
// Verify the expected entity files are generated
|
|
@@ -77,7 +76,6 @@ describe('entity', () => {
|
|
|
77
76
|
const tree = await runner.runSchematic('entity', {
|
|
78
77
|
name: 'session',
|
|
79
78
|
project: 'test-app',
|
|
80
|
-
inDirectory: true,
|
|
81
79
|
path: 'src/app/core/store',
|
|
82
80
|
}, createWorkspaceTree());
|
|
83
81
|
const appModel = tree.readContent('/src/app/core/store/app.model.ts');
|
|
@@ -90,7 +88,6 @@ describe('entity', () => {
|
|
|
90
88
|
const tree = await runner.runSchematic('entity', {
|
|
91
89
|
name: 'session',
|
|
92
90
|
project: 'test-app',
|
|
93
|
-
inDirectory: true,
|
|
94
91
|
path: 'src/app/core/store',
|
|
95
92
|
}, createWorkspaceTree());
|
|
96
93
|
const fbMock = tree.readContent('/src/app/core/firebase/firebase.mock.service.ts');
|
|
@@ -105,15 +102,52 @@ describe('entity', () => {
|
|
|
105
102
|
expect(fbMock).toContain('sessions,');
|
|
106
103
|
expect(fbMock).toContain('sessions?: any[]');
|
|
107
104
|
});
|
|
108
|
-
it('should
|
|
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 () => {
|
|
109
120
|
const tree = await runner.runSchematic('entity', {
|
|
110
121
|
name: 'session',
|
|
111
122
|
project: 'test-app',
|
|
112
|
-
|
|
113
|
-
|
|
123
|
+
path: 'src/app/some-other-place',
|
|
124
|
+
mockRedirect: true,
|
|
114
125
|
}, createWorkspaceTree());
|
|
115
|
-
//
|
|
116
|
-
expect(tree.files).
|
|
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;');
|
|
117
151
|
});
|
|
118
152
|
});
|
|
119
153
|
//# sourceMappingURL=index_spec.js.map
|
|
@@ -1 +1 @@
|
|
|
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,EAAE;QACF,uCAAuC;QACvC,UAAU;QACV,MAAM;QACN,kBAAkB;QAClB,MAAM;QACN,sDAAsD;QACtD,+CAA+C;QAC/C,GAAG;KACJ,CAAC,IAAI,CAAC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QAEd,MAAM,IAAI,GAAG,MAAM,MAAM,CAAC,YAAY,CAAC,QAAQ,EAAE;YAC/C,IAAI,EAAE,SAAS;YACf,OAAO,EAAE,UAAU;YACnB,IAAI,EAAE,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"}
|
package/src/entity/schema.json
CHANGED
|
@@ -33,11 +33,6 @@
|
|
|
33
33
|
"index": 0
|
|
34
34
|
},
|
|
35
35
|
"x-prompt": "What name would you like to use for the entity?"
|
|
36
|
-
},
|
|
37
|
-
"inDirectory": {
|
|
38
|
-
"type": "boolean",
|
|
39
|
-
"default": true,
|
|
40
|
-
"x-prompt": "Are you currently in the directory where you want to generate the entity? (typically directly in src/app/core/store)"
|
|
41
36
|
}
|
|
42
37
|
},
|
|
43
38
|
"required": [
|
|
@@ -8,7 +8,7 @@ import {
|
|
|
8
8
|
RulesTestEnvironment,
|
|
9
9
|
} from '@firebase/rules-unit-testing';
|
|
10
10
|
import { readFileSync } from 'fs';
|
|
11
|
-
import { doc, setDoc, updateDoc, getDoc, deleteDoc, collection, addDoc } from 'firebase/firestore';
|
|
11
|
+
import { doc, setDoc, updateDoc, getDoc, deleteDoc, collection, addDoc, query, where, getDocs } from 'firebase/firestore';
|
|
12
12
|
|
|
13
13
|
let testEnv: RulesTestEnvironment;
|
|
14
14
|
|
|
@@ -138,6 +138,16 @@ describe('Firestore Security Rules', () => {
|
|
|
138
138
|
const adminDb = testEnv.authenticatedContext('admin').firestore();
|
|
139
139
|
await assertSucceeds(deleteDoc(doc(adminDb, 'users/alice')));
|
|
140
140
|
});
|
|
141
|
+
|
|
142
|
+
it('should allow authenticated users to list users', async () => {
|
|
143
|
+
const aliceDb = testEnv.authenticatedContext('alice').firestore();
|
|
144
|
+
await assertSucceeds(getDocs(collection(aliceDb, 'users')));
|
|
145
|
+
});
|
|
146
|
+
|
|
147
|
+
it('should deny unauthenticated users from listing users', async () => {
|
|
148
|
+
const unauthedDb = testEnv.unauthenticatedContext().firestore();
|
|
149
|
+
await assertFails(getDocs(collection(unauthedDb, 'users')));
|
|
150
|
+
});
|
|
141
151
|
});
|
|
142
152
|
|
|
143
153
|
describe('UserContexts Collection', () => {
|
|
@@ -211,6 +221,83 @@ describe('Firestore Security Rules', () => {
|
|
|
211
221
|
});
|
|
212
222
|
});
|
|
213
223
|
|
|
224
|
+
describe('UserPrivates Collection', () => {
|
|
225
|
+
it('should allow authenticated users to create their own private record', async () => {
|
|
226
|
+
const aliceDb = testEnv.authenticatedContext('alice').firestore();
|
|
227
|
+
await assertSucceeds(
|
|
228
|
+
setDoc(doc(aliceDb, 'userPrivates/alice'), {
|
|
229
|
+
email: 'alice@example.com',
|
|
230
|
+
})
|
|
231
|
+
);
|
|
232
|
+
});
|
|
233
|
+
|
|
234
|
+
it('should deny authenticated users from creating another users private record', async () => {
|
|
235
|
+
const aliceDb = testEnv.authenticatedContext('alice').firestore();
|
|
236
|
+
await assertFails(
|
|
237
|
+
setDoc(doc(aliceDb, 'userPrivates/bob'), {
|
|
238
|
+
email: 'bob@example.com',
|
|
239
|
+
})
|
|
240
|
+
);
|
|
241
|
+
});
|
|
242
|
+
|
|
243
|
+
it('should allow authenticated users to read their own private record', async () => {
|
|
244
|
+
await testEnv.withSecurityRulesDisabled(async (context) => {
|
|
245
|
+
await setDoc(doc(context.firestore(), 'userPrivates/alice'), { email: 'alice@example.com' });
|
|
246
|
+
});
|
|
247
|
+
const aliceDb = testEnv.authenticatedContext('alice').firestore();
|
|
248
|
+
await assertSucceeds(getDoc(doc(aliceDb, 'userPrivates/alice')));
|
|
249
|
+
});
|
|
250
|
+
|
|
251
|
+
it('should deny authenticated users from reading another users private record', async () => {
|
|
252
|
+
await testEnv.withSecurityRulesDisabled(async (context) => {
|
|
253
|
+
await setDoc(doc(context.firestore(), 'userPrivates/alice'), { email: 'alice@example.com' });
|
|
254
|
+
});
|
|
255
|
+
const bobDb = testEnv.authenticatedContext('bob').firestore();
|
|
256
|
+
await assertFails(getDoc(doc(bobDb, 'userPrivates/alice')));
|
|
257
|
+
});
|
|
258
|
+
|
|
259
|
+
it('should allow admin to read another users private record', async () => {
|
|
260
|
+
await testEnv.withSecurityRulesDisabled(async (context) => {
|
|
261
|
+
await setDoc(doc(context.firestore(), 'users/admin'), { isAdmin: true });
|
|
262
|
+
await setDoc(doc(context.firestore(), 'userPrivates/alice'), { email: 'alice@example.com' });
|
|
263
|
+
});
|
|
264
|
+
const adminDb = testEnv.authenticatedContext('admin').firestore();
|
|
265
|
+
await assertSucceeds(getDoc(doc(adminDb, 'userPrivates/alice')));
|
|
266
|
+
});
|
|
267
|
+
|
|
268
|
+
it('should allow authenticated users to update their own private record', async () => {
|
|
269
|
+
await testEnv.withSecurityRulesDisabled(async (context) => {
|
|
270
|
+
await setDoc(doc(context.firestore(), 'userPrivates/alice'), { email: 'alice@example.com' });
|
|
271
|
+
});
|
|
272
|
+
const aliceDb = testEnv.authenticatedContext('alice').firestore();
|
|
273
|
+
await assertSucceeds(updateDoc(doc(aliceDb, 'userPrivates/alice'), { email: 'alice2@example.com' }));
|
|
274
|
+
});
|
|
275
|
+
|
|
276
|
+
it('should deny authenticated users from updating another users private record', async () => {
|
|
277
|
+
await testEnv.withSecurityRulesDisabled(async (context) => {
|
|
278
|
+
await setDoc(doc(context.firestore(), 'userPrivates/alice'), { email: 'alice@example.com' });
|
|
279
|
+
});
|
|
280
|
+
const bobDb = testEnv.authenticatedContext('bob').firestore();
|
|
281
|
+
await assertFails(updateDoc(doc(bobDb, 'userPrivates/alice'), { email: 'alice2@example.com' }));
|
|
282
|
+
});
|
|
283
|
+
|
|
284
|
+
it('should allow authenticated users to delete their own private record', async () => {
|
|
285
|
+
await testEnv.withSecurityRulesDisabled(async (context) => {
|
|
286
|
+
await setDoc(doc(context.firestore(), 'userPrivates/alice'), { email: 'alice@example.com' });
|
|
287
|
+
});
|
|
288
|
+
const aliceDb = testEnv.authenticatedContext('alice').firestore();
|
|
289
|
+
await assertSucceeds(deleteDoc(doc(aliceDb, 'userPrivates/alice')));
|
|
290
|
+
});
|
|
291
|
+
|
|
292
|
+
it('should deny authenticated users from deleting another users private record', async () => {
|
|
293
|
+
await testEnv.withSecurityRulesDisabled(async (context) => {
|
|
294
|
+
await setDoc(doc(context.firestore(), 'userPrivates/alice'), { email: 'alice@example.com' });
|
|
295
|
+
});
|
|
296
|
+
const bobDb = testEnv.authenticatedContext('bob').firestore();
|
|
297
|
+
await assertFails(deleteDoc(doc(bobDb, 'userPrivates/alice')));
|
|
298
|
+
});
|
|
299
|
+
});
|
|
300
|
+
|
|
214
301
|
describe('Default Deny', () => {
|
|
215
302
|
it('should deny read/write to unknown collections', async () => {
|
|
216
303
|
const aliceDb = testEnv.authenticatedContext('alice').firestore();
|
|
@@ -39,6 +39,15 @@ service cloud.firestore {
|
|
|
39
39
|
&& (request.auth.uid == userId || isAdmin());
|
|
40
40
|
}
|
|
41
41
|
|
|
42
|
+
// ─── User Privates ───────────────────────────────────────────────────
|
|
43
|
+
// Create/Read/Update/Delete: only the user themselves (document ID == auth.uid) or admins
|
|
44
|
+
match /userPrivates/{userId} {
|
|
45
|
+
allow create: if request.auth != null && request.auth.uid == userId;
|
|
46
|
+
allow read: if request.auth != null && (request.auth.uid == userId || isAdmin());
|
|
47
|
+
allow update: if request.auth != null && (request.auth.uid == userId || isAdmin());
|
|
48
|
+
allow delete: if request.auth != null && (request.auth.uid == userId || isAdmin());
|
|
49
|
+
}
|
|
50
|
+
|
|
42
51
|
// ─── User Contexts ───────────────────────────────────────────────────
|
|
43
52
|
// Create: only the user themselves (auth.uid == __userId)
|
|
44
53
|
// Read: only the user themselves or admins
|
|
@@ -14,7 +14,9 @@
|
|
|
14
14
|
"lint": "ng lint",
|
|
15
15
|
"lintfix": "ng lint --fix",
|
|
16
16
|
"code-check": "ngc --noEmit && sass src:dist/css-check --no-source-map && rm -rf dist/css-check && npm run lintfix",
|
|
17
|
-
"analyze": "ng build --stats-json && esbuild-visualizer --metadata dist/<%= dasherize(project) %>/stats.json --filename dist/<%= dasherize(project) %>/bundle-analysis.html && open dist/<%= dasherize(project) %>/bundle-analysis.html"
|
|
17
|
+
"analyze": "ng build --stats-json && esbuild-visualizer --metadata dist/<%= dasherize(project) %>/stats.json --filename dist/<%= dasherize(project) %>/bundle-analysis.html && open dist/<%= dasherize(project) %>/bundle-analysis.html",
|
|
18
|
+
"deploy:dev": "ng build --configuration development && firebase deploy --project dev",
|
|
19
|
+
"deploy:prod": "ng build --configuration production && firebase deploy --project prod"
|
|
18
20
|
},
|
|
19
21
|
"private": true,
|
|
20
22
|
"dependencies": {
|
|
@@ -53,7 +55,7 @@
|
|
|
53
55
|
"@firebase/rules-unit-testing": "^5.0.1",
|
|
54
56
|
"firebase-tools": "^14.27.0",
|
|
55
57
|
"@ngx-env/builder": "^21.0.1",
|
|
56
|
-
"@tech4good/angular-schematics": "^21.
|
|
58
|
+
"@tech4good/angular-schematics": "^21.4.0",
|
|
57
59
|
"@types/estree": "^1.0.0",
|
|
58
60
|
"@types/jest": "^30.0.0",
|
|
59
61
|
"@types/node": "^18.19.47",
|
|
@@ -66,11 +66,11 @@ describe('AdminUserListComponent', () => {
|
|
|
66
66
|
|
|
67
67
|
// Wait for streams to populate and display user rows
|
|
68
68
|
expect(await screen.findByText('Alice Waiting')).toBeVisible();
|
|
69
|
-
expect(screen.
|
|
69
|
+
expect(await screen.findByText('Bob Done')).toBeVisible();
|
|
70
70
|
|
|
71
71
|
// Verify user context data is rendered (questionOne / questionTwo) with findByText to allow async resolution
|
|
72
|
-
expect(await screen.findByText('
|
|
73
|
-
expect(screen.
|
|
72
|
+
expect(await screen.findByText('Response to question one')).toBeVisible();
|
|
73
|
+
expect(await screen.findByText('Response to question two')).toBeVisible();
|
|
74
74
|
});
|
|
75
75
|
|
|
76
76
|
it('should handle pagination limit state updates when clicking Load More', async () => {
|
|
@@ -1,5 +1,12 @@
|
|
|
1
|
-
|
|
1
|
+
:host {
|
|
2
|
+
display: flex;
|
|
3
|
+
flex-direction: column;
|
|
2
4
|
height: 100%;
|
|
5
|
+
}
|
|
6
|
+
|
|
7
|
+
.content-container {
|
|
8
|
+
flex: 1;
|
|
9
|
+
min-height: 0;
|
|
3
10
|
width: 100%;
|
|
4
11
|
position: relative;
|
|
5
12
|
display: flex;
|
|
@@ -11,6 +18,7 @@
|
|
|
11
18
|
flex: 1;
|
|
12
19
|
overflow: auto;
|
|
13
20
|
min-height: 0;
|
|
21
|
+
height: 100%;
|
|
14
22
|
}
|
|
15
23
|
|
|
16
24
|
app-redeployment-warning {
|
|
@@ -8,7 +8,7 @@ import { BatchWriteMockService } from 'src/app/core/store/batch-write.mock.servi
|
|
|
8
8
|
import { BATCH_WRITE_SERVICE } from 'src/app/core/store/batch-write.service';
|
|
9
9
|
import { LOG_SERVICE, LogInDevService } from './core/analytics/log.service';
|
|
10
10
|
|
|
11
|
-
/** Sets up the testing environment for AppComponent using render
|
|
11
|
+
/** Sets up the testing environment for AppComponent using render. */
|
|
12
12
|
async function setup() {
|
|
13
13
|
const user = userEvent.setup();
|
|
14
14
|
const checkedSpy = jest.fn();
|
|
@@ -36,4 +36,4 @@ describe('AppComponent', () => {
|
|
|
36
36
|
const { fixture } = await setup();
|
|
37
37
|
expect(fixture.componentInstance).toBeTruthy();
|
|
38
38
|
});
|
|
39
|
-
});
|
|
39
|
+
});
|
|
@@ -31,7 +31,7 @@ describe('Core Auth Routing', () => {
|
|
|
31
31
|
providers: [
|
|
32
32
|
provideRouter(routes),
|
|
33
33
|
{ provide: AuthService, useValue: mockAuthService },
|
|
34
|
-
{ provide: AuthStore, useValue: { user: mockUserSignal } },
|
|
34
|
+
{ provide: AuthStore, useValue: { user: mockUserSignal, isLoadingLogin: signal(false) } },
|
|
35
35
|
{ provide: DATABASE_SERVICE, useClass: FirebaseMockService },
|
|
36
36
|
{ provide: BATCH_WRITE_SERVICE, useClass: BatchWriteMockService },
|
|
37
37
|
{ provide: LOG_SERVICE, useClass: LogInDevService },
|
|
@@ -63,7 +63,7 @@ describe('TimeAnalyticsService', () => {
|
|
|
63
63
|
|
|
64
64
|
// 2. Now a delayed subscriber comes in.
|
|
65
65
|
let capturedRoute: string | undefined;
|
|
66
|
-
|
|
66
|
+
|
|
67
67
|
// Note: currentRoute$ is a private property. We can access it via bracket notation for testing,
|
|
68
68
|
// or test the public behavior. Since we specifically want to verify the RxJS shareReplay caching
|
|
69
69
|
// on `currentRoute$`, we will inspect it directly.
|
|
@@ -117,7 +117,7 @@ describe('TimeAnalyticsService', () => {
|
|
|
117
117
|
expect(savedLog.__sessionId).toEqual('test-session-id');
|
|
118
118
|
expect(savedLog.__deviceId).toEqual('test-device-id');
|
|
119
119
|
expect(savedLog.startTime).toEqual(1000);
|
|
120
|
-
|
|
120
|
+
|
|
121
121
|
// Total active time should be 2000 ms (from T=1000 to T=3000)
|
|
122
122
|
const activeTime = savedLog.time.find((t: any) => t.type === 'active');
|
|
123
123
|
expect(activeTime).toBeDefined();
|