@dereekb/firebase-server 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 (166) hide show
  1. package/index.cjs.js +7506 -1884
  2. package/index.esm.js +7505 -1890
  3. package/mailgun/index.cjs.js +333 -31
  4. package/mailgun/index.esm.js +333 -31
  5. package/mailgun/package.json +8 -8
  6. package/mailgun/src/lib/auth.mailgun.d.ts +22 -3
  7. package/model/index.cjs.js +11334 -3830
  8. package/model/index.esm.js +11338 -3834
  9. package/model/package.json +10 -10
  10. package/model/src/lib/mailgun/notification.send.service.mailgun.d.ts +27 -1
  11. package/model/src/lib/notification/notification.action.init.service.d.ts +93 -1
  12. package/model/src/lib/notification/notification.action.service.d.ts +151 -2
  13. package/model/src/lib/notification/notification.config.d.ts +19 -7
  14. package/model/src/lib/notification/notification.config.service.d.ts +44 -6
  15. package/model/src/lib/notification/notification.create.run.d.ts +33 -5
  16. package/model/src/lib/notification/notification.error.d.ts +63 -0
  17. package/model/src/lib/notification/notification.module.d.ts +11 -0
  18. package/model/src/lib/notification/notification.send.d.ts +8 -1
  19. package/model/src/lib/notification/notification.send.service.d.ts +7 -1
  20. package/model/src/lib/notification/notification.send.service.notificationsummary.d.ts +32 -2
  21. package/model/src/lib/notification/notification.send.service.text.d.ts +11 -3
  22. package/model/src/lib/notification/notification.task.service.d.ts +13 -1
  23. package/model/src/lib/notification/notification.task.service.handler.d.ts +27 -3
  24. package/model/src/lib/notification/notification.task.service.util.d.ts +16 -4
  25. package/model/src/lib/notification/notification.task.subtask.handler.d.ts +31 -1
  26. package/model/src/lib/notification/notification.util.d.ts +70 -0
  27. package/model/src/lib/storagefile/storagefile.action.init.service.d.ts +62 -1
  28. package/model/src/lib/storagefile/storagefile.action.server.d.ts +124 -2
  29. package/model/src/lib/storagefile/storagefile.error.d.ts +44 -0
  30. package/model/src/lib/storagefile/storagefile.module.d.ts +11 -0
  31. package/model/src/lib/storagefile/storagefile.task.service.handler.d.ts +4 -1
  32. package/model/src/lib/storagefile/storagefile.upload.service.d.ts +13 -1
  33. package/model/src/lib/storagefile/storagefile.upload.service.initializer.d.ts +43 -1
  34. package/model/src/lib/storagefile/storagefile.util.d.ts +8 -0
  35. package/oidc/index.cjs.default.js +1 -0
  36. package/oidc/index.cjs.js +5607 -0
  37. package/oidc/index.cjs.mjs +2 -0
  38. package/oidc/index.d.ts +1 -0
  39. package/oidc/index.esm.js +5560 -0
  40. package/oidc/package.json +26 -0
  41. package/oidc/src/index.d.ts +1 -0
  42. package/oidc/src/lib/controller/index.d.ts +3 -0
  43. package/oidc/src/lib/controller/oidc.interaction.controller.d.ts +54 -0
  44. package/oidc/src/lib/controller/oidc.provider.controller.d.ts +18 -0
  45. package/oidc/src/lib/controller/oidc.wellknown.controller.d.ts +36 -0
  46. package/oidc/src/lib/index.d.ts +6 -0
  47. package/oidc/src/lib/middleware/index.d.ts +3 -0
  48. package/oidc/src/lib/middleware/oauth-auth.decorator.d.ts +14 -0
  49. package/oidc/src/lib/middleware/oauth-auth.middleware.d.ts +21 -0
  50. package/oidc/src/lib/middleware/oauth-auth.module.d.ts +50 -0
  51. package/oidc/src/lib/model/index.d.ts +3 -0
  52. package/oidc/src/lib/model/jwks/index.d.ts +3 -0
  53. package/oidc/src/lib/model/jwks/jwks.d.ts +107 -0
  54. package/oidc/src/lib/model/jwks/jwks.id.d.ts +9 -0
  55. package/oidc/src/lib/model/jwks/jwks.query.d.ts +18 -0
  56. package/oidc/src/lib/model/model.d.ts +12 -0
  57. package/oidc/src/lib/model/oidc/index.d.ts +2 -0
  58. package/oidc/src/lib/model/oidc/oidcmodel.action.server.d.ts +62 -0
  59. package/oidc/src/lib/model/oidc/oidcmodel.module.d.ts +23 -0
  60. package/oidc/src/lib/oidc.config.d.ts +175 -0
  61. package/oidc/src/lib/oidc.module.d.ts +100 -0
  62. package/oidc/src/lib/service/index.d.ts +10 -0
  63. package/oidc/src/lib/service/oidc.account.d.ts +36 -0
  64. package/oidc/src/lib/service/oidc.account.service.d.ts +104 -0
  65. package/oidc/src/lib/service/oidc.adapter.service.d.ts +20 -0
  66. package/oidc/src/lib/service/oidc.auth.d.ts +26 -0
  67. package/oidc/src/lib/service/oidc.client.service.d.ts +57 -0
  68. package/oidc/src/lib/service/oidc.config.service.d.ts +100 -0
  69. package/oidc/src/lib/service/oidc.encryption.service.d.ts +53 -0
  70. package/oidc/src/lib/service/oidc.interaction.service.d.ts +44 -0
  71. package/oidc/src/lib/service/oidc.jwks.service.d.ts +105 -0
  72. package/oidc/src/lib/service/oidc.service.d.ts +55 -0
  73. package/package.json +21 -14
  74. package/src/lib/auth/auth.context.d.ts +22 -2
  75. package/src/lib/auth/auth.service.d.ts +5 -0
  76. package/src/lib/auth/auth.service.error.d.ts +2 -1
  77. package/src/lib/auth/auth.util.d.ts +15 -3
  78. package/src/lib/env/env.config.d.ts +42 -0
  79. package/src/lib/env/env.service.d.ts +17 -0
  80. package/src/lib/env/index.d.ts +1 -0
  81. package/src/lib/firestore/array.d.ts +11 -3
  82. package/src/lib/firestore/driver.accessor.batch.d.ts +27 -4
  83. package/src/lib/firestore/driver.accessor.d.ts +43 -0
  84. package/src/lib/firestore/driver.accessor.default.d.ts +20 -0
  85. package/src/lib/firestore/driver.accessor.transaction.d.ts +28 -4
  86. package/src/lib/firestore/driver.d.ts +14 -0
  87. package/src/lib/firestore/driver.query.d.ts +25 -0
  88. package/src/lib/firestore/increment.d.ts +13 -3
  89. package/src/lib/firestore/snapshot/index.d.ts +1 -1
  90. package/src/lib/firestore/snapshot/{snapshot.field.d.ts → snapshot.field.encrypt.d.ts} +13 -27
  91. package/src/lib/function/assert.d.ts +32 -16
  92. package/src/lib/function/context.d.ts +26 -0
  93. package/src/lib/function/error.auth.d.ts +15 -0
  94. package/src/lib/function/error.d.ts +68 -4
  95. package/src/lib/nest/app.d.ts +53 -9
  96. package/src/lib/nest/app.module.d.ts +90 -0
  97. package/src/lib/nest/auth/auth.module.d.ts +30 -4
  98. package/src/lib/nest/auth/auth.util.d.ts +38 -0
  99. package/src/lib/nest/controller/auth.context.server.d.ts +27 -0
  100. package/src/lib/nest/controller/index.d.ts +1 -0
  101. package/src/lib/nest/development/development.app.function.d.ts +45 -0
  102. package/src/lib/nest/development/development.assert.function.d.ts +19 -1
  103. package/src/lib/nest/development/development.function.d.ts +42 -3
  104. package/src/lib/nest/development/development.schedule.function.d.ts +29 -0
  105. package/src/lib/nest/development/development.schedule.function.error.d.ts +21 -0
  106. package/src/lib/nest/env/env.service.d.ts +9 -0
  107. package/src/lib/nest/env/env.util.d.ts +16 -0
  108. package/src/lib/nest/firebase/firebase.module.d.ts +13 -1
  109. package/src/lib/nest/firestore/firestore.module.d.ts +24 -8
  110. package/src/lib/nest/function/call.d.ts +75 -6
  111. package/src/lib/nest/function/context.d.ts +85 -2
  112. package/src/lib/nest/function/nest.d.ts +46 -0
  113. package/src/lib/nest/function/schedule.d.ts +49 -0
  114. package/src/lib/nest/function/v2/blocking.d.ts +92 -8
  115. package/src/lib/nest/function/v2/call.d.ts +38 -8
  116. package/src/lib/nest/function/v2/event.d.ts +67 -4
  117. package/src/lib/nest/function/v2/schedule.d.ts +36 -5
  118. package/src/lib/nest/index.d.ts +3 -0
  119. package/src/lib/nest/middleware/appcheck.d.ts +5 -0
  120. package/src/lib/nest/middleware/appcheck.middleware.d.ts +44 -14
  121. package/src/lib/nest/middleware/appcheck.module.d.ts +10 -1
  122. package/src/lib/nest/middleware/globalprefix.d.ts +31 -3
  123. package/src/lib/nest/middleware/index.d.ts +2 -1
  124. package/src/lib/nest/middleware/rawbody.middleware.d.ts +6 -0
  125. package/src/lib/nest/model/call.model.function.d.ts +69 -3
  126. package/src/lib/nest/model/create.model.function.d.ts +66 -0
  127. package/src/lib/nest/model/crud.assert.function.d.ts +27 -1
  128. package/src/lib/nest/model/delete.model.function.d.ts +55 -0
  129. package/src/lib/nest/model/permission.error.d.ts +15 -0
  130. package/src/lib/nest/model/read.model.function.d.ts +57 -0
  131. package/src/lib/nest/model/specifier.function.d.ts +58 -1
  132. package/src/lib/nest/model/update.model.function.d.ts +58 -0
  133. package/src/lib/nest/nest.provider.d.ts +24 -11
  134. package/src/lib/nest/nest.provider.server.d.ts +12 -0
  135. package/src/lib/nest/storage/storage.module.d.ts +30 -4
  136. package/src/lib/storage/driver.accessor.d.ts +33 -0
  137. package/src/lib/storage/driver.d.ts +14 -0
  138. package/src/lib/storage/storage.d.ts +11 -4
  139. package/src/lib/storage/storage.service.d.ts +10 -1
  140. package/src/lib/type.d.ts +7 -2
  141. package/test/index.cjs.js +4072 -757
  142. package/test/index.esm.js +4073 -761
  143. package/test/package.json +10 -10
  144. package/test/src/lib/firebase/firebase.admin.auth.d.ts +82 -1
  145. package/test/src/lib/firebase/firebase.admin.collection.d.ts +55 -3
  146. package/test/src/lib/firebase/firebase.admin.d.ts +64 -0
  147. package/test/src/lib/firebase/firebase.admin.function.d.ts +84 -0
  148. package/test/src/lib/firebase/firebase.admin.nest.d.ts +125 -17
  149. package/test/src/lib/firebase/firebase.admin.nest.function.callable.context.d.ts +44 -0
  150. package/test/src/lib/firebase/firebase.admin.nest.function.cloud.context.d.ts +41 -0
  151. package/test/src/lib/firebase/firebase.admin.nest.function.d.ts +98 -0
  152. package/test/src/lib/firebase/firebase.admin.test.server.d.ts +26 -0
  153. package/test/src/lib/firebase/firebase.d.ts +57 -2
  154. package/test/src/lib/firebase/firebase.function.d.ts +138 -0
  155. package/test/src/lib/firestore/firestore.admin.d.ts +6 -0
  156. package/test/src/lib/firestore/firestore.d.ts +30 -0
  157. package/test/src/lib/storage/storage.admin.d.ts +9 -3
  158. package/test/src/lib/storage/storage.d.ts +30 -0
  159. package/zoho/index.cjs.js +406 -73
  160. package/zoho/index.esm.js +406 -73
  161. package/zoho/package.json +8 -8
  162. package/zoho/src/lib/zoho.accounts.firebase.d.ts +13 -2
  163. package/zoho/src/lib/zoho.accounts.firebase.system.d.ts +29 -6
  164. package/index.cjs.js.map +0 -1
  165. package/index.esm.js.map +0 -1
  166. /package/src/lib/nest/middleware/{webhook.d.ts → webhook.module.d.ts} +0 -0
@@ -1,30 +1,80 @@
1
1
  import { AbstractChildTestContextFixture, type BuildTestsWithContextFunction, type TestContextFactory, type TestContextFixture } from '@dereekb/util/test';
2
2
  import { AbstractFirebaseAdminTestContextInstanceChild, type FirebaseAdminTestContextInstance } from './firebase.admin';
3
- import { type Abstract, type INestApplicationContext, type Provider, type Type } from '@nestjs/common';
3
+ import { INestApplication, type Abstract, type INestApplicationContext, type Provider, type Type } from '@nestjs/common';
4
4
  import { type StorageBucketId } from '@dereekb/firebase';
5
- import { type NestAppPromiseGetter } from '@dereekb/firebase-server';
5
+ import { type FirebaseServerEnvironmentConfig, type NestAppPromiseGetter, type NestServerInstanceConfig } from '@dereekb/firebase-server';
6
6
  import { type TestingModule } from '@nestjs/testing';
7
- import { type ArrayOrValue, type ClassType, type Getter } from '@dereekb/util';
8
- import { type ServerEnvironmentConfig } from '@dereekb/nestjs';
7
+ import { type ArrayOrValue, type ClassType, type Getter, Maybe } from '@dereekb/util';
8
+ /**
9
+ * NestJS injection token used to provide the {@link NestServerInstanceConfig} to the test's
10
+ * {@link TestingModule}. The instance is injected during nest application creation so that
11
+ * production configuration (global prefix, webhooks, etc.) can be applied in tests.
12
+ */
13
+ export declare const FIREBASE_ADMIN_NEST_TEST_SERVER_INSTANCE_CONFIG_TOKEN = "FIREBASE_ADMIN_NEST_TEST_SERVER_INSTANCE_CONFIG_TOKEN";
14
+ /**
15
+ * Extends the Firebase Admin test context with NestJS {@link TestingModule} access.
16
+ *
17
+ * Provides the compiled NestJS module, a way to resolve providers via `get()`,
18
+ * and helpers for creating / initializing a full {@link INestApplication} for
19
+ * integration tests that need HTTP or middleware support.
20
+ */
9
21
  export interface FirebaseAdminNestTestContext {
10
22
  readonly nest: TestingModule;
11
23
  readonly nestAppPromiseGetter: NestAppPromiseGetter;
24
+ /**
25
+ * Returns the configured nest application singleton for this context.
26
+ *
27
+ * If it does not exist, calls `createNewNestApplication` and returns the result.
28
+ */
29
+ loadInitializedNestApplication(): Promise<INestApplication>;
30
+ /**
31
+ * Creates a new blank nest application.
32
+ */
33
+ createNewNestApplication(): INestApplication;
12
34
  get<TInput = any, TResult = TInput>(typeOrToken: Type<TInput> | Abstract<TInput> | string | symbol, options?: {
13
35
  strict: boolean;
14
36
  }): TResult;
15
37
  }
38
+ /**
39
+ * Utility intersection type combining {@link FirebaseAdminNestTestContext} with a
40
+ * {@link TestContextFixture} parameterized by the parent instance type.
41
+ *
42
+ * Useful as a type constraint when a helper needs both NestJS context methods and
43
+ * fixture lifecycle access.
44
+ */
16
45
  export type FirebaseAdminNestTestContextFixtureType<PI extends FirebaseAdminTestContextInstance> = FirebaseAdminNestTestContext & TestContextFixture<PI>;
46
+ /**
47
+ * Child fixture that wraps a {@link FirebaseAdminNestTestContextInstance} and forwards
48
+ * all {@link FirebaseAdminNestTestContext} members to the underlying instance.
49
+ *
50
+ * Created by {@link firebaseAdminNestContextWithFixture} during test setup. Tests receive
51
+ * this fixture and use it to access the NestJS {@link TestingModule}, resolve providers,
52
+ * and create application instances.
53
+ */
17
54
  export declare class FirebaseAdminNestTestContextFixture<PI extends FirebaseAdminTestContextInstance = FirebaseAdminTestContextInstance, PF extends TestContextFixture<PI> = TestContextFixture<PI>, I extends FirebaseAdminNestTestContextInstance<PI> = FirebaseAdminNestTestContextInstance<PI>> extends AbstractChildTestContextFixture<I, PF> implements FirebaseAdminNestTestContext {
18
55
  get nest(): TestingModule;
19
56
  get nestAppPromiseGetter(): Getter<Promise<INestApplicationContext>>;
57
+ createNewNestApplication(): INestApplication;
58
+ loadInitializedNestApplication(): Promise<INestApplication>;
20
59
  get<TInput = any, TResult = TInput>(typeOrToken: Type<TInput> | Abstract<TInput> | string | symbol, options?: {
21
60
  strict: boolean;
22
61
  }): TResult;
23
62
  }
63
+ /**
64
+ * Concrete instance that holds the compiled NestJS {@link TestingModule} and provides
65
+ * methods for creating and initializing a full {@link INestApplication}.
66
+ *
67
+ * Applies production-like configuration (global route prefix, server instance hooks)
68
+ * from {@link FIREBASE_ADMIN_NEST_TEST_SERVER_INSTANCE_CONFIG_TOKEN} when creating applications,
69
+ * ensuring test applications mirror production setup.
70
+ */
24
71
  export declare class FirebaseAdminNestTestContextInstance<PI extends FirebaseAdminTestContextInstance = FirebaseAdminTestContextInstance> extends AbstractFirebaseAdminTestContextInstanceChild<PI> implements FirebaseAdminNestTestContext {
25
72
  readonly nest: TestingModule;
26
73
  readonly nestAppPromiseGetter: Getter<Promise<INestApplicationContext>>;
74
+ readonly _loadInitializedNestApplication: import("@dereekb/util").CachedFactoryWithInput<Promise<INestApplication<any>>, unknown>;
27
75
  constructor(parent: PI, nest: TestingModule);
76
+ createNewNestApplication(): INestApplication;
77
+ loadInitializedNestApplication(): Promise<INestApplication>;
28
78
  get<TInput = any, TResult = TInput>(typeOrToken: Type<TInput> | Abstract<TInput> | string | symbol, options?: {
29
79
  strict?: boolean | undefined;
30
80
  each?: undefined | false;
@@ -34,53 +84,111 @@ export interface FirebaseAdminNestTestConfig<PI extends FirebaseAdminTestContext
34
84
  /**
35
85
  * Creates a new fixture.
36
86
  */
37
- makeFixture?: (f: PF) => C;
87
+ readonly makeFixture?: (f: PF) => C;
38
88
  /**
39
89
  * Root module to import.
40
90
  */
41
- nestModules: ArrayOrValue<ClassType>;
91
+ readonly nestModules: ArrayOrValue<ClassType>;
92
+ /**
93
+ * Optional `NestServerInstanceConfig` from the production app setup.
94
+ *
95
+ * When provided, shared configuration (global prefix, webhooks, AppCheck, storage, etc.)
96
+ * is derived from this config via `buildNestServerRootModule`, ensuring tests match production.
97
+ *
98
+ * Fields like `moduleClass` and `applicationOptions` are ignored — the test uses `nestModules` instead.
99
+ * Test-specific overrides (e.g., `injectFirebaseServerAppTokenProvider`, `envConfig`) still take precedence.
100
+ */
101
+ readonly serverInstanceConfig?: Maybe<NestServerInstanceConfig<any>>;
42
102
  /**
43
103
  * Whether or not to inject the env service provider (and serverEnvTokenProvider()) by default.
44
104
  *
45
105
  * If false will affect the default envConfig value.
46
106
  */
47
- injectServerEnvServiceProvider?: boolean;
107
+ readonly injectServerEnvServiceProvider?: boolean;
48
108
  /**
49
- * (Optional) ServerEnvironmentServiceConfig. Overrides the default which sets production=false.
109
+ * (Optional) FirebaseServerEnvironmentConfig. Overrides the default which sets production=false.
50
110
  *
51
111
  * If injectFirebaseServerEnvServiceProvider is false then this requires a value to be provided in order to be injected.
52
112
  */
53
- envConfig?: ServerEnvironmentConfig;
113
+ readonly envConfig?: FirebaseServerEnvironmentConfig;
54
114
  /**
55
115
  * Whether or not to inject the firebase server provider (firebaseServerAppTokenProvider()).
56
116
  *
57
117
  * This makes FIREBASE_APP_TOKEN available globally and provides the app configured for this test.
58
118
  */
59
- injectFirebaseServerAppTokenProvider?: boolean;
119
+ readonly injectFirebaseServerAppTokenProvider?: boolean;
60
120
  /**
61
121
  * Default storage bucket to use for tests.
62
122
  */
63
- defaultStorageBucket?: StorageBucketId;
123
+ readonly defaultStorageBucket?: StorageBucketId;
64
124
  /**
65
125
  * Whether or not to force using the storage bucket.
66
126
  */
67
- forceStorageBucket?: boolean;
127
+ readonly forceStorageBucket?: boolean;
68
128
  /**
69
129
  * Optional providers to pass to the TestingModule initialization.
70
130
  */
71
- makeProviders?: (instance: PI) => Provider<any>[];
131
+ readonly makeProviders?: (instance: PI) => Provider<any>[];
72
132
  /**
73
133
  * Creates a new instance.
74
134
  */
75
- makeInstance?: (instance: PI, nest: TestingModule) => I;
135
+ readonly makeInstance?: (instance: PI, nest: TestingModule) => I;
76
136
  /**
77
137
  * Optional function to initialize the instance.
78
138
  */
79
- initInstance?: (instance: I) => Promise<void>;
139
+ readonly initInstance?: (instance: I) => Promise<void>;
80
140
  }
141
+ /**
142
+ * Factory type that produces a {@link FirebaseAdminNestTestContextFixture} for each test suite.
143
+ * Pass a {@link BuildTestsWithContextFunction} to register tests that run against the fixture.
144
+ */
81
145
  export type FirebaseAdminNestTestContextFactory<PI extends FirebaseAdminTestContextInstance = FirebaseAdminTestContextInstance, PF extends TestContextFixture<PI> = TestContextFixture<PI>, I extends FirebaseAdminNestTestContextInstance<PI> = FirebaseAdminNestTestContextInstance<PI>, C extends FirebaseAdminNestTestContextFixture<PI, PF, I> = FirebaseAdminNestTestContextFixture<PI, PF, I>> = TestContextFactory<C>;
146
+ /**
147
+ * Composes a NestJS test context on top of an existing parent test context factory.
148
+ *
149
+ * Use this when the parent context is _not_ the default {@link firebaseAdminTestContextFactory} --
150
+ * for example, when layering NestJS onto a custom Firebase Admin function context.
151
+ * For the common case, prefer {@link firebaseAdminNestContextFactory}.
152
+ *
153
+ * @param config - NestJS module, provider, and fixture configuration.
154
+ * @param factory - The parent context factory that provides the Firebase Admin instance.
155
+ * @returns A new factory that nests the NestJS context inside the parent.
156
+ */
82
157
  export declare function firebaseAdminNestContextFixture<PI extends FirebaseAdminTestContextInstance = FirebaseAdminTestContextInstance, PF extends TestContextFixture<PI> = TestContextFixture<PI>, I extends FirebaseAdminNestTestContextInstance<PI> = FirebaseAdminNestTestContextInstance<PI>, C extends FirebaseAdminNestTestContextFixture<PI, PF, I> = FirebaseAdminNestTestContextFixture<PI, PF, I>>(config: FirebaseAdminNestTestConfig<PI, PF, I, C>, factory: TestContextFactory<PF>): FirebaseAdminNestTestContextFactory<PI, PF, I, C>;
83
- export declare class FirebaseAdminNestRootModule {
84
- }
158
+ /** @deprecated Use `FirebaseNestServerRootModule` from `@dereekb/firebase-server` instead. */
159
+ export { FirebaseNestServerRootModule as FirebaseAdminNestRootModule } from '@dereekb/firebase-server';
160
+ /**
161
+ * Wires up a NestJS {@link TestingModule} inside an already-created parent fixture.
162
+ *
163
+ * This is the core integration point: it builds the root module via {@link buildNestServerRootModule},
164
+ * compiles the testing module, creates the instance, and registers Jest lifecycle hooks
165
+ * (via {@link useTestContextFixture}) to tear down the module after tests complete.
166
+ *
167
+ * Typically called indirectly through {@link firebaseAdminNestContextFixture} or
168
+ * {@link firebaseAdminNestContextFactory}. Call directly only when composing custom fixture hierarchies.
169
+ *
170
+ * @param config - NestJS module, provider, and fixture configuration.
171
+ * @param f - The parent fixture that is already set up.
172
+ * @param buildTests - Callback that receives the child fixture and registers test cases.
173
+ */
85
174
  export declare function firebaseAdminNestContextWithFixture<PI extends FirebaseAdminTestContextInstance = FirebaseAdminTestContextInstance, PF extends TestContextFixture<PI> = TestContextFixture<PI>, I extends FirebaseAdminNestTestContextInstance<PI> = FirebaseAdminNestTestContextInstance<PI>, C extends FirebaseAdminNestTestContextFixture<PI, PF, I> = FirebaseAdminNestTestContextFixture<PI, PF, I>>(config: FirebaseAdminNestTestConfig<PI, PF, I, C>, f: PF, buildTests: BuildTestsWithContextFunction<C>): void;
175
+ /**
176
+ * Convenience factory that layers a NestJS test context on top of the default
177
+ * {@link firebaseAdminTestContextFactory}. This is the simplest way to get a
178
+ * fully configured Firebase Admin + NestJS test context.
179
+ *
180
+ * @example
181
+ * ```ts
182
+ * const f = firebaseAdminNestContextFactory({
183
+ * nestModules: [MyAppModule]
184
+ * });
185
+ *
186
+ * f((c) => {
187
+ * it('should resolve service', () => {
188
+ * const svc = c.get(MyService);
189
+ * expect(svc).toBeDefined();
190
+ * });
191
+ * });
192
+ * ```
193
+ */
86
194
  export declare function firebaseAdminNestContextFactory<I extends FirebaseAdminNestTestContextInstance<FirebaseAdminTestContextInstance> = FirebaseAdminNestTestContextInstance<FirebaseAdminTestContextInstance>>(config: FirebaseAdminNestTestConfig<FirebaseAdminTestContextInstance, TestContextFixture<FirebaseAdminTestContextInstance>, I>): FirebaseAdminNestTestContextFactory<FirebaseAdminTestContextInstance, TestContextFixture<FirebaseAdminTestContextInstance>, I>;
@@ -1,23 +1,67 @@
1
1
  import { type FirebaseAdminFunctionNestTestContext, type WrapCallableRequestForNestTestsInput } from './firebase.admin.nest.function';
2
2
  import { type WrappedCallableRequest } from './firebase.function';
3
+ /**
4
+ * Base configuration shared by both single and multiple callable request test builders.
5
+ * Provides the {@link FirebaseAdminFunctionNestTestContext} that supplies NestJS and
6
+ * Cloud Function wrapping capabilities.
7
+ */
3
8
  export interface CallableRequestTestBaseConfig {
9
+ /** The test context fixture providing NestJS module and function wrapping access. */
4
10
  readonly f: FirebaseAdminFunctionNestTestContext;
5
11
  }
12
+ /**
13
+ * Configuration for testing a single callable request function.
14
+ * The `fn` factory is wrapped and provided to the test callback as a {@link WrappedCallableRequest}.
15
+ */
6
16
  export interface CallableRequestTestSingleConfig<I, O = unknown> extends CallableRequestTestBaseConfig {
17
+ /** The callable HTTP function factory to wrap for testing. */
7
18
  readonly fn: WrapCallableRequestForNestTestsInput<I, O>;
8
19
  }
20
+ /**
21
+ * Test callback for a single callable request. Receives the wrapped callable function
22
+ * and should register test cases (e.g., `it(...)` blocks) inside the callback body.
23
+ */
9
24
  export type CallableRequestTestSingleFunction<I, O = unknown> = (fn: WrappedCallableRequest<I, O>) => void;
25
+ /**
26
+ * Map of named callable request function factories.
27
+ *
28
+ * Each key becomes a fixture property (with a {@link CallableRequestTestMultipleFixtureSuffix} suffix)
29
+ * containing the corresponding {@link WrappedCallableRequest}.
30
+ */
10
31
  export type CallableRequestTestConfigMapObject = {
11
32
  [key: string]: WrapCallableRequestForNestTestsInput<any>;
12
33
  };
34
+ /**
35
+ * Configuration for testing multiple callable request functions simultaneously.
36
+ * Each entry in `fns` is independently wrapped and exposed via a {@link CallableRequestTestMultipleFixture}.
37
+ */
13
38
  export interface CallableRequestTestMultipleConfig<I, T extends CallableRequestTestConfigMapObject> extends CallableRequestTestBaseConfig {
39
+ /** Map of named callable function factories to wrap for testing. */
14
40
  fns: T;
15
41
  }
42
+ /**
43
+ * Suffix appended to each key in a {@link CallableRequestTestConfigMapObject} when building
44
+ * the {@link CallableRequestTestMultipleFixture}. For example, a key `"createUser"` produces
45
+ * a fixture property named `"createUserWrappedFn"`.
46
+ */
16
47
  export declare const CallableRequestTestMultipleFixtureSuffix = "WrappedFn";
48
+ /**
49
+ * Mapped type that transforms a {@link CallableRequestTestConfigMapObject} into an object
50
+ * whose keys are the original keys suffixed with {@link CallableRequestTestMultipleFixtureSuffix}
51
+ * and whose values are the corresponding {@link WrappedCallableRequest} instances.
52
+ */
17
53
  export type CallableRequestTestMultipleFixture<T extends CallableRequestTestConfigMapObject> = {
18
54
  [K in keyof T as K extends string ? `${K}${typeof CallableRequestTestMultipleFixtureSuffix}` : never]: T[K] extends WrapCallableRequestForNestTestsInput<infer I, infer O> ? WrappedCallableRequest<I, O> : never;
19
55
  };
56
+ /**
57
+ * Test callback for multiple callable requests. Receives a {@link CallableRequestTestMultipleFixture}
58
+ * containing all wrapped functions, keyed by their suffixed names.
59
+ */
20
60
  export type CallableRequestTestMultipleFunction<T extends CallableRequestTestConfigMapObject> = (fn: CallableRequestTestMultipleFixture<T>) => void;
61
+ /**
62
+ * Type guard that distinguishes a {@link CallableRequestTestSingleConfig} from a
63
+ * {@link CallableRequestTestMultipleConfig} by checking for the presence of the `fn` property.
64
+ */
21
65
  export declare function isCallableRequestTestSingleConfig<I, T extends CallableRequestTestConfigMapObject>(config: CallableRequestTestSingleConfig<I> | CallableRequestTestMultipleConfig<I, T>): config is CallableRequestTestSingleConfig<I>;
22
66
  /**
23
67
  * Used to provide a test builder that exposes a WrappedCallableRequest using the input configuration.
@@ -1,23 +1,64 @@
1
1
  import { type FirebaseAdminFunctionNestTestContext, type WrapCloudFunctionForNestTestsInput } from './firebase.admin.nest.function';
2
2
  import { type WrappedCloudFunction } from './firebase.function';
3
+ /**
4
+ * Alias for {@link WrappedCloudFunction} used within cloud function test builders.
5
+ * Provides a semantic name specific to the test context.
6
+ */
3
7
  export type CloudFunctionTestWrappedCloudFunction<I extends object> = WrappedCloudFunction<I>;
8
+ /**
9
+ * Base configuration shared by both single and multiple cloud function test builders.
10
+ * Provides the {@link FirebaseAdminFunctionNestTestContext} that supplies NestJS and
11
+ * Cloud Function wrapping capabilities.
12
+ */
4
13
  export interface CloudFunctionTestBaseConfig {
14
+ /** The test context fixture providing NestJS module and function wrapping access. */
5
15
  f: FirebaseAdminFunctionNestTestContext;
6
16
  }
17
+ /**
18
+ * Configuration for testing a single cloud function (v1 schedule, blocking, or cloud event).
19
+ * The `fn` factory is wrapped and provided to the test callback as a {@link WrappedCloudFunction}.
20
+ */
7
21
  export interface CloudFunctionTestSingleConfig<I extends object> extends CloudFunctionTestBaseConfig {
22
+ /** The cloud function factory to wrap for testing. */
8
23
  fn: WrapCloudFunctionForNestTestsInput<I>;
9
24
  }
25
+ /**
26
+ * Test callback for a single cloud function. Receives the wrapped function and should
27
+ * register test cases (e.g., `it(...)` blocks) inside the callback body.
28
+ */
10
29
  export type CloudFunctionTestSingleFunction<I extends object> = (fn: WrappedCloudFunction<I>) => void;
30
+ /**
31
+ * Map of named cloud function factories. Each key becomes a fixture property
32
+ * (suffixed with `"CloudFn"`) containing the corresponding {@link WrappedCloudFunction}.
33
+ */
11
34
  export type CloudFunctionTestConfigMapObject = {
12
35
  [key: string]: WrapCloudFunctionForNestTestsInput<any>;
13
36
  };
37
+ /**
38
+ * Configuration for testing multiple cloud functions simultaneously.
39
+ * Each entry in `fns` is independently wrapped and exposed via a {@link CloudFunctionTestMultipleFixture}.
40
+ */
14
41
  export interface CloudFunctionTestMultipleConfig<I extends object, T extends CloudFunctionTestConfigMapObject> extends CloudFunctionTestBaseConfig {
42
+ /** Map of named cloud function factories to wrap for testing. */
15
43
  fns: T;
16
44
  }
45
+ /**
46
+ * Mapped type that transforms a {@link CloudFunctionTestConfigMapObject} into an object
47
+ * whose keys are the original keys suffixed with `"CloudFn"` and whose values are the
48
+ * corresponding {@link WrappedCloudFunction} instances.
49
+ */
17
50
  export type CloudFunctionTestMultipleFixture<T extends CloudFunctionTestConfigMapObject> = {
18
51
  [K in keyof T as K extends string ? `${K}CloudFn` : never]: T[K] extends WrapCloudFunctionForNestTestsInput<infer I> ? WrappedCloudFunction<I> : never;
19
52
  };
53
+ /**
54
+ * Test callback for multiple cloud functions. Receives a {@link CloudFunctionTestMultipleFixture}
55
+ * containing all wrapped functions, keyed by their suffixed names.
56
+ */
20
57
  export type CloudFunctionTestMultipleFunction<T extends CloudFunctionTestConfigMapObject> = (fn: CloudFunctionTestMultipleFixture<T>) => void;
58
+ /**
59
+ * Type guard that distinguishes a {@link CloudFunctionTestSingleConfig} from a
60
+ * {@link CloudFunctionTestMultipleConfig} by checking for the presence of the `fn` property.
61
+ */
21
62
  export declare function isCloudFunctionTestSingleConfig<I extends object, T extends CloudFunctionTestConfigMapObject>(config: CloudFunctionTestSingleConfig<I> | CloudFunctionTestMultipleConfig<I, T>): config is CloudFunctionTestSingleConfig<I>;
22
63
  /**
23
64
  * Used to provide a test builder that exposes a WrappedCloudFunction using the input configuration.
@@ -6,12 +6,57 @@ import { type NestApplicationBlockingFunctionFactory, type NestApplicationCallab
6
6
  import { type FirebaseAdminCloudFunctionWrapper, type FirebaseAdminCloudFunctionWrapperSource, type WrappedCloudFunctionV1, type WrappedCallableRequest } from './firebase.function';
7
7
  import { type CloudEvent } from 'firebase-functions/v2';
8
8
  type WrapCloudFunctionForNestTestsInputNonEventTypes = NestApplicationScheduleFunctionFactory | NestApplicationBlockingFunctionFactory<any, unknown>;
9
+ /**
10
+ * Input type for {@link wrapCloudFunctionForNestTestsGetter} that resolves to the appropriate
11
+ * NestJS application function factory based on the event type `I`.
12
+ *
13
+ * When `I` is a {@link CloudEvent}, cloud event factories are also accepted; otherwise only
14
+ * schedule and blocking function factories are valid.
15
+ */
9
16
  export type WrapCloudFunctionForNestTestsInput<I extends object> = I extends CloudEvent<any> ? NestApplicationCloudEventFunctionFactory<I> | WrapCloudFunctionForNestTestsInputNonEventTypes : WrapCloudFunctionForNestTestsInputNonEventTypes;
17
+ /**
18
+ * Creates a lazy getter that wraps a NestJS-hosted Cloud Function (v1) for testing.
19
+ *
20
+ * The returned getter defers wrapping until first invocation, so the NestJS application
21
+ * is resolved at call time rather than at setup time.
22
+ *
23
+ * @param wrapper - The test context providing the function wrapper and NestJS app promise.
24
+ * @param fn - The NestJS application function factory to wrap.
25
+ * @returns A getter that produces a {@link WrappedCloudFunctionV1} on each call.
26
+ */
10
27
  export declare function wrapCloudFunctionForNestTestsGetter<I extends object>(wrapper: FirebaseAdminFunctionNestTestContext, fn: WrapCloudFunctionForNestTestsInput<I>): Getter<WrappedCloudFunctionV1<I>>;
28
+ /**
29
+ * Input type for {@link wrapCallableRequestForNestTestsGetter}. Accepts a NestJS application
30
+ * callable HTTP function factory that produces a gen-2 callable function from a NestJS app promise.
31
+ */
11
32
  export type WrapCallableRequestForNestTestsInput<I, O = unknown> = NestApplicationCallableHttpFunctionFactory<I, O>;
33
+ /**
34
+ * Creates a lazy getter that wraps a NestJS-hosted callable request function for testing.
35
+ *
36
+ * Similar to {@link wrapCloudFunctionForNestTestsGetter} but targets gen-2 callable HTTP
37
+ * functions. The getter defers resolution so the NestJS app is available at call time.
38
+ *
39
+ * @param wrapper - The test context providing the function wrapper and NestJS app promise.
40
+ * @param fn - The NestJS callable HTTP function factory to wrap.
41
+ * @returns A getter that produces a {@link WrappedCallableRequest} on each call.
42
+ */
12
43
  export declare function wrapCallableRequestForNestTestsGetter<I, O = unknown>(wrapper: FirebaseAdminFunctionNestTestContext, fn: WrapCallableRequestForNestTestsInput<I, O>): Getter<WrappedCallableRequest<I, O>>;
44
+ /**
45
+ * Combined test context that merges {@link FirebaseAdminNestTestContext} (NestJS module access)
46
+ * with {@link FirebaseAdminCloudFunctionWrapperSource} (Cloud Function wrapping).
47
+ *
48
+ * Implementations provide both the NestJS {@link TestingModule} and the `fnWrapper` needed
49
+ * to wrap and invoke Cloud Functions within integration tests.
50
+ */
13
51
  export interface FirebaseAdminFunctionNestTestContext extends FirebaseAdminNestTestContext, FirebaseAdminCloudFunctionWrapperSource {
14
52
  }
53
+ /**
54
+ * Fixture that combines NestJS testing module access with Cloud Function wrapping capabilities.
55
+ *
56
+ * Extends {@link FirebaseAdminNestTestContextFixture} and adds convenience methods for wrapping
57
+ * both v1 cloud functions and gen-2 callable requests directly from the fixture, delegating
58
+ * to the standalone {@link wrapCloudFunctionForNestTestsGetter} and {@link wrapCallableRequestForNestTestsGetter} helpers.
59
+ */
15
60
  export declare class FirebaseAdminFunctionNestTestContextFixture<PI extends FirebaseAdminFunctionTestContextInstance = FirebaseAdminFunctionTestContextInstance, PF extends TestContextFixture<PI> = TestContextFixture<PI>, I extends FirebaseAdminFunctionNestTestContextInstance<PI> = FirebaseAdminFunctionNestTestContextInstance<PI>> extends FirebaseAdminNestTestContextFixture<PI, PF, I> implements FirebaseAdminFunctionNestTestContext {
16
61
  wrapCloudFunctionForNestTests<I extends object>(fn: WrapCloudFunctionForNestTestsInput<I>): WrappedCloudFunctionV1<I>;
17
62
  wrapCloudFunctionForNestTestsGetter<I extends object>(fn: WrapCloudFunctionForNestTestsInput<I>): Getter<WrappedCloudFunctionV1<I>>;
@@ -19,14 +64,67 @@ export declare class FirebaseAdminFunctionNestTestContextFixture<PI extends Fire
19
64
  wrapCallableRequestForNestTestsGetter<I, O = unknown>(fn: WrapCallableRequestForNestTestsInput<I, O>): Getter<WrappedCallableRequest<I, O>>;
20
65
  get fnWrapper(): FirebaseAdminCloudFunctionWrapper;
21
66
  }
67
+ /**
68
+ * Concrete instance that extends {@link FirebaseAdminNestTestContextInstance} with the
69
+ * {@link FirebaseAdminCloudFunctionWrapperSource} interface, delegating `fnWrapper` to
70
+ * the parent {@link FirebaseAdminFunctionTestContextInstance}.
71
+ */
22
72
  export declare class FirebaseAdminFunctionNestTestContextInstance<PI extends FirebaseAdminFunctionTestContextInstance = FirebaseAdminFunctionTestContextInstance> extends FirebaseAdminNestTestContextInstance<PI> implements FirebaseAdminFunctionNestTestContext {
23
73
  get fnWrapper(): FirebaseAdminCloudFunctionWrapper;
24
74
  }
75
+ /**
76
+ * Configuration type for NestJS + Cloud Function test contexts.
77
+ * Alias for {@link FirebaseAdminNestTestConfig} parameterized with function-aware types.
78
+ */
25
79
  export type FirebaseAdminFunctionNestTestConfig<PI extends FirebaseAdminFunctionTestContextInstance = FirebaseAdminFunctionTestContextInstance, PF extends TestContextFixture<PI> = TestContextFixture<PI>, I extends FirebaseAdminFunctionNestTestContextInstance<PI> = FirebaseAdminFunctionNestTestContextInstance<PI>, C extends FirebaseAdminFunctionNestTestContextFixture<PI, PF, I> = FirebaseAdminFunctionNestTestContextFixture<PI, PF, I>> = FirebaseAdminNestTestConfig<PI, PF, I, C>;
80
+ /**
81
+ * Factory type that produces a {@link FirebaseAdminFunctionNestTestContextFixture} for each test suite.
82
+ */
26
83
  export type FirebaseAdminFunctionNestTestContextFactory<PI extends FirebaseAdminFunctionTestContextInstance = FirebaseAdminFunctionTestContextInstance, PF extends TestContextFixture<PI> = TestContextFixture<PI>, I extends FirebaseAdminFunctionNestTestContextInstance<PI> = FirebaseAdminFunctionNestTestContextInstance<PI>, C extends FirebaseAdminFunctionNestTestContextFixture<PI, PF, I> = FirebaseAdminFunctionNestTestContextFixture<PI, PF, I>> = TestContextFactory<C>;
84
+ /**
85
+ * Composes a NestJS + Cloud Function test context on top of an existing parent factory.
86
+ *
87
+ * Use when the parent factory is custom; for the common case with default parent, prefer
88
+ * {@link firebaseAdminFunctionNestContextFactory}.
89
+ *
90
+ * @param config - NestJS module, provider, and fixture configuration.
91
+ * @param factory - The parent context factory providing the Firebase Admin function instance.
92
+ * @returns A new factory combining NestJS and Cloud Function wrapping capabilities.
93
+ */
27
94
  export declare function firebaseAdminFunctionNestContextFixture<PI extends FirebaseAdminFunctionTestContextInstance = FirebaseAdminFunctionTestContextInstance, PF extends TestContextFixture<PI> = TestContextFixture<PI>, I extends FirebaseAdminFunctionNestTestContextInstance<PI> = FirebaseAdminFunctionNestTestContextInstance<PI>, C extends FirebaseAdminFunctionNestTestContextFixture<PI, PF, I> = FirebaseAdminFunctionNestTestContextFixture<PI, PF, I>>(config: FirebaseAdminFunctionNestTestConfig<PI, PF, I, C>, factory: TestContextFactory<PF>): FirebaseAdminFunctionNestTestContextFactory<PI, PF, I, C>;
95
+ /**
96
+ * Empty NestJS module class used as a placeholder root module for function nest test contexts.
97
+ */
28
98
  export declare class FirebaseAdminFunctionNestRootModule {
29
99
  }
100
+ /**
101
+ * Wires up a NestJS {@link TestingModule} with Cloud Function wrapping inside an existing parent fixture.
102
+ *
103
+ * Merges default `makeFixture` / `makeInstance` implementations that produce function-aware
104
+ * fixture and instance classes, then delegates to {@link firebaseAdminNestContextWithFixture}.
105
+ *
106
+ * @param config - NestJS module, provider, and fixture configuration.
107
+ * @param f - The parent fixture that is already set up.
108
+ * @param buildTests - Callback that receives the child fixture and registers test cases.
109
+ */
30
110
  export declare function firebaseAdminFunctionNestContextWithFixture<PI extends FirebaseAdminFunctionTestContextInstance = FirebaseAdminFunctionTestContextInstance, PF extends TestContextFixture<PI> = TestContextFixture<PI>, I extends FirebaseAdminFunctionNestTestContextInstance<PI> = FirebaseAdminFunctionNestTestContextInstance<PI>, C extends FirebaseAdminFunctionNestTestContextFixture<PI, PF, I> = FirebaseAdminFunctionNestTestContextFixture<PI, PF, I>>(config: FirebaseAdminFunctionNestTestConfig<PI, PF, I, C>, f: PF, buildTests: BuildTestsWithContextFunction<C>): void;
111
+ /**
112
+ * Convenience factory that layers a NestJS + Cloud Function test context on top of the
113
+ * default {@link firebaseAdminFunctionTestContextFactory}. This is the simplest entry point
114
+ * for tests that need both NestJS module access and Cloud Function wrapping.
115
+ *
116
+ * @example
117
+ * ```ts
118
+ * const f = firebaseAdminFunctionNestContextFactory({
119
+ * nestModules: [MyAppModule]
120
+ * });
121
+ *
122
+ * f((c) => {
123
+ * describeCallableRequestTest('myCallable', { f: c, fn: myCallableFactory }, (wrappedFn) => {
124
+ * it('should succeed', async () => { ... });
125
+ * });
126
+ * });
127
+ * ```
128
+ */
31
129
  export declare function firebaseAdminFunctionNestContextFactory<I extends FirebaseAdminFunctionNestTestContextInstance<FirebaseAdminFunctionTestContextInstance> = FirebaseAdminFunctionNestTestContextInstance<FirebaseAdminFunctionTestContextInstance>>(config: FirebaseAdminFunctionNestTestConfig<FirebaseAdminFunctionTestContextInstance, TestContextFixture<FirebaseAdminFunctionTestContextInstance>, I>): FirebaseAdminFunctionNestTestContextFactory<FirebaseAdminFunctionTestContextInstance, TestContextFixture<FirebaseAdminFunctionTestContextInstance>, I>;
32
130
  export {};
@@ -1,3 +1,29 @@
1
1
  import { type TestFirestoreContextFixture, type TestFirestoreInstance } from '@dereekb/firebase/test';
2
+ /**
3
+ * Initializes the Firebase Admin test environment with the default emulator ports
4
+ * used by the `@dereekb/firebase-server` test suite.
5
+ *
6
+ * This is a convenience wrapper around {@link initFirebaseAdminTestEnvironment} that
7
+ * pre-configures auth (9903), firestore (9904), and storage (9906) on `0.0.0.0`.
8
+ * Call this once at the top of each test file (or in a global setup) before any
9
+ * Firebase Admin SDK calls are made.
10
+ *
11
+ * @example
12
+ * ```ts
13
+ * beforeAll(() => {
14
+ * initFirebaseServerAdminTestEnvironment();
15
+ * });
16
+ * ```
17
+ */
2
18
  export declare function initFirebaseServerAdminTestEnvironment(): void;
19
+ /**
20
+ * Registers a smoke-test `describe` block that verifies basic Firestore connectivity
21
+ * against the emulator.
22
+ *
23
+ * Creates a {@link MockItemFirestoreCollection}, writes a document, and asserts it exists.
24
+ * Useful as a sanity check inside larger test suites to confirm the emulator is reachable
25
+ * and the fixture is wired up correctly.
26
+ *
27
+ * @param s - The firestore context fixture providing the active {@link TestFirestoreContext}.
28
+ */
3
29
  export declare function describeFirestoreTest(s: TestFirestoreContextFixture<TestFirestoreInstance>): void;
@@ -1,21 +1,76 @@
1
1
  /**
2
- * Host url:port combo.
2
+ * A `host:port` string used to connect to a Firebase emulator.
3
3
  *
4
- * I.E. localhost:8080
4
+ * @example
5
+ * ```ts
6
+ * const host: FirebaseAdminTestEnvironmentHost = 'localhost:8080';
7
+ * ```
5
8
  */
6
9
  export type FirebaseAdminTestEnvironmentHost = string;
10
+ /**
11
+ * Configuration for Firebase emulator host addresses.
12
+ *
13
+ * Each emulator can be set to a {@link FirebaseAdminTestEnvironmentHost} string to enable it,
14
+ * or `null` to skip that emulator. If the firestore emulator is non-null and another emulator
15
+ * is left undefined (not null), {@link initFirebaseAdminTestEnvironment} will throw to prevent
16
+ * accidental connections to production services.
17
+ */
7
18
  export interface FirebaseAdminTestEnvironmentEmulatorsConfig {
8
19
  auth: FirebaseAdminTestEnvironmentHost | null;
9
20
  storage: FirebaseAdminTestEnvironmentHost | null;
10
21
  firestore: FirebaseAdminTestEnvironmentHost | null;
11
22
  }
23
+ /**
24
+ * Top-level configuration for initializing the Firebase Admin test environment.
25
+ *
26
+ * Passed to {@link initFirebaseAdminTestEnvironment} to configure which emulators the test suite connects to.
27
+ */
12
28
  export interface FirebaseAdminTestEnvironmentConfig {
13
29
  emulators: FirebaseAdminTestEnvironmentEmulatorsConfig;
14
30
  }
31
+ /**
32
+ * Returns whether {@link initFirebaseAdminTestEnvironment} has already been called.
33
+ *
34
+ * Useful for guarding against double-initialization or verifying that setup has completed
35
+ * before creating test contexts.
36
+ */
15
37
  export declare function isAdminEnvironmentInitialized(): boolean;
38
+ /**
39
+ * Generates a unique GCloud project ID based on the current timestamp.
40
+ *
41
+ * The generated ID has the format `firebase-test-<epoch-millis>`, ensuring each test run
42
+ * operates against an isolated project namespace in the emulators.
43
+ *
44
+ * @example
45
+ * ```ts
46
+ * const projectId = generateNewProjectId();
47
+ * // => 'firebase-test-1710000000000'
48
+ * ```
49
+ */
16
50
  export declare function generateNewProjectId(): string;
51
+ /**
52
+ * Generates a new project ID and writes it to the `GCLOUD_PROJECT` and `GCLOUD_TEST_PROJECT`
53
+ * environment variables. Also updates `FIREBASE_CONFIG` via {@link applyFirebaseGCloudTestProjectIdToFirebaseConfigEnv}.
54
+ *
55
+ * This ensures all Firebase Admin SDK calls within the current process use an isolated project,
56
+ * preventing cross-test data contamination when running against emulators.
57
+ *
58
+ * @returns The newly generated project ID.
59
+ */
17
60
  export declare function rollNewGCloudProjectEnvironmentVariable(): string;
61
+ /**
62
+ * Reads the current `GCLOUD_PROJECT` environment variable.
63
+ *
64
+ * This is the "active" project ID that the Firebase Admin SDK resolves at runtime.
65
+ */
18
66
  export declare function getGCloudProjectId(): string | undefined;
67
+ /**
68
+ * Reads the current `GCLOUD_TEST_PROJECT` environment variable.
69
+ *
70
+ * This holds the canonical test project ID set during {@link rollNewGCloudProjectEnvironmentVariable},
71
+ * and is used by {@link applyFirebaseGCloudTestProjectIdToFirebaseConfigEnv} as the source of truth
72
+ * when re-applying the project ID after external libraries overwrite `FIREBASE_CONFIG`.
73
+ */
19
74
  export declare function getGCloudTestProjectId(): string | undefined;
20
75
  /**
21
76
  * Applies the current GCLOUD_PROJECT to FIREBASE_CONFIG.