@lpdjs/firestore-repo-service 2.2.3 → 2.2.5

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 (40) hide show
  1. package/README.md +40 -19
  2. package/dist/create-servers-D4-NGpKm.d.ts +105 -0
  3. package/dist/create-servers-DmggzSb3.d.cts +105 -0
  4. package/dist/{index-Bw1fvzu5.d.ts → index-Cvip2Sgt.d.ts} +2 -2
  5. package/dist/{index-bqqrGjxe.d.cts → index-DpD4DEqH.d.cts} +2 -2
  6. package/dist/index.cjs +137 -47
  7. package/dist/index.cjs.map +1 -1
  8. package/dist/index.d.cts +9 -4
  9. package/dist/index.d.ts +9 -4
  10. package/dist/index.js +137 -47
  11. package/dist/index.js.map +1 -1
  12. package/dist/openapi-B3P2F8op.d.ts +69 -0
  13. package/dist/openapi-UJJ1aCFk.d.cts +69 -0
  14. package/dist/queue-D_-aMf4H.d.ts +52 -0
  15. package/dist/queue-Dk1Ezhkf.d.cts +52 -0
  16. package/dist/servers/admin/index.d.cts +2 -2
  17. package/dist/servers/admin/index.d.ts +2 -2
  18. package/dist/servers/crud/index.cjs.map +1 -1
  19. package/dist/servers/crud/index.d.cts +4 -2
  20. package/dist/servers/crud/index.d.ts +4 -2
  21. package/dist/servers/crud/index.js.map +1 -1
  22. package/dist/servers/index.cjs +157 -67
  23. package/dist/servers/index.cjs.map +1 -1
  24. package/dist/servers/index.d.cts +9 -4
  25. package/dist/servers/index.d.ts +9 -4
  26. package/dist/servers/index.js +157 -67
  27. package/dist/servers/index.js.map +1 -1
  28. package/dist/sync/bigquery.d.cts +1 -1
  29. package/dist/sync/bigquery.d.ts +1 -1
  30. package/dist/sync/index.cjs +33 -33
  31. package/dist/sync/index.cjs.map +1 -1
  32. package/dist/sync/index.d.cts +5 -107
  33. package/dist/sync/index.d.ts +5 -107
  34. package/dist/sync/index.js +33 -33
  35. package/dist/sync/index.js.map +1 -1
  36. package/dist/{types-BbCdscqh.d.cts → types-CX5AbZWV.d.cts} +1 -1
  37. package/dist/{types-BbCdscqh.d.ts → types-CX5AbZWV.d.ts} +1 -1
  38. package/dist/{types-DKgWRTDf.d.cts → types-Z9Qy8Xmx.d.cts} +7 -68
  39. package/dist/{types-DKgWRTDf.d.ts → types-Z9Qy8Xmx.d.ts} +7 -68
  40. package/package.json +1 -1
@@ -0,0 +1,69 @@
1
+ import { s as CrudRepoRegistry, O as OpenAPISpecOptions } from './types-Z9Qy8Xmx.js';
2
+
3
+ /**
4
+ * OpenAPI 3.1 specification generator for the CRUD server.
5
+ *
6
+ * Introspects each `CrudRepoEntry` and uses Zod 4's native `z.toJSONSchema()`
7
+ * to produce a fully typed OpenAPI document ready for Scalar UI or codegen.
8
+ *
9
+ * @module servers/crud/openapi
10
+ */
11
+
12
+ /** Minimal subset of an OpenAPI 3.1 document we produce. */
13
+ interface OpenAPIDocument {
14
+ openapi: "3.1.0";
15
+ info: OpenAPIInfo;
16
+ servers?: {
17
+ url: string;
18
+ description?: string;
19
+ }[];
20
+ paths: Record<string, Record<string, OpenAPIOperation>>;
21
+ components: {
22
+ schemas: Record<string, Record<string, unknown>>;
23
+ securitySchemes?: Record<string, Record<string, unknown>>;
24
+ };
25
+ security?: Record<string, string[]>[];
26
+ tags?: {
27
+ name: string;
28
+ description?: string;
29
+ }[];
30
+ }
31
+ interface OpenAPIInfo {
32
+ title: string;
33
+ version: string;
34
+ description?: string;
35
+ }
36
+ interface OpenAPIOperation {
37
+ operationId: string;
38
+ summary: string;
39
+ tags: string[];
40
+ parameters?: Record<string, unknown>[];
41
+ requestBody?: Record<string, unknown>;
42
+ responses: Record<string, Record<string, unknown>>;
43
+ security?: Record<string, string[]>[];
44
+ }
45
+ /**
46
+ * Generate a full OpenAPI 3.1 specification from a `CrudRepoRegistry`.
47
+ *
48
+ * Uses Zod 4's native `z.toJSONSchema()` to convert each repo's schema
49
+ * into a JSON Schema component, then assembles paths for the standard
50
+ * CRUD endpoints.
51
+ *
52
+ * @example
53
+ * ```ts
54
+ * import { generateOpenAPISpec } from "@lpdjs/firestore-repo-service/servers/crud";
55
+ *
56
+ * const spec = generateOpenAPISpec(registry, "/api", {
57
+ * title: "My API",
58
+ * version: "1.0.0",
59
+ * servers: [{ url: "https://my-api.example.com" }],
60
+ * auth: "bearer",
61
+ * });
62
+ *
63
+ * // Write to file
64
+ * fs.writeFileSync("openapi.json", JSON.stringify(spec, null, 2));
65
+ * ```
66
+ */
67
+ declare function generateOpenAPISpec(registry: CrudRepoRegistry, basePath: string, options?: OpenAPISpecOptions): OpenAPIDocument;
68
+
69
+ export { type OpenAPIDocument as O, generateOpenAPISpec as g };
@@ -0,0 +1,69 @@
1
+ import { s as CrudRepoRegistry, O as OpenAPISpecOptions } from './types-Z9Qy8Xmx.cjs';
2
+
3
+ /**
4
+ * OpenAPI 3.1 specification generator for the CRUD server.
5
+ *
6
+ * Introspects each `CrudRepoEntry` and uses Zod 4's native `z.toJSONSchema()`
7
+ * to produce a fully typed OpenAPI document ready for Scalar UI or codegen.
8
+ *
9
+ * @module servers/crud/openapi
10
+ */
11
+
12
+ /** Minimal subset of an OpenAPI 3.1 document we produce. */
13
+ interface OpenAPIDocument {
14
+ openapi: "3.1.0";
15
+ info: OpenAPIInfo;
16
+ servers?: {
17
+ url: string;
18
+ description?: string;
19
+ }[];
20
+ paths: Record<string, Record<string, OpenAPIOperation>>;
21
+ components: {
22
+ schemas: Record<string, Record<string, unknown>>;
23
+ securitySchemes?: Record<string, Record<string, unknown>>;
24
+ };
25
+ security?: Record<string, string[]>[];
26
+ tags?: {
27
+ name: string;
28
+ description?: string;
29
+ }[];
30
+ }
31
+ interface OpenAPIInfo {
32
+ title: string;
33
+ version: string;
34
+ description?: string;
35
+ }
36
+ interface OpenAPIOperation {
37
+ operationId: string;
38
+ summary: string;
39
+ tags: string[];
40
+ parameters?: Record<string, unknown>[];
41
+ requestBody?: Record<string, unknown>;
42
+ responses: Record<string, Record<string, unknown>>;
43
+ security?: Record<string, string[]>[];
44
+ }
45
+ /**
46
+ * Generate a full OpenAPI 3.1 specification from a `CrudRepoRegistry`.
47
+ *
48
+ * Uses Zod 4's native `z.toJSONSchema()` to convert each repo's schema
49
+ * into a JSON Schema component, then assembles paths for the standard
50
+ * CRUD endpoints.
51
+ *
52
+ * @example
53
+ * ```ts
54
+ * import { generateOpenAPISpec } from "@lpdjs/firestore-repo-service/servers/crud";
55
+ *
56
+ * const spec = generateOpenAPISpec(registry, "/api", {
57
+ * title: "My API",
58
+ * version: "1.0.0",
59
+ * servers: [{ url: "https://my-api.example.com" }],
60
+ * auth: "bearer",
61
+ * });
62
+ *
63
+ * // Write to file
64
+ * fs.writeFileSync("openapi.json", JSON.stringify(spec, null, 2));
65
+ * ```
66
+ */
67
+ declare function generateOpenAPISpec(registry: CrudRepoRegistry, basePath: string, options?: OpenAPISpecOptions): OpenAPIDocument;
68
+
69
+ export { type OpenAPIDocument as O, generateOpenAPISpec as g };
@@ -0,0 +1,52 @@
1
+ import { a as SqlAdapter, S as SyncEvent } from './types-CX5AbZWV.js';
2
+
3
+ /**
4
+ * Per-repo in-memory batch buffer.
5
+ *
6
+ * Accumulates {@link SyncEvent}s and flushes them in batches to a
7
+ * {@link SqlAdapter}. On flush failure the events are re-published
8
+ * to PubSub for retry (if a PubSub re-publisher is provided).
9
+ */
10
+
11
+ interface SyncQueueOptions {
12
+ /** SQL adapter to flush data to */
13
+ adapter: SqlAdapter;
14
+ /** SQL table name */
15
+ tableName: string;
16
+ /** Primary key column name */
17
+ primaryKey: string;
18
+ /** Max rows per flush (default: 100) */
19
+ batchSize?: number;
20
+ /** Auto-flush interval in ms (default: 5_000). 0 = manual only. */
21
+ flushIntervalMs?: number;
22
+ /** Called on flush failure with the failed events. Typically re-publishes to PubSub. */
23
+ onFlushError?: (events: SyncEvent[], error: unknown) => Promise<void>;
24
+ }
25
+ /**
26
+ * In-memory buffer that batches sync events per-repo and flushes them
27
+ * to a SQL adapter.
28
+ */
29
+ declare class SyncQueue {
30
+ private buffer;
31
+ private flushing;
32
+ private timer;
33
+ private readonly adapter;
34
+ private readonly tableName;
35
+ private readonly primaryKey;
36
+ private readonly batchSize;
37
+ private readonly onFlushError?;
38
+ constructor(opts: SyncQueueOptions);
39
+ /** Number of events waiting in the buffer. */
40
+ get size(): number;
41
+ /** Push one or more events into the buffer. Triggers auto-flush if batchSize reached. */
42
+ enqueue(...events: SyncEvent[]): void;
43
+ /**
44
+ * Flush all buffered events to the SQL adapter.
45
+ * Upserts and deletes are batched separately.
46
+ */
47
+ flush(): Promise<void>;
48
+ /** Stop the auto-flush timer and flush remaining events. */
49
+ shutdown(): Promise<void>;
50
+ }
51
+
52
+ export { SyncQueue as S, type SyncQueueOptions as a };
@@ -0,0 +1,52 @@
1
+ import { a as SqlAdapter, S as SyncEvent } from './types-CX5AbZWV.cjs';
2
+
3
+ /**
4
+ * Per-repo in-memory batch buffer.
5
+ *
6
+ * Accumulates {@link SyncEvent}s and flushes them in batches to a
7
+ * {@link SqlAdapter}. On flush failure the events are re-published
8
+ * to PubSub for retry (if a PubSub re-publisher is provided).
9
+ */
10
+
11
+ interface SyncQueueOptions {
12
+ /** SQL adapter to flush data to */
13
+ adapter: SqlAdapter;
14
+ /** SQL table name */
15
+ tableName: string;
16
+ /** Primary key column name */
17
+ primaryKey: string;
18
+ /** Max rows per flush (default: 100) */
19
+ batchSize?: number;
20
+ /** Auto-flush interval in ms (default: 5_000). 0 = manual only. */
21
+ flushIntervalMs?: number;
22
+ /** Called on flush failure with the failed events. Typically re-publishes to PubSub. */
23
+ onFlushError?: (events: SyncEvent[], error: unknown) => Promise<void>;
24
+ }
25
+ /**
26
+ * In-memory buffer that batches sync events per-repo and flushes them
27
+ * to a SQL adapter.
28
+ */
29
+ declare class SyncQueue {
30
+ private buffer;
31
+ private flushing;
32
+ private timer;
33
+ private readonly adapter;
34
+ private readonly tableName;
35
+ private readonly primaryKey;
36
+ private readonly batchSize;
37
+ private readonly onFlushError?;
38
+ constructor(opts: SyncQueueOptions);
39
+ /** Number of events waiting in the buffer. */
40
+ get size(): number;
41
+ /** Push one or more events into the buffer. Triggers auto-flush if batchSize reached. */
42
+ enqueue(...events: SyncEvent[]): void;
43
+ /**
44
+ * Flush all buffered events to the SQL adapter.
45
+ * Upserts and deletes are batched separately.
46
+ */
47
+ flush(): Promise<void>;
48
+ /** Stop the auto-flush timer and flush remaining events. */
49
+ shutdown(): Promise<void>;
50
+ }
51
+
52
+ export { SyncQueue as S, type SyncQueueOptions as a };
@@ -1,5 +1,5 @@
1
1
  import 'zod';
2
2
  import 'firebase-functions/v2/https';
3
- import '../../types-DKgWRTDf.cjs';
4
- export { A as AdminRepoConfig, a as AdminRepoEntry, b as AdminServerOptions, B as BasicAuthConfig, d as Middleware, M as MiniRouter, e as RepoRegistry, f as RouteHandler, c as createAdminServer } from '../../index-bqqrGjxe.cjs';
3
+ import '../../types-Z9Qy8Xmx.cjs';
4
+ export { A as AdminRepoConfig, a as AdminRepoEntry, b as AdminServerOptions, B as BasicAuthConfig, c as Middleware, M as MiniRouter, d as RepoRegistry, e as RouteHandler, f as createAdminServer } from '../../index-DpD4DEqH.cjs';
5
5
  import 'firebase-admin/firestore';
@@ -1,5 +1,5 @@
1
1
  import 'zod';
2
2
  import 'firebase-functions/v2/https';
3
- import '../../types-DKgWRTDf.js';
4
- export { A as AdminRepoConfig, a as AdminRepoEntry, b as AdminServerOptions, B as BasicAuthConfig, d as Middleware, M as MiniRouter, e as RepoRegistry, f as RouteHandler, c as createAdminServer } from '../../index-Bw1fvzu5.js';
3
+ import '../../types-Z9Qy8Xmx.js';
4
+ export { A as AdminRepoConfig, a as AdminRepoEntry, b as AdminServerOptions, B as BasicAuthConfig, c as Middleware, M as MiniRouter, d as RepoRegistry, e as RouteHandler, f as createAdminServer } from '../../index-Cvip2Sgt.js';
5
5
  import 'firebase-admin/firestore';