@lpdjs/firestore-repo-service 2.1.2 → 2.1.4
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/README.md +22 -13
- package/dist/index.cjs +44 -44
- package/dist/index.cjs.map +1 -1
- package/dist/index.js +44 -44
- package/dist/index.js.map +1 -1
- package/dist/servers/admin/index.cjs +4 -4
- package/dist/servers/admin/index.cjs.map +1 -1
- package/dist/servers/admin/index.js +4 -4
- package/dist/servers/admin/index.js.map +1 -1
- package/dist/servers/crud/index.cjs +2 -2
- package/dist/servers/crud/index.cjs.map +1 -1
- package/dist/servers/crud/index.js +2 -2
- package/dist/servers/crud/index.js.map +1 -1
- package/dist/servers/index.cjs +2 -2
- package/dist/servers/index.cjs.map +1 -1
- package/dist/servers/index.js +2 -2
- package/dist/servers/index.js.map +1 -1
- package/dist/sync/bigquery.cjs +7 -8
- package/dist/sync/bigquery.cjs.map +1 -1
- package/dist/sync/bigquery.d.cts +4 -2
- package/dist/sync/bigquery.d.ts +4 -2
- package/dist/sync/bigquery.js +7 -8
- package/dist/sync/bigquery.js.map +1 -1
- package/dist/sync/index.cjs +41 -39
- package/dist/sync/index.cjs.map +1 -1
- package/dist/sync/index.d.cts +178 -170
- package/dist/sync/index.d.ts +178 -170
- package/dist/sync/index.js +41 -39
- package/dist/sync/index.js.map +1 -1
- package/dist/{types-PzZ0APQ_.d.cts → types-DE9lapG8.d.cts} +35 -16
- package/dist/{types-PzZ0APQ_.d.ts → types-DE9lapG8.d.ts} +35 -16
- package/package.json +1 -1
|
@@ -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) */
|
|
@@ -36,10 +38,6 @@ interface SqlDialect {
|
|
|
36
38
|
mapType(logical: LogicalType): string;
|
|
37
39
|
/** Wrap an identifier (table / column name) for the dialect */
|
|
38
40
|
quoteIdentifier(id: string): string;
|
|
39
|
-
/** Generate a full CREATE TABLE statement */
|
|
40
|
-
createTableDDL(table: SqlTableDef): string;
|
|
41
|
-
/** Generate ALTER TABLE ADD COLUMN statement(s) for new columns */
|
|
42
|
-
addColumnsDDL(tableName: string, columns: SqlColumn[]): string;
|
|
43
41
|
}
|
|
44
42
|
/**
|
|
45
43
|
* Logical types used as an intermediate representation between Zod types
|
|
@@ -94,6 +92,16 @@ interface SqlAdapter {
|
|
|
94
92
|
* Delete rows by primary-key values.
|
|
95
93
|
*/
|
|
96
94
|
deleteRows(tableName: string, primaryKey: string, ids: string[]): Promise<void>;
|
|
95
|
+
/**
|
|
96
|
+
* Add columns to an existing table.
|
|
97
|
+
* The adapter is responsible for qualifying table names (e.g. dataset.table).
|
|
98
|
+
*/
|
|
99
|
+
addColumns(tableName: string, columns: SqlColumn[]): Promise<void>;
|
|
100
|
+
/**
|
|
101
|
+
* Execute a raw SQL statement.
|
|
102
|
+
* The adapter is responsible for qualifying any table references.
|
|
103
|
+
*/
|
|
104
|
+
executeRaw(sql: string): Promise<void>;
|
|
97
105
|
}
|
|
98
106
|
/** Per-repository sync options, typed to the repo's field names. */
|
|
99
107
|
interface RepoSyncConfig<F extends string = string> {
|
|
@@ -202,7 +210,7 @@ interface GenerateDDLConfig<M = Record<string, any>> {
|
|
|
202
210
|
/**
|
|
203
211
|
* HTTP Basic Auth configuration for the sync admin.
|
|
204
212
|
*/
|
|
205
|
-
interface
|
|
213
|
+
interface adminsyncBasicAuth {
|
|
206
214
|
type: "basic";
|
|
207
215
|
/** Realm displayed in the browser login dialog */
|
|
208
216
|
realm?: string;
|
|
@@ -212,7 +220,7 @@ interface SyncAdminBasicAuth {
|
|
|
212
220
|
/**
|
|
213
221
|
* Feature flags controlling which sync admin endpoints are enabled.
|
|
214
222
|
*/
|
|
215
|
-
interface
|
|
223
|
+
interface adminsyncFeaturesFlag {
|
|
216
224
|
/** Show pending queue state (default: false) */
|
|
217
225
|
viewQueue?: boolean;
|
|
218
226
|
/** Allow force-syncing an entire collection (default: false) */
|
|
@@ -227,13 +235,13 @@ interface SyncAdminFeaturesFlag {
|
|
|
227
235
|
* When provided in `FirestoreSyncConfig.admin`, an `onRequest` Cloud Function
|
|
228
236
|
* handler is created and added to `sync.functions`.
|
|
229
237
|
*/
|
|
230
|
-
interface
|
|
238
|
+
interface adminsyncConfig {
|
|
231
239
|
/** Authentication guard — HTTP Basic Auth or custom middleware function */
|
|
232
|
-
auth?:
|
|
240
|
+
auth?: adminsyncBasicAuth | ((req: any, res: any, next: () => void) => void | Promise<void>);
|
|
233
241
|
/** Base URL path (default: "/sync-admin") */
|
|
234
242
|
basePath?: string;
|
|
235
243
|
/** Feature flags controlling which endpoints are enabled */
|
|
236
|
-
featuresFlag?:
|
|
244
|
+
featuresFlag?: adminsyncFeaturesFlag;
|
|
237
245
|
/**
|
|
238
246
|
* `onRequest` from `firebase-functions/https` (or `firebase-functions/v2/https`).
|
|
239
247
|
* When provided, the admin handler is automatically wrapped as a Cloud Function.
|
|
@@ -248,10 +256,21 @@ interface SyncAdminConfig {
|
|
|
248
256
|
}
|
|
249
257
|
/** Options for `createFirestoreSync()` — the unified wrapper. */
|
|
250
258
|
interface FirestoreSyncConfig<M = Record<string, any>> {
|
|
251
|
-
/**
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
259
|
+
/**
|
|
260
|
+
* External dependencies — all Firebase/PubSub modules.
|
|
261
|
+
* `pubsub` can be a factory `() => PubSub` for lazy initialization
|
|
262
|
+
* (avoids creating gRPC channels at module-load time for functions that
|
|
263
|
+
* don't need PubSub, e.g. the admin or CRUD servers).
|
|
264
|
+
*/
|
|
265
|
+
deps: Omit<SyncDeps, "pubsub"> & {
|
|
266
|
+
pubsub: OrFactory<PubSubClientDep>;
|
|
267
|
+
};
|
|
268
|
+
/**
|
|
269
|
+
* SQL adapter to flush data to.
|
|
270
|
+
* Can be a factory `() => adapter` for lazy initialization
|
|
271
|
+
* (avoids connecting to BigQuery / SQL at module-load time).
|
|
272
|
+
*/
|
|
273
|
+
adapter: OrFactory<SqlAdapter>;
|
|
255
274
|
/** PubSub topic name prefix (topics will be `{prefix}-{repoName}`) */
|
|
256
275
|
topicPrefix?: string;
|
|
257
276
|
/** Max rows per flush batch (default: 100) */
|
|
@@ -261,13 +280,13 @@ interface FirestoreSyncConfig<M = Record<string, any>> {
|
|
|
261
280
|
/** Auto-create/migrate tables on first event (default: false) */
|
|
262
281
|
autoMigrate?: boolean;
|
|
263
282
|
/**
|
|
264
|
-
* Optional sync admin endpoint. When provided, a `
|
|
283
|
+
* Optional sync admin endpoint. When provided, a `adminsync` handler is
|
|
265
284
|
* added to `sync.functions` exposing health-check, force-sync, and queue
|
|
266
285
|
* inspection endpoints behind authentication.
|
|
267
286
|
*/
|
|
268
|
-
admin?:
|
|
287
|
+
admin?: adminsyncConfig;
|
|
269
288
|
/** Per-repo overrides (shared between triggers and worker) */
|
|
270
289
|
repos?: TypedRepoSyncConfigs<M>;
|
|
271
290
|
}
|
|
272
291
|
|
|
273
|
-
export type { FirestoreSyncConfig as F, GenerateDDLConfig as G, LogicalType as L, PubSubClientDep as P, RepoSyncConfig as R,
|
|
292
|
+
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) */
|
|
@@ -36,10 +38,6 @@ interface SqlDialect {
|
|
|
36
38
|
mapType(logical: LogicalType): string;
|
|
37
39
|
/** Wrap an identifier (table / column name) for the dialect */
|
|
38
40
|
quoteIdentifier(id: string): string;
|
|
39
|
-
/** Generate a full CREATE TABLE statement */
|
|
40
|
-
createTableDDL(table: SqlTableDef): string;
|
|
41
|
-
/** Generate ALTER TABLE ADD COLUMN statement(s) for new columns */
|
|
42
|
-
addColumnsDDL(tableName: string, columns: SqlColumn[]): string;
|
|
43
41
|
}
|
|
44
42
|
/**
|
|
45
43
|
* Logical types used as an intermediate representation between Zod types
|
|
@@ -94,6 +92,16 @@ interface SqlAdapter {
|
|
|
94
92
|
* Delete rows by primary-key values.
|
|
95
93
|
*/
|
|
96
94
|
deleteRows(tableName: string, primaryKey: string, ids: string[]): Promise<void>;
|
|
95
|
+
/**
|
|
96
|
+
* Add columns to an existing table.
|
|
97
|
+
* The adapter is responsible for qualifying table names (e.g. dataset.table).
|
|
98
|
+
*/
|
|
99
|
+
addColumns(tableName: string, columns: SqlColumn[]): Promise<void>;
|
|
100
|
+
/**
|
|
101
|
+
* Execute a raw SQL statement.
|
|
102
|
+
* The adapter is responsible for qualifying any table references.
|
|
103
|
+
*/
|
|
104
|
+
executeRaw(sql: string): Promise<void>;
|
|
97
105
|
}
|
|
98
106
|
/** Per-repository sync options, typed to the repo's field names. */
|
|
99
107
|
interface RepoSyncConfig<F extends string = string> {
|
|
@@ -202,7 +210,7 @@ interface GenerateDDLConfig<M = Record<string, any>> {
|
|
|
202
210
|
/**
|
|
203
211
|
* HTTP Basic Auth configuration for the sync admin.
|
|
204
212
|
*/
|
|
205
|
-
interface
|
|
213
|
+
interface adminsyncBasicAuth {
|
|
206
214
|
type: "basic";
|
|
207
215
|
/** Realm displayed in the browser login dialog */
|
|
208
216
|
realm?: string;
|
|
@@ -212,7 +220,7 @@ interface SyncAdminBasicAuth {
|
|
|
212
220
|
/**
|
|
213
221
|
* Feature flags controlling which sync admin endpoints are enabled.
|
|
214
222
|
*/
|
|
215
|
-
interface
|
|
223
|
+
interface adminsyncFeaturesFlag {
|
|
216
224
|
/** Show pending queue state (default: false) */
|
|
217
225
|
viewQueue?: boolean;
|
|
218
226
|
/** Allow force-syncing an entire collection (default: false) */
|
|
@@ -227,13 +235,13 @@ interface SyncAdminFeaturesFlag {
|
|
|
227
235
|
* When provided in `FirestoreSyncConfig.admin`, an `onRequest` Cloud Function
|
|
228
236
|
* handler is created and added to `sync.functions`.
|
|
229
237
|
*/
|
|
230
|
-
interface
|
|
238
|
+
interface adminsyncConfig {
|
|
231
239
|
/** Authentication guard — HTTP Basic Auth or custom middleware function */
|
|
232
|
-
auth?:
|
|
240
|
+
auth?: adminsyncBasicAuth | ((req: any, res: any, next: () => void) => void | Promise<void>);
|
|
233
241
|
/** Base URL path (default: "/sync-admin") */
|
|
234
242
|
basePath?: string;
|
|
235
243
|
/** Feature flags controlling which endpoints are enabled */
|
|
236
|
-
featuresFlag?:
|
|
244
|
+
featuresFlag?: adminsyncFeaturesFlag;
|
|
237
245
|
/**
|
|
238
246
|
* `onRequest` from `firebase-functions/https` (or `firebase-functions/v2/https`).
|
|
239
247
|
* When provided, the admin handler is automatically wrapped as a Cloud Function.
|
|
@@ -248,10 +256,21 @@ interface SyncAdminConfig {
|
|
|
248
256
|
}
|
|
249
257
|
/** Options for `createFirestoreSync()` — the unified wrapper. */
|
|
250
258
|
interface FirestoreSyncConfig<M = Record<string, any>> {
|
|
251
|
-
/**
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
259
|
+
/**
|
|
260
|
+
* External dependencies — all Firebase/PubSub modules.
|
|
261
|
+
* `pubsub` can be a factory `() => PubSub` for lazy initialization
|
|
262
|
+
* (avoids creating gRPC channels at module-load time for functions that
|
|
263
|
+
* don't need PubSub, e.g. the admin or CRUD servers).
|
|
264
|
+
*/
|
|
265
|
+
deps: Omit<SyncDeps, "pubsub"> & {
|
|
266
|
+
pubsub: OrFactory<PubSubClientDep>;
|
|
267
|
+
};
|
|
268
|
+
/**
|
|
269
|
+
* SQL adapter to flush data to.
|
|
270
|
+
* Can be a factory `() => adapter` for lazy initialization
|
|
271
|
+
* (avoids connecting to BigQuery / SQL at module-load time).
|
|
272
|
+
*/
|
|
273
|
+
adapter: OrFactory<SqlAdapter>;
|
|
255
274
|
/** PubSub topic name prefix (topics will be `{prefix}-{repoName}`) */
|
|
256
275
|
topicPrefix?: string;
|
|
257
276
|
/** Max rows per flush batch (default: 100) */
|
|
@@ -261,13 +280,13 @@ interface FirestoreSyncConfig<M = Record<string, any>> {
|
|
|
261
280
|
/** Auto-create/migrate tables on first event (default: false) */
|
|
262
281
|
autoMigrate?: boolean;
|
|
263
282
|
/**
|
|
264
|
-
* Optional sync admin endpoint. When provided, a `
|
|
283
|
+
* Optional sync admin endpoint. When provided, a `adminsync` handler is
|
|
265
284
|
* added to `sync.functions` exposing health-check, force-sync, and queue
|
|
266
285
|
* inspection endpoints behind authentication.
|
|
267
286
|
*/
|
|
268
|
-
admin?:
|
|
287
|
+
admin?: adminsyncConfig;
|
|
269
288
|
/** Per-repo overrides (shared between triggers and worker) */
|
|
270
289
|
repos?: TypedRepoSyncConfigs<M>;
|
|
271
290
|
}
|
|
272
291
|
|
|
273
|
-
export type { FirestoreSyncConfig as F, GenerateDDLConfig as G, LogicalType as L, PubSubClientDep as P, RepoSyncConfig as R,
|
|
292
|
+
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.
|
|
3
|
+
"version": "2.1.4",
|
|
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",
|