@dereekb/firebase 13.2.2 → 13.3.1

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 (135) hide show
  1. package/index.cjs.js +12893 -4062
  2. package/index.esm.js +12872 -4065
  3. package/package.json +5 -5
  4. package/src/lib/client/error/error.d.ts +18 -3
  5. package/src/lib/client/firestore/array.d.ts +16 -3
  6. package/src/lib/client/firestore/driver.accessor.batch.d.ts +35 -4
  7. package/src/lib/client/firestore/driver.accessor.create.d.ts +15 -0
  8. package/src/lib/client/firestore/driver.accessor.d.ts +15 -0
  9. package/src/lib/client/firestore/driver.accessor.default.d.ts +32 -0
  10. package/src/lib/client/firestore/driver.accessor.transaction.d.ts +35 -4
  11. package/src/lib/client/firestore/driver.d.ts +16 -0
  12. package/src/lib/client/firestore/driver.query.d.ts +36 -0
  13. package/src/lib/client/firestore/firestore.d.ts +11 -1
  14. package/src/lib/client/firestore/increment.d.ts +12 -3
  15. package/src/lib/client/function/development.function.factory.d.ts +27 -2
  16. package/src/lib/client/function/error.d.ts +27 -0
  17. package/src/lib/client/function/function.callable.d.ts +50 -5
  18. package/src/lib/client/function/function.factory.d.ts +70 -4
  19. package/src/lib/client/function/model.function.factory.d.ts +64 -9
  20. package/src/lib/client/storage/driver.accessor.d.ts +93 -0
  21. package/src/lib/client/storage/driver.d.ts +15 -0
  22. package/src/lib/client/storage/storage.d.ts +10 -1
  23. package/src/lib/common/auth/auth.context.d.ts +17 -2
  24. package/src/lib/common/auth/auth.d.ts +38 -9
  25. package/src/lib/common/auth/auth.error.d.ts +25 -0
  26. package/src/lib/common/auth/auth.server.error.d.ts +6 -2
  27. package/src/lib/common/development/function.d.ts +17 -6
  28. package/src/lib/common/development/function.schedule.d.ts +30 -1
  29. package/src/lib/common/firestore/accessor/accessor.wrap.modify.d.ts +36 -12
  30. package/src/lib/common/firestore/accessor/array.d.ts +14 -4
  31. package/src/lib/common/firestore/accessor/document.d.ts +77 -2
  32. package/src/lib/common/firestore/accessor/increment.d.ts +15 -3
  33. package/src/lib/common/firestore/collection/collection.d.ts +22 -4
  34. package/src/lib/common/firestore/collection/collection.util.d.ts +12 -2
  35. package/src/lib/common/firestore/driver/accessor.d.ts +28 -1
  36. package/src/lib/common/firestore/driver/batch.d.ts +6 -4
  37. package/src/lib/common/firestore/driver/driver.d.ts +18 -1
  38. package/src/lib/common/firestore/driver/query.d.ts +20 -1
  39. package/src/lib/common/firestore/driver/query.handler.d.ts +23 -0
  40. package/src/lib/common/firestore/driver/transaction.d.ts +18 -6
  41. package/src/lib/common/firestore/error.d.ts +16 -4
  42. package/src/lib/common/firestore/query/iterator.d.ts +11 -0
  43. package/src/lib/common/firestore/reference.d.ts +11 -6
  44. package/src/lib/common/firestore/snapshot/snapshot.d.ts +4 -0
  45. package/src/lib/common/firestore/snapshot/snapshot.field.d.ts +263 -63
  46. package/src/lib/common/firestore/types.d.ts +39 -1
  47. package/src/lib/common/firestore/util/id.batch.d.ts +55 -3
  48. package/src/lib/common/function/action.d.ts +35 -0
  49. package/src/lib/common/model/context.d.ts +11 -1
  50. package/src/lib/common/model/function.d.ts +45 -9
  51. package/src/lib/common/model/model/model.loader.d.ts +37 -0
  52. package/src/lib/common/model/model/model.param.d.ts +24 -2
  53. package/src/lib/common/model/model.service.d.ts +126 -4
  54. package/src/lib/common/model/permission/permission.context.d.ts +15 -0
  55. package/src/lib/common/model/permission/permission.d.ts +16 -0
  56. package/src/lib/common/model/permission/permission.service.d.ts +24 -1
  57. package/src/lib/common/model/permission/permission.service.grant.d.ts +72 -28
  58. package/src/lib/common/model/permission/permission.service.role.d.ts +15 -0
  59. package/src/lib/common/storage/accessor/path.model.d.ts +25 -8
  60. package/src/lib/common/storage/context.d.ts +23 -6
  61. package/src/lib/common/storage/driver/accessor.d.ts +15 -4
  62. package/src/lib/common/storage/driver/accessor.iterate.d.ts +31 -8
  63. package/src/lib/common/storage/driver/accessor.util.d.ts +13 -6
  64. package/src/lib/common/storage/driver/driver.d.ts +10 -1
  65. package/src/lib/common/storage/driver/error.d.ts +16 -0
  66. package/src/lib/common/storage/driver/list.d.ts +30 -0
  67. package/src/lib/common/storage/storage.d.ts +76 -19
  68. package/src/lib/common/storage/types.d.ts +23 -5
  69. package/src/lib/model/index.d.ts +1 -0
  70. package/src/lib/model/notification/notification.action.d.ts +8 -0
  71. package/src/lib/model/notification/notification.api.d.ts +26 -0
  72. package/src/lib/model/notification/notification.api.error.d.ts +15 -0
  73. package/src/lib/model/notification/notification.api.util.d.ts +27 -12
  74. package/src/lib/model/notification/notification.config.d.ts +193 -64
  75. package/src/lib/model/notification/notification.create.d.ts +62 -13
  76. package/src/lib/model/notification/notification.create.task.d.ts +25 -4
  77. package/src/lib/model/notification/notification.d.ts +258 -99
  78. package/src/lib/model/notification/notification.details.d.ts +66 -18
  79. package/src/lib/model/notification/notification.id.d.ts +90 -12
  80. package/src/lib/model/notification/notification.item.d.ts +57 -16
  81. package/src/lib/model/notification/notification.message.d.ts +84 -18
  82. package/src/lib/model/notification/notification.query.d.ts +21 -24
  83. package/src/lib/model/notification/notification.send.d.ts +38 -5
  84. package/src/lib/model/notification/notification.task.d.ts +87 -16
  85. package/src/lib/model/notification/notification.task.subtask.d.ts +42 -13
  86. package/src/lib/model/notification/notification.util.d.ts +68 -18
  87. package/src/lib/model/oidcmodel/index.d.ts +8 -0
  88. package/src/lib/model/oidcmodel/oidcmodel.action.d.ts +37 -0
  89. package/src/lib/model/oidcmodel/oidcmodel.api.d.ts +131 -0
  90. package/src/lib/model/oidcmodel/oidcmodel.d.ts +114 -0
  91. package/src/lib/model/oidcmodel/oidcmodel.data.d.ts +17 -0
  92. package/src/lib/model/oidcmodel/oidcmodel.id.d.ts +18 -0
  93. package/src/lib/model/oidcmodel/oidcmodel.interaction.d.ts +40 -0
  94. package/src/lib/model/oidcmodel/oidcmodel.interaction.oauth.d.ts +73 -0
  95. package/src/lib/model/oidcmodel/oidcmodel.query.d.ts +21 -0
  96. package/src/lib/model/storagefile/storagefile.action.d.ts +47 -0
  97. package/src/lib/model/storagefile/storagefile.api.d.ts +54 -4
  98. package/src/lib/model/storagefile/storagefile.create.d.ts +40 -3
  99. package/src/lib/model/storagefile/storagefile.d.ts +153 -16
  100. package/src/lib/model/storagefile/storagefile.file.d.ts +22 -7
  101. package/src/lib/model/storagefile/storagefile.group.d.ts +30 -1
  102. package/src/lib/model/storagefile/storagefile.group.processing.d.ts +20 -2
  103. package/src/lib/model/storagefile/storagefile.id.d.ts +44 -5
  104. package/src/lib/model/storagefile/storagefile.permission.d.ts +23 -4
  105. package/src/lib/model/storagefile/storagefile.query.d.ts +63 -11
  106. package/src/lib/model/storagefile/storagefile.task.d.ts +47 -4
  107. package/src/lib/model/storagefile/storagefile.upload.claims.d.ts +21 -4
  108. package/src/lib/model/storagefile/storagefile.upload.d.ts +41 -9
  109. package/src/lib/model/storagefile/storagefile.upload.determiner.d.ts +112 -20
  110. package/src/lib/model/storagefile/storagefile.util.d.ts +66 -3
  111. package/src/lib/model/system/system.action.d.ts +25 -0
  112. package/src/lib/model/system/system.d.ts +80 -4
  113. package/src/lib/model/user.d.ts +8 -2
  114. package/test/index.cjs.js +11168 -3295
  115. package/test/index.esm.js +11176 -3303
  116. package/test/package.json +6 -6
  117. package/test/src/lib/client/firebase.authorized.d.ts +18 -0
  118. package/test/src/lib/client/firebase.d.ts +60 -0
  119. package/test/src/lib/common/firebase.instance.d.ts +21 -0
  120. package/test/src/lib/common/firestore/firestore.d.ts +40 -0
  121. package/test/src/lib/common/firestore/firestore.instance.d.ts +16 -0
  122. package/test/src/lib/common/firestore/test.driver.accessor.d.ts +39 -2
  123. package/test/src/lib/common/firestore/test.driver.utility.d.ts +8 -2
  124. package/test/src/lib/common/firestore/test.iterator.d.ts +7 -2
  125. package/test/src/lib/common/mock/mock.item.collection.fixture.d.ts +29 -1
  126. package/test/src/lib/common/mock/mock.item.d.ts +219 -5
  127. package/test/src/lib/common/mock/mock.item.id.d.ts +6 -0
  128. package/test/src/lib/common/mock/mock.item.query.d.ts +12 -0
  129. package/test/src/lib/common/mock/mock.item.service.d.ts +60 -0
  130. package/test/src/lib/common/mock/mock.item.storage.fixture.d.ts +28 -1
  131. package/test/src/lib/common/storage/storage.d.ts +30 -0
  132. package/test/src/lib/common/storage/storage.instance.d.ts +22 -0
  133. package/test/src/lib/common/storage/test.driver.accessor.d.ts +7 -2
  134. package/index.cjs.js.map +0 -1
  135. package/index.esm.js.map +0 -1
package/test/package.json CHANGED
@@ -1,12 +1,12 @@
1
1
  {
2
2
  "name": "@dereekb/firebase/test",
3
- "version": "13.2.2",
3
+ "version": "13.3.1",
4
4
  "peerDependencies": {
5
- "@dereekb/date": "13.2.2",
6
- "@dereekb/firebase": "13.2.2",
7
- "@dereekb/model": "13.2.2",
8
- "@dereekb/rxjs": "13.2.2",
9
- "@dereekb/util": "13.2.2",
5
+ "@dereekb/date": "13.3.1",
6
+ "@dereekb/firebase": "13.3.1",
7
+ "@dereekb/model": "13.3.1",
8
+ "@dereekb/rxjs": "13.3.1",
9
+ "@dereekb/util": "13.3.1",
10
10
  "@firebase/rules-unit-testing": "5.0.0",
11
11
  "date-fns": "^4.0.0",
12
12
  "firebase": "^12.0.0",
@@ -1,5 +1,23 @@
1
1
  import { type TestContextFactory } from '@dereekb/util/test';
2
2
  import { type RulesUnitTestFirebaseTestingContextFixture } from './firebase';
3
+ /**
4
+ * Default user ID used for the authenticated context in client-side Firebase tests.
5
+ */
3
6
  export declare const TESTING_AUTHORIZED_FIREBASE_USER_ID = "0";
7
+ /**
8
+ * Convenience type alias for a test context factory that produces {@link RulesUnitTestFirebaseTestingContextFixture} instances.
9
+ */
4
10
  export type FirebaseTestContextFactory = TestContextFactory<RulesUnitTestFirebaseTestingContextFixture>;
11
+ /**
12
+ * Pre-configured {@link FirebaseTestContextFactory} that provides a fully authorized (all reads/writes allowed)
13
+ * Firebase emulator context for both Firestore and Storage.
14
+ *
15
+ * Uses permissive security rules and authenticates as {@link TESTING_AUTHORIZED_FIREBASE_USER_ID}.
16
+ * This is the most common base factory for client-side mock item tests.
17
+ *
18
+ * @example
19
+ * ```ts
20
+ * const f = testWithMockItemCollectionFixture()(authorizedFirebaseFactory);
21
+ * ```
22
+ */
5
23
  export declare const authorizedFirebaseFactory: FirebaseTestContextFactory;
@@ -5,11 +5,26 @@ import { type FirebaseStorage, type Firestore } from '@dereekb/firebase';
5
5
  import { type TestFirebaseStorageContext, type TestingFirebaseStorageDrivers } from '../common/storage/storage';
6
6
  import { TestFirebaseContextFixture, type TestFirebaseInstance } from '../common/firebase.instance';
7
7
  import { type TestFirebaseStorageInstance } from '../common/storage/storage.instance';
8
+ /**
9
+ * Combined driver type providing both Firestore and Firebase Storage testing drivers.
10
+ */
8
11
  export type TestingFirebaseDrivers = TestingFirestoreDrivers & TestingFirebaseStorageDrivers;
12
+ /**
13
+ * Configuration for the authenticated context used in rules unit tests.
14
+ *
15
+ * When provided, the test runs as the specified user. When omitted,
16
+ * tests run as an unauthenticated context.
17
+ */
9
18
  export interface RulesUnitTestingContextConfig {
10
19
  readonly userId: string;
11
20
  readonly tokenOptions?: Maybe<TokenOptions>;
12
21
  }
22
+ /**
23
+ * Extended {@link TestEnvironmentConfig} with additional options for emulator setup.
24
+ *
25
+ * The `collectionNames` field is required when using testing drivers that fuzz collection names
26
+ * to isolate parallel test runs.
27
+ */
13
28
  export interface RulesUnitTestingTestEnvironmentConfig extends TestEnvironmentConfig {
14
29
  /**
15
30
  * List of collection names used in the environment. Is required if using testing drivers.
@@ -18,20 +33,53 @@ export interface RulesUnitTestingTestEnvironmentConfig extends TestEnvironmentCo
18
33
  readonly firestore?: EmulatorConfig;
19
34
  readonly storage?: EmulatorConfig;
20
35
  }
36
+ /**
37
+ * Top-level configuration for {@link firebaseRulesUnitTestBuilder}.
38
+ *
39
+ * Combines the emulator environment config with an optional authenticated context.
40
+ */
21
41
  export interface RulesUnitTestingConfig {
22
42
  readonly testEnvironment: RulesUnitTestingTestEnvironmentConfig;
23
43
  readonly rulesContext?: Maybe<RulesUnitTestingContextConfig>;
24
44
  }
45
+ /**
46
+ * Extends {@link TestFirestoreContext} with references to the underlying `@firebase/rules-unit-testing` objects.
47
+ *
48
+ * Useful when a test needs direct access to the rules test environment (e.g., for clearing data or
49
+ * switching auth contexts).
50
+ */
25
51
  export interface RulesUnitTestTestFirestoreContext extends TestFirestoreContext {
26
52
  readonly rulesTestEnvironment: RulesTestEnvironment;
27
53
  readonly rulesTestContext: RulesTestContext;
28
54
  }
55
+ /**
56
+ * Creates a {@link TestFirestoreContext} backed by the rules unit testing emulator.
57
+ *
58
+ * Combines the Firestore client drivers with the rules test environment and context
59
+ * to produce a context suitable for client-side Firestore tests.
60
+ */
29
61
  export declare function makeRulesTestFirestoreContext(drivers: TestingFirestoreDrivers, rulesTestEnvironment: RulesTestEnvironment, rulesTestContext: RulesTestContext): TestFirestoreContext;
62
+ /**
63
+ * Extends {@link TestFirebaseStorageContext} with references to the underlying `@firebase/rules-unit-testing` objects.
64
+ */
30
65
  export interface RulesUnitTestTestFirebaseStorageContext extends TestFirebaseStorageContext {
31
66
  readonly rulesTestEnvironment: RulesTestEnvironment;
32
67
  readonly rulesTestContext: RulesTestContext;
33
68
  }
69
+ /**
70
+ * Creates a {@link TestFirebaseStorageContext} backed by the rules unit testing emulator.
71
+ *
72
+ * Combines the Storage client drivers with the rules test environment and context
73
+ * to produce a context suitable for client-side Firebase Storage tests.
74
+ */
34
75
  export declare function makeRulesTestFirebaseStorageContext(drivers: TestingFirebaseStorageDrivers, rulesTestEnvironment: RulesTestEnvironment, rulesTestContext: RulesTestContext): TestFirebaseStorageContext;
76
+ /**
77
+ * Test instance that provides both Firestore and Firebase Storage contexts via the
78
+ * `@firebase/rules-unit-testing` emulator.
79
+ *
80
+ * Lazily initializes contexts on first access using {@link cachedGetter}.
81
+ * Used as the instance type for {@link RulesUnitTestFirebaseTestingContextFixture}.
82
+ */
35
83
  export declare class RulesUnitTestTestFirebaseInstance implements TestFirebaseInstance, TestFirebaseStorageInstance {
36
84
  readonly drivers: TestingFirebaseDrivers;
37
85
  readonly rulesTestEnvironment: RulesTestEnvironment;
@@ -44,6 +92,12 @@ export declare class RulesUnitTestTestFirebaseInstance implements TestFirebaseIn
44
92
  get firestore(): Firestore;
45
93
  get storage(): FirebaseStorage;
46
94
  }
95
+ /**
96
+ * Concrete {@link TestFirebaseContextFixture} for client-side rules unit tests.
97
+ *
98
+ * Manages the lifecycle of a {@link RulesUnitTestTestFirebaseInstance}, handling
99
+ * setup and teardown of the emulator environment between test suites.
100
+ */
47
101
  export declare class RulesUnitTestFirebaseTestingContextFixture extends TestFirebaseContextFixture<RulesUnitTestTestFirebaseInstance> {
48
102
  }
49
103
  /**
@@ -52,4 +106,10 @@ export declare class RulesUnitTestFirebaseTestingContextFixture extends TestFire
52
106
  * This can be used to easily build a testing context that sets up RulesTestEnvironment for tests that sets itself up and tears itself down.
53
107
  */
54
108
  export declare const firebaseRulesUnitTestBuilder: import("@dereekb/util/test").TestContextBuilderFunction<RulesUnitTestTestFirebaseInstance, RulesUnitTestFirebaseTestingContextFixture, RulesUnitTestingConfig>;
109
+ /**
110
+ * Registers `beforeAll`/`afterAll` hooks to suppress verbose Firestore log output during tests.
111
+ *
112
+ * Sets the log level to `'error'` before tests and restores it to `'warn'` afterward.
113
+ * Call this at the top level of a `describe` block to reduce test noise.
114
+ */
55
115
  export declare function changeFirestoreLogLevelBeforeAndAfterTests(): void;
@@ -4,6 +4,13 @@ import { type TestFirestoreContext } from './firestore/firestore';
4
4
  import { type TestFirestoreInstance } from './firestore/firestore.instance';
5
5
  import { type TestFirebaseStorageContext } from './storage/storage';
6
6
  import { type TestFirebaseStorageInstance } from './storage/storage.instance';
7
+ /**
8
+ * Combined test instance that provides access to both Firestore and Firebase Storage test contexts.
9
+ *
10
+ * Use this when your tests need to interact with both Firestore documents and storage files
11
+ * within the same test scenario. Implements both {@link TestFirestoreInstance} and
12
+ * {@link TestFirebaseStorageInstance} so it can be used wherever either is expected.
13
+ */
7
14
  export declare class TestFirebaseInstance implements TestFirestoreInstance, TestFirebaseStorageInstance {
8
15
  readonly firestoreContext: TestFirestoreContext;
9
16
  readonly storageContext: TestFirebaseStorageContext;
@@ -11,12 +18,26 @@ export declare class TestFirebaseInstance implements TestFirestoreInstance, Test
11
18
  get firestore(): Firestore;
12
19
  get storage(): FirebaseStorage;
13
20
  }
21
+ /**
22
+ * Test fixture that manages the lifecycle of a {@link TestFirebaseInstance}, providing
23
+ * convenient access to both Firestore and Storage test contexts.
24
+ *
25
+ * Extends {@link AbstractTestContextFixture} to handle setup/teardown of the combined
26
+ * Firebase test environment. Use this as the base fixture when writing tests that
27
+ * exercise both Firestore and Storage functionality together.
28
+ */
14
29
  export declare class TestFirebaseContextFixture<F extends TestFirebaseInstance = TestFirebaseInstance> extends AbstractTestContextFixture<F> {
15
30
  get firestore(): Firestore;
16
31
  get firestoreContext(): TestFirestoreContext;
17
32
  get storage(): FirebaseStorage;
18
33
  get storageContext(): TestFirebaseStorageContext;
19
34
  }
35
+ /**
36
+ * Factory type for creating {@link TestFirebaseContextFixture} instances in test suites.
37
+ *
38
+ * Pass this to test utility functions that need to set up a combined Firestore + Storage
39
+ * test environment.
40
+ */
20
41
  export type TestFirebaseContextFactory = TestContextFactory<TestFirebaseContextFixture>;
21
42
  /**
22
43
  * @deprecated Use TestFirebaseContextFactory instead.
@@ -15,6 +15,22 @@ export interface TestingFirestoreAccessorDriver extends FirestoreAccessorDriver
15
15
  */
16
16
  initWithCollectionNames(collectionNames: string[]): Map<string, string>;
17
17
  }
18
+ /**
19
+ * Creates a {@link TestingFirestoreAccessorDriver} that wraps the given driver with collection name fuzzing.
20
+ *
21
+ * Each collection/subcollection/collectionGroup path is replaced with a unique fuzzed name
22
+ * (incorporating a timestamp and random component) so that parallel tests never read or write
23
+ * each other's documents. The mapping from original to fuzzed names is retrievable via
24
+ * {@link TestingFirestoreAccessorDriver.getFuzzedCollectionsNameMap}.
25
+ *
26
+ * @example
27
+ * ```ts
28
+ * const testDriver = makeTestingFirestoreAccesorDriver(productionDriver);
29
+ * // "mockItems" -> "1678901234_42_mockItems_1"
30
+ * ```
31
+ *
32
+ * @param driver - The base driver to wrap with fuzzing behavior.
33
+ */
18
34
  export declare function makeTestingFirestoreAccesorDriver(driver: FirestoreAccessorDriver): TestingFirestoreAccessorDriver;
19
35
  /**
20
36
  * Drivers used for testing. Provides additional functionality for controlling collection access to prevent cross-test contamination.
@@ -30,9 +46,33 @@ export interface TestingFirestoreDrivers extends FirestoreDrivers {
30
46
  * @returns
31
47
  */
32
48
  export declare function makeTestingFirestoreDrivers(drivers: FirestoreDrivers): TestingFirestoreDrivers;
49
+ /**
50
+ * Extension applied to a {@link FirestoreContext} to expose the testing-specific drivers.
51
+ *
52
+ * This is mixed into the base context type via {@link TestFirestoreContext} so that
53
+ * test code can access the fuzzed driver and its collection name map.
54
+ */
33
55
  export interface TestingFirestoreContextExtension {
34
56
  drivers: TestingFirestoreDrivers;
35
57
  }
58
+ /**
59
+ * A {@link FirestoreContext} augmented with {@link TestingFirestoreContextExtension},
60
+ * giving tests access to fuzzed collection drivers for isolation.
61
+ */
36
62
  export type TestFirestoreContext<C = FirestoreContext> = C & TestingFirestoreContextExtension;
63
+ /**
64
+ * Function that clears a single Firestore collection used during testing.
65
+ *
66
+ * @param collectionName - The original (un-fuzzed) collection name.
67
+ * @param realCollectionName - The fuzzed collection name that actually exists in Firestore.
68
+ */
37
69
  export type ClearTestFirestoreCollectionFunction = (collectionName: string, realCollectionName: string) => Promise<void>;
70
+ /**
71
+ * Iterates over every fuzzed collection in the given test context and invokes the
72
+ * provided cleanup function for each one. Use this in `afterAll`/`afterEach` hooks
73
+ * to remove test data and avoid cross-test contamination.
74
+ *
75
+ * @param context - The test context whose fuzzed collections should be cleared.
76
+ * @param clearCollection - Callback that performs the actual deletion for a single collection.
77
+ */
38
78
  export declare function clearTestFirestoreContextCollections(context: TestFirestoreContext, clearCollection: ClearTestFirestoreCollectionFunction): Promise<void>;
@@ -1,15 +1,31 @@
1
1
  import { AbstractTestContextFixture, type TestContextFactory } from '@dereekb/util/test';
2
2
  import { type Firestore } from '@dereekb/firebase';
3
3
  import { type TestFirestoreContext } from './firestore';
4
+ /**
5
+ * Test instance that wraps a {@link TestFirestoreContext} and provides convenient access
6
+ * to the underlying Firestore instance.
7
+ *
8
+ * Acts as the core building block for Firestore-only test scenarios. The context includes
9
+ * fuzzed collection names to ensure test isolation.
10
+ */
4
11
  export declare class TestFirestoreInstance {
5
12
  readonly firestoreContext: TestFirestoreContext;
6
13
  constructor(firestoreContext: TestFirestoreContext);
7
14
  get firestore(): Firestore;
8
15
  }
16
+ /**
17
+ * Test fixture that manages the lifecycle of a {@link TestFirestoreInstance}.
18
+ *
19
+ * Extends {@link AbstractTestContextFixture} to handle setup/teardown of the Firestore
20
+ * test environment, including fuzzed collection drivers for test isolation.
21
+ */
9
22
  export declare class TestFirestoreContextFixture<F extends TestFirestoreInstance = TestFirestoreInstance> extends AbstractTestContextFixture<F> {
10
23
  get firestore(): Firestore;
11
24
  get firestoreContext(): TestFirestoreContext;
12
25
  }
26
+ /**
27
+ * Factory type for creating {@link TestFirestoreContextFixture} instances in test suites.
28
+ */
13
29
  export type TestFirestoreContextFactory = TestContextFactory<TestFirestoreContextFixture>;
14
30
  /**
15
31
  * @deprecated Use TestFirestoreContextFactory instead.
@@ -2,19 +2,56 @@ import { type Transaction, type DocumentReference, type WriteBatch, type Firesto
2
2
  import { type MockItemCollectionFixture } from '../mock';
3
3
  import { type Getter } from '@dereekb/util';
4
4
  /**
5
- * Describes accessor driver tests, using a MockItemCollectionFixture.
5
+ * Registers a shared test suite that validates {@link FirestoreAccessorDriver} behavior
6
+ * (CRUD operations, transactions, write batches, subcollections, and collection groups)
7
+ * against a live or emulated Firestore instance.
6
8
  *
7
- * @param f
9
+ * Call this once per driver implementation (e.g., client SDK, Admin SDK) to verify
10
+ * that the driver conforms to the expected Firestore accessor contract.
11
+ *
12
+ * @param f - Fixture providing the mock item collections and parent context for the tests.
8
13
  */
9
14
  export declare function describeFirestoreAccessorDriverTests(f: MockItemCollectionFixture): void;
15
+ /**
16
+ * Configuration object for {@link describeFirestoreDocumentAccessorTests}.
17
+ *
18
+ * Supplies the test suite with the context, document factories, test data, and
19
+ * assertion helpers needed to validate document-level accessor operations
20
+ * (get, set, update, create, delete, stream, transactions, write batches).
21
+ */
10
22
  export interface DescribeAccessorTests<T> {
23
+ /** The Firestore context used for running transactions and creating batches. */
11
24
  context: FirestoreContext;
25
+ /** Returns the document under test. Called fresh in each `beforeEach`. */
12
26
  firestoreDocument: Getter<FirestoreDocument<T>>;
27
+ /**
28
+ * Returns partial data for the first of two sequential updates within a transaction.
29
+ * Used to verify that non-overlapping fields survive a second update.
30
+ */
13
31
  dataForFirstOfTwoUpdates: () => Partial<T>;
32
+ /** Returns partial data used for standard update/set assertions. */
14
33
  dataForUpdate: () => Partial<T>;
34
+ /**
35
+ * Optional predicate that checks whether fields from the first update
36
+ * are still present after the second update was applied. When provided,
37
+ * the multi-update transaction test will assert this returns `true`.
38
+ */
15
39
  hasRemainingDataFromFirstOfTwoUpdate?: (data: T) => boolean;
40
+ /** Predicate that returns `true` when the document's data reflects a successful update. */
16
41
  hasDataFromUpdate: (data: T) => boolean;
42
+ /** Loads the document within a transaction context for transaction-based tests. */
17
43
  loadDocumentForTransaction: (transaction: Transaction, ref?: DocumentReference<T>) => AbstractFirestoreDocument<T, any>;
44
+ /** Loads the document within a write batch context for batch-based tests. */
18
45
  loadDocumentForWriteBatch: (writeBatch: WriteBatch, ref?: DocumentReference<T>) => FirestoreDocument<T, any>;
19
46
  }
47
+ /**
48
+ * Registers a shared test suite that validates document-level accessor operations
49
+ * (get, set, update, create, delete, stream, transactions, and write batches)
50
+ * for a single Firestore document type.
51
+ *
52
+ * This is called internally by {@link describeFirestoreAccessorDriverTests} for each
53
+ * mock document type, but can also be invoked directly when testing custom document types.
54
+ *
55
+ * @param init - Factory that returns a fresh {@link DescribeAccessorTests} config for each test.
56
+ */
20
57
  export declare function describeFirestoreDocumentAccessorTests<T>(init: () => DescribeAccessorTests<T>): void;
@@ -1,7 +1,13 @@
1
1
  import { type MockItemCollectionFixture } from '../mock';
2
2
  /**
3
- * Describes utility driver tests, using a MockItemCollectionFixture.
3
+ * Registers a shared test suite that validates Firestore document utility functions
4
+ * (snapshot helpers, document loaders, data extraction, reactive streams, and caching)
5
+ * against a live or emulated Firestore instance.
4
6
  *
5
- * @param f
7
+ * Covers functions from `document.utility.ts`, `document.rxjs.ts`, and `query.util.ts`
8
+ * such as {@link getDocumentSnapshots}, {@link loadDocumentsForKeys},
9
+ * {@link latestSnapshotsFromDocuments}, {@link streamDocumentSnapshotsData}, and more.
10
+ *
11
+ * @param f - Fixture providing the mock item collection and parent context for the tests.
6
12
  */
7
13
  export declare function describeFirestoreDocumentUtilityTests(f: MockItemCollectionFixture): void;
@@ -1,7 +1,12 @@
1
1
  import { type MockItemCollectionFixture } from '../mock';
2
2
  /**
3
- * Describes accessor driver tests, using a MockItemCollectionFixture.
3
+ * Registers a shared test suite that validates Firestore pagination and iteration behavior
4
+ * (page-based queries, snapshot/item accumulators, and loading-state integration)
5
+ * against a live or emulated Firestore instance.
4
6
  *
5
- * @param f
7
+ * Tests cover {@link FirestoreItemPageIterationFactoryFunction}, {@link firebaseQuerySnapshotAccumulator},
8
+ * {@link firebaseQueryItemAccumulator}, and related RxJS accumulator utilities.
9
+ *
10
+ * @param f - Fixture providing the mock item collection and parent context for the tests.
6
11
  */
7
12
  export declare function describeFirestoreIterationTests(f: MockItemCollectionFixture): void;
@@ -3,6 +3,12 @@ import { AbstractWrappedFixtureWithInstance, type TestWrappedContextFactoryBuild
3
3
  import { type TestFirestoreContextFixture } from '../firestore/firestore.instance';
4
4
  import { type MockItemFirestoreCollection, type MockItem } from './mock.item';
5
5
  import { type MockItemCollections } from './mock.item.service';
6
+ /**
7
+ * Provides direct access to all mock item Firestore collections for a single test run.
8
+ *
9
+ * Created by {@link MockItemCollectionFixture} and exposes convenience getters for each
10
+ * mock collection/collection-group. Delegates collection creation to {@link makeMockItemCollections}.
11
+ */
6
12
  export declare class MockItemCollectionFixtureInstance {
7
13
  readonly fixture: MockItemCollectionFixture;
8
14
  readonly collections: MockItemCollections;
@@ -23,10 +29,32 @@ export declare class MockItemCollectionFixtureInstance {
23
29
  constructor(fixture: MockItemCollectionFixture);
24
30
  }
25
31
  /**
26
- * Used to expose a CollectionReference to MockItem for simple tests.
32
+ * Test fixture that wraps a {@link TestFirestoreContextFixture} and provides access to
33
+ * all mock item collections via {@link MockItemCollectionFixtureInstance}.
34
+ *
35
+ * Use {@link testWithMockItemCollectionFixture} to create a factory builder for this fixture.
27
36
  */
28
37
  export declare class MockItemCollectionFixture extends AbstractWrappedFixtureWithInstance<MockItemCollectionFixtureInstance, TestFirestoreContextFixture> {
29
38
  }
39
+ /**
40
+ * Configuration options for {@link testWithMockItemCollectionFixture}.
41
+ *
42
+ * Currently empty; reserved for future setup/teardown customization.
43
+ */
30
44
  export interface MockItemCollectionFirebaseContextConfig {
31
45
  }
46
+ /**
47
+ * Creates a {@link TestWrappedContextFactoryBuilder} that sets up a {@link MockItemCollectionFixture}
48
+ * around a parent {@link TestFirestoreContextFixture}.
49
+ *
50
+ * Compose with a Firebase test context factory to get a fully wired test environment:
51
+ *
52
+ * @example
53
+ * ```ts
54
+ * const f = testWithMockItemCollectionFixture()(authorizedFirebaseFactory);
55
+ * describe('my test', () => f.with((instance) => {
56
+ * it('should work', () => { ... });
57
+ * }));
58
+ * ```
59
+ */
32
60
  export declare function testWithMockItemCollectionFixture(config?: MockItemCollectionFirebaseContextConfig): TestWrappedContextFactoryBuilder<MockItemCollectionFixture, TestFirestoreContextFixture>;