@lpdjs/firestore-repo-service 2.1.2 → 2.1.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -5,6 +5,8 @@
5
5
  * worker) and any SQL backend (BigQuery, PostgreSQL, …). Only the adapter
6
6
  * touches the database SDK; everything else works with these abstractions.
7
7
  */
8
+ /** A value that can be provided directly or as a lazy factory function. */
9
+ type OrFactory<T> = T | (() => T);
8
10
  /** A single column in a SQL table. */
9
11
  interface SqlColumn {
10
12
  /** Column name (snake_case recommended for SQL) */
@@ -202,7 +204,7 @@ interface GenerateDDLConfig<M = Record<string, any>> {
202
204
  /**
203
205
  * HTTP Basic Auth configuration for the sync admin.
204
206
  */
205
- interface SyncAdminBasicAuth {
207
+ interface adminsyncBasicAuth {
206
208
  type: "basic";
207
209
  /** Realm displayed in the browser login dialog */
208
210
  realm?: string;
@@ -212,7 +214,7 @@ interface SyncAdminBasicAuth {
212
214
  /**
213
215
  * Feature flags controlling which sync admin endpoints are enabled.
214
216
  */
215
- interface SyncAdminFeaturesFlag {
217
+ interface adminsyncFeaturesFlag {
216
218
  /** Show pending queue state (default: false) */
217
219
  viewQueue?: boolean;
218
220
  /** Allow force-syncing an entire collection (default: false) */
@@ -227,13 +229,13 @@ interface SyncAdminFeaturesFlag {
227
229
  * When provided in `FirestoreSyncConfig.admin`, an `onRequest` Cloud Function
228
230
  * handler is created and added to `sync.functions`.
229
231
  */
230
- interface SyncAdminConfig {
232
+ interface adminsyncConfig {
231
233
  /** Authentication guard — HTTP Basic Auth or custom middleware function */
232
- auth?: SyncAdminBasicAuth | ((req: any, res: any, next: () => void) => void | Promise<void>);
234
+ auth?: adminsyncBasicAuth | ((req: any, res: any, next: () => void) => void | Promise<void>);
233
235
  /** Base URL path (default: "/sync-admin") */
234
236
  basePath?: string;
235
237
  /** Feature flags controlling which endpoints are enabled */
236
- featuresFlag?: SyncAdminFeaturesFlag;
238
+ featuresFlag?: adminsyncFeaturesFlag;
237
239
  /**
238
240
  * `onRequest` from `firebase-functions/https` (or `firebase-functions/v2/https`).
239
241
  * When provided, the admin handler is automatically wrapped as a Cloud Function.
@@ -248,10 +250,21 @@ interface SyncAdminConfig {
248
250
  }
249
251
  /** Options for `createFirestoreSync()` — the unified wrapper. */
250
252
  interface FirestoreSyncConfig<M = Record<string, any>> {
251
- /** External dependencies — all Firebase/PubSub modules */
252
- deps: SyncDeps;
253
- /** SQL adapter to flush data to */
254
- adapter: SqlAdapter;
253
+ /**
254
+ * External dependencies — all Firebase/PubSub modules.
255
+ * `pubsub` can be a factory `() => PubSub` for lazy initialization
256
+ * (avoids creating gRPC channels at module-load time for functions that
257
+ * don't need PubSub, e.g. the admin or CRUD servers).
258
+ */
259
+ deps: Omit<SyncDeps, "pubsub"> & {
260
+ pubsub: OrFactory<PubSubClientDep>;
261
+ };
262
+ /**
263
+ * SQL adapter to flush data to.
264
+ * Can be a factory `() => adapter` for lazy initialization
265
+ * (avoids connecting to BigQuery / SQL at module-load time).
266
+ */
267
+ adapter: OrFactory<SqlAdapter>;
255
268
  /** PubSub topic name prefix (topics will be `{prefix}-{repoName}`) */
256
269
  topicPrefix?: string;
257
270
  /** Max rows per flush batch (default: 100) */
@@ -261,13 +274,13 @@ interface FirestoreSyncConfig<M = Record<string, any>> {
261
274
  /** Auto-create/migrate tables on first event (default: false) */
262
275
  autoMigrate?: boolean;
263
276
  /**
264
- * Optional sync admin endpoint. When provided, a `syncAdmin` handler is
277
+ * Optional sync admin endpoint. When provided, a `adminsync` handler is
265
278
  * added to `sync.functions` exposing health-check, force-sync, and queue
266
279
  * inspection endpoints behind authentication.
267
280
  */
268
- admin?: SyncAdminConfig;
281
+ admin?: adminsyncConfig;
269
282
  /** Per-repo overrides (shared between triggers and worker) */
270
283
  repos?: TypedRepoSyncConfigs<M>;
271
284
  }
272
285
 
273
- export type { FirestoreSyncConfig as F, GenerateDDLConfig as G, LogicalType as L, PubSubClientDep as P, RepoSyncConfig as R, SqlDialect as S, SqlColumn as a, SqlTableDef as b, SqlAdapter as c, SyncEvent as d, SyncWorkerConfig as e, SyncTriggersConfig as f, SyncAdminConfig as g, SyncOperation as h, SyncDeps as i, FirestoreTriggersDep as j, PubSubHandlerDep as k, SyncAdminBasicAuth as l, SyncAdminFeaturesFlag as m };
286
+ export type { FirestoreSyncConfig as F, GenerateDDLConfig as G, LogicalType as L, OrFactory as O, PubSubClientDep as P, RepoSyncConfig as R, SqlAdapter as S, SyncEvent as a, adminsyncConfig as b, SqlDialect as c, SqlColumn as d, SqlTableDef as e, SyncTriggersConfig as f, SyncWorkerConfig as g, FirestoreTriggersDep as h, PubSubHandlerDep as i, SyncDeps as j, SyncOperation as k, adminsyncBasicAuth as l, adminsyncFeaturesFlag as m };
@@ -5,6 +5,8 @@
5
5
  * worker) and any SQL backend (BigQuery, PostgreSQL, …). Only the adapter
6
6
  * touches the database SDK; everything else works with these abstractions.
7
7
  */
8
+ /** A value that can be provided directly or as a lazy factory function. */
9
+ type OrFactory<T> = T | (() => T);
8
10
  /** A single column in a SQL table. */
9
11
  interface SqlColumn {
10
12
  /** Column name (snake_case recommended for SQL) */
@@ -202,7 +204,7 @@ interface GenerateDDLConfig<M = Record<string, any>> {
202
204
  /**
203
205
  * HTTP Basic Auth configuration for the sync admin.
204
206
  */
205
- interface SyncAdminBasicAuth {
207
+ interface adminsyncBasicAuth {
206
208
  type: "basic";
207
209
  /** Realm displayed in the browser login dialog */
208
210
  realm?: string;
@@ -212,7 +214,7 @@ interface SyncAdminBasicAuth {
212
214
  /**
213
215
  * Feature flags controlling which sync admin endpoints are enabled.
214
216
  */
215
- interface SyncAdminFeaturesFlag {
217
+ interface adminsyncFeaturesFlag {
216
218
  /** Show pending queue state (default: false) */
217
219
  viewQueue?: boolean;
218
220
  /** Allow force-syncing an entire collection (default: false) */
@@ -227,13 +229,13 @@ interface SyncAdminFeaturesFlag {
227
229
  * When provided in `FirestoreSyncConfig.admin`, an `onRequest` Cloud Function
228
230
  * handler is created and added to `sync.functions`.
229
231
  */
230
- interface SyncAdminConfig {
232
+ interface adminsyncConfig {
231
233
  /** Authentication guard — HTTP Basic Auth or custom middleware function */
232
- auth?: SyncAdminBasicAuth | ((req: any, res: any, next: () => void) => void | Promise<void>);
234
+ auth?: adminsyncBasicAuth | ((req: any, res: any, next: () => void) => void | Promise<void>);
233
235
  /** Base URL path (default: "/sync-admin") */
234
236
  basePath?: string;
235
237
  /** Feature flags controlling which endpoints are enabled */
236
- featuresFlag?: SyncAdminFeaturesFlag;
238
+ featuresFlag?: adminsyncFeaturesFlag;
237
239
  /**
238
240
  * `onRequest` from `firebase-functions/https` (or `firebase-functions/v2/https`).
239
241
  * When provided, the admin handler is automatically wrapped as a Cloud Function.
@@ -248,10 +250,21 @@ interface SyncAdminConfig {
248
250
  }
249
251
  /** Options for `createFirestoreSync()` — the unified wrapper. */
250
252
  interface FirestoreSyncConfig<M = Record<string, any>> {
251
- /** External dependencies — all Firebase/PubSub modules */
252
- deps: SyncDeps;
253
- /** SQL adapter to flush data to */
254
- adapter: SqlAdapter;
253
+ /**
254
+ * External dependencies — all Firebase/PubSub modules.
255
+ * `pubsub` can be a factory `() => PubSub` for lazy initialization
256
+ * (avoids creating gRPC channels at module-load time for functions that
257
+ * don't need PubSub, e.g. the admin or CRUD servers).
258
+ */
259
+ deps: Omit<SyncDeps, "pubsub"> & {
260
+ pubsub: OrFactory<PubSubClientDep>;
261
+ };
262
+ /**
263
+ * SQL adapter to flush data to.
264
+ * Can be a factory `() => adapter` for lazy initialization
265
+ * (avoids connecting to BigQuery / SQL at module-load time).
266
+ */
267
+ adapter: OrFactory<SqlAdapter>;
255
268
  /** PubSub topic name prefix (topics will be `{prefix}-{repoName}`) */
256
269
  topicPrefix?: string;
257
270
  /** Max rows per flush batch (default: 100) */
@@ -261,13 +274,13 @@ interface FirestoreSyncConfig<M = Record<string, any>> {
261
274
  /** Auto-create/migrate tables on first event (default: false) */
262
275
  autoMigrate?: boolean;
263
276
  /**
264
- * Optional sync admin endpoint. When provided, a `syncAdmin` handler is
277
+ * Optional sync admin endpoint. When provided, a `adminsync` handler is
265
278
  * added to `sync.functions` exposing health-check, force-sync, and queue
266
279
  * inspection endpoints behind authentication.
267
280
  */
268
- admin?: SyncAdminConfig;
281
+ admin?: adminsyncConfig;
269
282
  /** Per-repo overrides (shared between triggers and worker) */
270
283
  repos?: TypedRepoSyncConfigs<M>;
271
284
  }
272
285
 
273
- export type { FirestoreSyncConfig as F, GenerateDDLConfig as G, LogicalType as L, PubSubClientDep as P, RepoSyncConfig as R, SqlDialect as S, SqlColumn as a, SqlTableDef as b, SqlAdapter as c, SyncEvent as d, SyncWorkerConfig as e, SyncTriggersConfig as f, SyncAdminConfig as g, SyncOperation as h, SyncDeps as i, FirestoreTriggersDep as j, PubSubHandlerDep as k, SyncAdminBasicAuth as l, SyncAdminFeaturesFlag as m };
286
+ export type { FirestoreSyncConfig as F, GenerateDDLConfig as G, LogicalType as L, OrFactory as O, PubSubClientDep as P, RepoSyncConfig as R, SqlAdapter as S, SyncEvent as a, adminsyncConfig as b, SqlDialect as c, SqlColumn as d, SqlTableDef as e, SyncTriggersConfig as f, SyncWorkerConfig as g, FirestoreTriggersDep as h, PubSubHandlerDep as i, SyncDeps as j, SyncOperation as k, adminsyncBasicAuth as l, adminsyncFeaturesFlag as m };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@lpdjs/firestore-repo-service",
3
- "version": "2.1.2",
3
+ "version": "2.1.3",
4
4
  "description": "⚡ Type-safe Firestore ORM with auto-generated repositories, advanced queries, relations with typed select, pagination with include, batch/bulk operations, aggregations and transactions.",
5
5
  "type": "module",
6
6
  "main": "./dist/index.cjs",