@dereekb/firebase 13.31.0 → 13.33.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/eslint/package.json +3 -3
- package/index.cjs.js +1913 -765
- package/index.esm.js +1858 -768
- package/package.json +5 -5
- package/src/lib/common/firestore/snapshot/snapshot.field.d.ts +59 -4
- package/src/lib/model/index.d.ts +1 -0
- package/src/lib/model/notification/index.d.ts +2 -0
- package/src/lib/model/notification/notification.api.d.ts +102 -0
- package/src/lib/model/notification/notification.api.error.d.ts +15 -0
- package/src/lib/model/notification/notification.d.ts +11 -0
- package/src/lib/model/notification/notification.healthcheck.d.ts +616 -0
- package/src/lib/model/notification/notification.healthcheck.mailgun.d.ts +57 -0
- package/src/lib/model/userexternalconnection/index.d.ts +6 -0
- package/src/lib/model/userexternalconnection/userexternalconnection.action.d.ts +21 -0
- package/src/lib/model/userexternalconnection/userexternalconnection.api.d.ts +120 -0
- package/src/lib/model/userexternalconnection/userexternalconnection.d.ts +191 -0
- package/src/lib/model/userexternalconnection/userexternalconnection.id.d.ts +51 -0
- package/src/lib/model/userexternalconnection/userexternalconnection.query.d.ts +19 -0
- package/src/lib/model/userexternalconnection/userexternalconnection.util.d.ts +149 -0
- package/test/index.cjs.js +371 -50
- package/test/index.esm.js +362 -51
- package/test/package.json +6 -6
- package/test/src/lib/client/firebase.rules.d.ts +114 -0
- package/test/src/lib/client/index.d.ts +1 -0
package/test/package.json
CHANGED
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@dereekb/firebase/test",
|
|
3
|
-
"version": "13.
|
|
3
|
+
"version": "13.33.0",
|
|
4
4
|
"peerDependencies": {
|
|
5
|
-
"@dereekb/date": "13.
|
|
6
|
-
"@dereekb/firebase": "13.
|
|
7
|
-
"@dereekb/model": "13.
|
|
8
|
-
"@dereekb/rxjs": "13.
|
|
9
|
-
"@dereekb/util": "13.
|
|
5
|
+
"@dereekb/date": "13.33.0",
|
|
6
|
+
"@dereekb/firebase": "13.33.0",
|
|
7
|
+
"@dereekb/model": "13.33.0",
|
|
8
|
+
"@dereekb/rxjs": "13.33.0",
|
|
9
|
+
"@dereekb/util": "13.33.0",
|
|
10
10
|
"@firebase/rules-unit-testing": "5.0.0",
|
|
11
11
|
"date-fns": "^4.1.0",
|
|
12
12
|
"firebase": "^12.12.1",
|
|
@@ -0,0 +1,114 @@
|
|
|
1
|
+
import { type Maybe } from '@dereekb/util';
|
|
2
|
+
import { type EmulatorConfig, type RulesTestEnvironment, type TokenOptions } from '@firebase/rules-unit-testing';
|
|
3
|
+
import { type Firestore } from 'firebase/firestore';
|
|
4
|
+
export { assertFails, assertSucceeds } from '@firebase/rules-unit-testing';
|
|
5
|
+
/**
|
|
6
|
+
* Default file name of the workspace's Firestore security rules.
|
|
7
|
+
*/
|
|
8
|
+
export declare const DEFAULT_FIRESTORE_RULES_FILE_NAME = "firestore.rules";
|
|
9
|
+
/**
|
|
10
|
+
* Configuration for {@link readFirestoreRulesFile}.
|
|
11
|
+
*/
|
|
12
|
+
export interface ReadFirestoreRulesFileConfig {
|
|
13
|
+
/**
|
|
14
|
+
* A path or `import.meta.url` to begin searching upward from.
|
|
15
|
+
*
|
|
16
|
+
* Resolve from the calling module rather than `process.cwd()`: vitest sets `root` to the project
|
|
17
|
+
* directory, so the working directory is not the workspace root when specs run.
|
|
18
|
+
*/
|
|
19
|
+
readonly from: string;
|
|
20
|
+
/**
|
|
21
|
+
* File name to look for. Defaults to `firestore.rules`.
|
|
22
|
+
*/
|
|
23
|
+
readonly fileName?: Maybe<string>;
|
|
24
|
+
}
|
|
25
|
+
/**
|
|
26
|
+
* Reads the workspace's Firestore rules file by walking up from the given module/path.
|
|
27
|
+
*
|
|
28
|
+
* @param config - The starting location and optional file name.
|
|
29
|
+
* @returns The contents of the rules file.
|
|
30
|
+
* @throws {Error} When no rules file is found at or above the starting location.
|
|
31
|
+
*/
|
|
32
|
+
export declare function readFirestoreRulesFile(config: ReadFirestoreRulesFileConfig): string;
|
|
33
|
+
/**
|
|
34
|
+
* Configuration for {@link firestoreRulesTestBuilder}.
|
|
35
|
+
*/
|
|
36
|
+
export interface FirestoreRulesTestConfig {
|
|
37
|
+
/**
|
|
38
|
+
* Explicit project id for the rules test environment.
|
|
39
|
+
*
|
|
40
|
+
* Rules tests must not share a project id with other suites, since documents seeded with rules
|
|
41
|
+
* disabled would otherwise be visible across suites.
|
|
42
|
+
*/
|
|
43
|
+
readonly projectId: string;
|
|
44
|
+
/**
|
|
45
|
+
* The Firestore security rules source to load. See {@link readFirestoreRulesFile}.
|
|
46
|
+
*/
|
|
47
|
+
readonly rules: string;
|
|
48
|
+
/**
|
|
49
|
+
* Optional emulator connection details. Defaults to the emulator config in the environment.
|
|
50
|
+
*/
|
|
51
|
+
readonly firestore?: Maybe<EmulatorConfig>;
|
|
52
|
+
}
|
|
53
|
+
/**
|
|
54
|
+
* Fixture handed to a {@link firestoreRulesTestBuilder} test body.
|
|
55
|
+
*
|
|
56
|
+
* Exposes RAW `firebase/firestore` handles rather than a `TestFirestoreContext`: the
|
|
57
|
+
* `firebaseRulesUnitTestBuilder()` drivers wrap every collection path with
|
|
58
|
+
* `makeTestingFirestoreAccesorDriver`, which fuzzes it to `${time}_${random}_${path}_${n}` — a
|
|
59
|
+
* fuzzed path can never match a `match /uec/{id}` rule, so those drivers cannot test rules.
|
|
60
|
+
*/
|
|
61
|
+
export interface FirestoreRulesTestFixture {
|
|
62
|
+
/**
|
|
63
|
+
* The underlying rules test environment.
|
|
64
|
+
*/
|
|
65
|
+
readonly rulesTestEnvironment: RulesTestEnvironment;
|
|
66
|
+
/**
|
|
67
|
+
* Returns a Firestore handle authenticated as the given user.
|
|
68
|
+
*
|
|
69
|
+
* @param userId - The uid to authenticate as.
|
|
70
|
+
* @param tokenOptions - Optional additional auth token claims.
|
|
71
|
+
* @returns A Firestore instance subject to the loaded security rules.
|
|
72
|
+
*/
|
|
73
|
+
firestoreForUser(userId: string, tokenOptions?: Maybe<TokenOptions>): Firestore;
|
|
74
|
+
/**
|
|
75
|
+
* Returns an unauthenticated Firestore handle.
|
|
76
|
+
*
|
|
77
|
+
* @returns A Firestore instance subject to the loaded security rules.
|
|
78
|
+
*/
|
|
79
|
+
unauthenticatedFirestore(): Firestore;
|
|
80
|
+
/**
|
|
81
|
+
* Runs the given function with security rules disabled, for seeding documents.
|
|
82
|
+
*
|
|
83
|
+
* @param fn - Receives a rules-bypassing Firestore instance.
|
|
84
|
+
* @returns A promise that resolves when the seeding completes.
|
|
85
|
+
*/
|
|
86
|
+
withSecurityRulesDisabled(fn: (firestore: Firestore) => Promise<void>): Promise<void>;
|
|
87
|
+
}
|
|
88
|
+
/**
|
|
89
|
+
* Registers vitest hooks that initialize a Firestore security-rules test environment, and invokes
|
|
90
|
+
* the given callback with a {@link FirestoreRulesTestFixture}.
|
|
91
|
+
*
|
|
92
|
+
* The environment is created once per suite (`beforeAll`), torn down once (`afterAll`), and the
|
|
93
|
+
* Firestore data is cleared between tests (`beforeEach`).
|
|
94
|
+
*
|
|
95
|
+
* @param config - The project id and rules to load.
|
|
96
|
+
* @returns A function that takes the test body builder.
|
|
97
|
+
*
|
|
98
|
+
* @example
|
|
99
|
+
* ```ts
|
|
100
|
+
* const rulesTest = firestoreRulesTestBuilder({
|
|
101
|
+
* projectId: 'demo-api-rules-test',
|
|
102
|
+
* rules: readFirestoreRulesFile({ from: import.meta.url })
|
|
103
|
+
* });
|
|
104
|
+
*
|
|
105
|
+
* describe('firestore.rules', () => {
|
|
106
|
+
* rulesTest((f) => {
|
|
107
|
+
* it('allows the owner to read their own document', async () => {
|
|
108
|
+
* await assertSucceeds(getDoc(doc(f.firestoreForUser('a'), 'uec', 'a')));
|
|
109
|
+
* });
|
|
110
|
+
* });
|
|
111
|
+
* });
|
|
112
|
+
* ```
|
|
113
|
+
*/
|
|
114
|
+
export declare function firestoreRulesTestBuilder(config: FirestoreRulesTestConfig): (buildTests: (fixture: FirestoreRulesTestFixture) => void) => void;
|