@lpdjs/firestore-repo-service 3.0.12 → 3.0.13

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 (56) hide show
  1. package/README.md +27 -14
  2. package/dist/{create-servers-BaCe3x4U.d.ts → create-servers-Db1xUY2N.d.ts} +4 -4
  3. package/dist/{create-servers-C_UOfc_Z.d.cts → create-servers-LyRLAOh3.d.cts} +4 -4
  4. package/dist/history/index.cjs +1 -1
  5. package/dist/history/index.cjs.map +1 -1
  6. package/dist/history/index.js +1 -1
  7. package/dist/history/index.js.map +1 -1
  8. package/dist/index.cjs +62 -62
  9. package/dist/index.cjs.map +1 -1
  10. package/dist/index.d.cts +19 -15
  11. package/dist/index.d.ts +19 -15
  12. package/dist/index.js +62 -62
  13. package/dist/index.js.map +1 -1
  14. package/dist/llms-full.txt +36 -23
  15. package/dist/llms.txt +2 -2
  16. package/dist/{openapi-BJdsB8kh.d.ts → openapi-CNIA7QRw.d.ts} +1 -1
  17. package/dist/{openapi-D4xT2ilq.d.cts → openapi-QVpqnnes.d.cts} +1 -1
  18. package/dist/{queue-CVnFz30E.d.ts → queue-BEB-ujA3.d.ts} +1 -1
  19. package/dist/{queue-z04IR_Jq.d.cts → queue-CpHe6M5j.d.cts} +1 -1
  20. package/dist/{rules-CEYrlE4J.d.cts → rules-Bu2NB7Eb.d.cts} +1 -1
  21. package/dist/{rules-Dw-Pz8p3.d.ts → rules-Cafrkb9v.d.ts} +1 -1
  22. package/dist/servers/admin/index.cjs +26 -26
  23. package/dist/servers/admin/index.cjs.map +1 -1
  24. package/dist/servers/admin/index.d.cts +3 -1
  25. package/dist/servers/admin/index.d.ts +3 -1
  26. package/dist/servers/admin/index.js +26 -26
  27. package/dist/servers/admin/index.js.map +1 -1
  28. package/dist/servers/crud/index.cjs +2 -2
  29. package/dist/servers/crud/index.cjs.map +1 -1
  30. package/dist/servers/crud/index.d.cts +6 -6
  31. package/dist/servers/crud/index.d.ts +6 -6
  32. package/dist/servers/crud/index.js +2 -2
  33. package/dist/servers/crud/index.js.map +1 -1
  34. package/dist/servers/index.cjs +55 -55
  35. package/dist/servers/index.cjs.map +1 -1
  36. package/dist/servers/index.d.cts +8 -8
  37. package/dist/servers/index.d.ts +8 -8
  38. package/dist/servers/index.js +55 -55
  39. package/dist/servers/index.js.map +1 -1
  40. package/dist/sync/bigquery.d.cts +1 -1
  41. package/dist/sync/bigquery.d.ts +1 -1
  42. package/dist/sync/index.cjs +41 -41
  43. package/dist/sync/index.cjs.map +1 -1
  44. package/dist/sync/index.d.cts +5 -5
  45. package/dist/sync/index.d.ts +5 -5
  46. package/dist/sync/index.js +41 -41
  47. package/dist/sync/index.js.map +1 -1
  48. package/dist/sync/meilisearch.d.cts +1 -1
  49. package/dist/sync/meilisearch.d.ts +1 -1
  50. package/dist/{types-BFbzLuFf.d.cts → types-B51LYvQZ.d.cts} +48 -5
  51. package/dist/{types-DsTJZOfr.d.cts → types-CNseHqF7.d.cts} +4 -2
  52. package/dist/{types-Ds9DUc21.d.ts → types-Ci0dGbuW.d.ts} +48 -5
  53. package/dist/{types-fY1XOBeT.d.ts → types-DGQURFSq.d.ts} +1 -1
  54. package/dist/{types-YP53OtiU.d.ts → types-DmXW_fVz.d.ts} +4 -2
  55. package/dist/{types-_lql12Ez.d.cts → types-VVuLlmfc.d.cts} +1 -1
  56. package/package.json +1 -1
@@ -4,7 +4,7 @@ import '../firebase-auth-nG3prKoj.cjs';
4
4
  import 'firebase-functions/v2/firestore';
5
5
  import 'firebase-functions/v2/https';
6
6
  import 'firebase-functions/v2/pubsub';
7
- import '../types-BFbzLuFf.cjs';
7
+ import '../types-B51LYvQZ.cjs';
8
8
  import '../types--RamYGF1.cjs';
9
9
  import 'firebase-admin/firestore';
10
10
 
@@ -4,7 +4,7 @@ import '../firebase-auth-nG3prKoj.js';
4
4
  import 'firebase-functions/v2/firestore';
5
5
  import 'firebase-functions/v2/https';
6
6
  import 'firebase-functions/v2/pubsub';
7
- import '../types-Ds9DUc21.js';
7
+ import '../types-Ci0dGbuW.js';
8
8
  import '../types--RamYGF1.js';
9
9
  import 'firebase-admin/firestore';
10
10
 
@@ -7,6 +7,36 @@ import { DocumentReference, Firestore, DocumentSnapshot, WhereFilterOp } from 'f
7
7
  * @internal
8
8
  */
9
9
  type ExtractDocumentRefSignature<T> = T extends (db: Firestore, ...args: infer P) => DocumentReference ? (...args: P) => DocumentReference : never;
10
+ /**
11
+ * Extract all `{param}` names from a path template string in left-to-right order.
12
+ * @example ExtractPathParams<"prevention/prev_rules/prev_workshops/{workshopId}/prev_events"> // ["workshopId"]
13
+ */
14
+ type ExtractPathParams<TPath extends string> = string extends TPath ? [] : TPath extends `${string}{${infer Param}}${infer Rest}` ? [Param, ...ExtractPathParams<Rest>] : [];
15
+ /**
16
+ * Extract dynamic parent key names from a path template (strips trailing `/{documentKey}` if present).
17
+ */
18
+ type ExtractParentParams<TPath extends string, TDocumentKey extends string> = ExtractPathParams<TPath> extends [
19
+ ...infer Parents extends string[],
20
+ TDocumentKey
21
+ ] ? Parents : ExtractPathParams<TPath>;
22
+ /**
23
+ * Detect `{param}` names in `TPath` that are not valid keys of `TModel`.
24
+ */
25
+ type InvalidPathParams<TPath extends string, TModel> = Exclude<ExtractPathParams<TPath>[number], keyof TModel & string>;
26
+ /**
27
+ * Constrain `TPath` so every `{param}` placeholder must be a strict `keyof TModel`.
28
+ */
29
+ type ValidatedPath<TPath extends string, TModel> = string extends TPath ? TPath : [InvalidPathParams<TPath, TModel>] extends [never] ? TPath : `Invalid path parameter(s): {${InvalidPathParams<TPath, TModel>}} — must be keyof model (${keyof TModel & string})`;
30
+ /**
31
+ * Convert an ordered tuple of parent key names into a positional string parameter tuple followed by `docId: string`.
32
+ * @internal
33
+ */
34
+ type PathParamsToArgsTuple<TParams extends readonly string[]> = [
35
+ ...{
36
+ [I in keyof TParams]: string;
37
+ },
38
+ docId: string
39
+ ];
10
40
  /**
11
41
  * `true` when `T` is `any` (the `0 extends (1 & T)` trick).
12
42
  * @internal
@@ -203,8 +233,8 @@ type RelationalKeys<T = any, TMapping = any> = {
203
233
  * @template TCreatedKey - The field name to store the creation timestamp (optional)
204
234
  * @template TUpdatedKey - The field name to store the update timestamp (optional)
205
235
  */
206
- interface RepositoryConfig<T, TForeignKeys extends readonly (keyof T)[], TQueryKeys extends readonly (keyof T)[], TIsGroup extends boolean = boolean, TRefCb = any, TRelationalKeys = {}, TDocumentKey extends keyof T = keyof T, TPathKey extends keyof T | undefined = undefined, TCreatedKey extends keyof T | undefined = undefined, TUpdatedKey extends keyof T | undefined = undefined, THistoryEnabled extends boolean = false> {
207
- path: string;
236
+ interface RepositoryConfig<T, TForeignKeys extends readonly (keyof T)[], TQueryKeys extends readonly (keyof T)[], TIsGroup extends boolean = boolean, TRefCb = any, TRelationalKeys = {}, TDocumentKey extends keyof T = keyof T, TPathKey extends keyof T | undefined = undefined, TCreatedKey extends keyof T | undefined = undefined, TUpdatedKey extends keyof T | undefined = undefined, THistoryEnabled extends boolean = false, TPath extends string = string> {
237
+ path: TPath;
208
238
  isGroup: TIsGroup;
209
239
  foreignKeys: TForeignKeys;
210
240
  queryKeys: TQueryKeys;
@@ -215,6 +245,10 @@ interface RepositoryConfig<T, TForeignKeys extends readonly (keyof T)[], TQueryK
215
245
  type: T;
216
246
  /** Zod schema attached when using createRepositoryConfig(schema)(config). Used by the admin server. */
217
247
  schema?: zod.ZodObject<any>;
248
+ /**
249
+ * @deprecated `refCb` is no longer needed — `documentRef` is automatically generated from `path`
250
+ * (e.g. `path: "residences/{residenceId}/res_events"`). Kept optional for backward compatibility.
251
+ */
218
252
  refCb?: TRefCb;
219
253
  relationalKeys?: TRelationalKeys;
220
254
  /**
@@ -227,8 +261,17 @@ interface RepositoryConfig<T, TForeignKeys extends readonly (keyof T)[], TQueryK
227
261
  history?: HistoryConfigForModel<T> & {
228
262
  enabled: THistoryEnabled;
229
263
  };
230
- documentRef: TRefCb extends undefined ? TIsGroup extends true ? (...pathSegments: string[]) => DocumentReference : (docId: string) => DocumentReference : ExtractDocumentRefSignature<TRefCb>;
231
- update: TRefCb extends undefined ? TIsGroup extends true ? (...args: [...string[], DeepPartial<T> & DotNotationUpdate<T>]) => Promise<T> : (docId: string, data: DeepPartial<T> & DotNotationUpdate<T>) => Promise<T> : ExtractUpdateSignature<TRefCb, T>;
264
+ documentRef: TRefCb extends undefined ? ExtractParentParams<TPath, TDocumentKey & string> extends [
265
+ string,
266
+ ...string[]
267
+ ] ? (...args: PathParamsToArgsTuple<ExtractParentParams<TPath, TDocumentKey & string>>) => DocumentReference : TIsGroup extends true ? (...pathSegments: string[]) => DocumentReference : (docId: string) => DocumentReference : ExtractDocumentRefSignature<TRefCb>;
268
+ update: TRefCb extends undefined ? ExtractParentParams<TPath, TDocumentKey & string> extends [
269
+ string,
270
+ ...string[]
271
+ ] ? (...args: [
272
+ ...PathParamsToArgsTuple<ExtractParentParams<TPath, TDocumentKey & string>>,
273
+ DeepPartial<T> & DotNotationUpdate<T>
274
+ ]) => Promise<T> : TIsGroup extends true ? (...args: [...string[], DeepPartial<T> & DotNotationUpdate<T>]) => Promise<T> : (docId: string, data: DeepPartial<T> & DotNotationUpdate<T>) => Promise<T> : ExtractUpdateSignature<TRefCb, T>;
232
275
  }
233
276
 
234
- export type { DeepPartial as D, ExtractDocumentRefSignature as E, FieldPath as F, GetOptions as G, QueryOptions as Q, RepositoryConfig as R, WhereClause as W, RelationConfig as a, DotNotationUpdate as b, ExtractUpdateSignature as c, GetResult as d, RelationalKeys as e, ExtractReturnDoc as f };
277
+ export type { DeepPartial as D, ExtractDocumentRefSignature as E, FieldPath as F, GetOptions as G, InvalidPathParams as I, PathParamsToArgsTuple as P, QueryOptions as Q, RepositoryConfig as R, ValidatedPath as V, WhereClause as W, RelationConfig as a, DotNotationUpdate as b, ExtractParentParams as c, ExtractPathParams as d, ExtractUpdateSignature as e, GetResult as f, RelationalKeys as g, ExtractReturnDoc as h };
@@ -4,7 +4,7 @@ import { z } from 'zod';
4
4
  import { HttpsOptions } from 'firebase-functions/v2/https';
5
5
  import { H as HistoryMethods } from './read-B15YaPyR.cjs';
6
6
  import { DocumentSnapshot, Query, CollectionReference, WriteBatch, Transaction, DocumentReference } from 'firebase-admin/firestore';
7
- import { Q as QueryOptions, R as RepositoryConfig, G as GetOptions, d as GetResult, f as ExtractReturnDoc, a as RelationConfig, D as DeepPartial, b as DotNotationUpdate, F as FieldPath } from './types-BFbzLuFf.cjs';
7
+ import { Q as QueryOptions, R as RepositoryConfig, G as GetOptions, f as GetResult, h as ExtractReturnDoc, a as RelationConfig, D as DeepPartial, b as DotNotationUpdate, F as FieldPath } from './types-B51LYvQZ.cjs';
8
8
 
9
9
  /**
10
10
  * Pagination result with data and cursor information
@@ -802,8 +802,10 @@ interface CrudRepoEntry {
802
802
  pathKey?: string;
803
803
  /** Whether this repo is a collection group (subcollection) */
804
804
  isGroup?: boolean;
805
- /** Parent key field names needed to build a subcollection document ref (auto-detected from refCb) */
805
+ /** Parent key field names needed to build a subcollection document ref (auto-detected from path template or refCb) */
806
806
  parentKeys?: string[];
807
+ /** Full Firestore document path pattern with `{param}` placeholders */
808
+ documentPathTemplate?: string;
807
809
  /** Field name for the creation timestamp (auto-set on create) */
808
810
  createdKey?: string;
809
811
  pageSize: number;
@@ -7,6 +7,36 @@ import { DocumentReference, Firestore, DocumentSnapshot, WhereFilterOp } from 'f
7
7
  * @internal
8
8
  */
9
9
  type ExtractDocumentRefSignature<T> = T extends (db: Firestore, ...args: infer P) => DocumentReference ? (...args: P) => DocumentReference : never;
10
+ /**
11
+ * Extract all `{param}` names from a path template string in left-to-right order.
12
+ * @example ExtractPathParams<"prevention/prev_rules/prev_workshops/{workshopId}/prev_events"> // ["workshopId"]
13
+ */
14
+ type ExtractPathParams<TPath extends string> = string extends TPath ? [] : TPath extends `${string}{${infer Param}}${infer Rest}` ? [Param, ...ExtractPathParams<Rest>] : [];
15
+ /**
16
+ * Extract dynamic parent key names from a path template (strips trailing `/{documentKey}` if present).
17
+ */
18
+ type ExtractParentParams<TPath extends string, TDocumentKey extends string> = ExtractPathParams<TPath> extends [
19
+ ...infer Parents extends string[],
20
+ TDocumentKey
21
+ ] ? Parents : ExtractPathParams<TPath>;
22
+ /**
23
+ * Detect `{param}` names in `TPath` that are not valid keys of `TModel`.
24
+ */
25
+ type InvalidPathParams<TPath extends string, TModel> = Exclude<ExtractPathParams<TPath>[number], keyof TModel & string>;
26
+ /**
27
+ * Constrain `TPath` so every `{param}` placeholder must be a strict `keyof TModel`.
28
+ */
29
+ type ValidatedPath<TPath extends string, TModel> = string extends TPath ? TPath : [InvalidPathParams<TPath, TModel>] extends [never] ? TPath : `Invalid path parameter(s): {${InvalidPathParams<TPath, TModel>}} — must be keyof model (${keyof TModel & string})`;
30
+ /**
31
+ * Convert an ordered tuple of parent key names into a positional string parameter tuple followed by `docId: string`.
32
+ * @internal
33
+ */
34
+ type PathParamsToArgsTuple<TParams extends readonly string[]> = [
35
+ ...{
36
+ [I in keyof TParams]: string;
37
+ },
38
+ docId: string
39
+ ];
10
40
  /**
11
41
  * `true` when `T` is `any` (the `0 extends (1 & T)` trick).
12
42
  * @internal
@@ -203,8 +233,8 @@ type RelationalKeys<T = any, TMapping = any> = {
203
233
  * @template TCreatedKey - The field name to store the creation timestamp (optional)
204
234
  * @template TUpdatedKey - The field name to store the update timestamp (optional)
205
235
  */
206
- interface RepositoryConfig<T, TForeignKeys extends readonly (keyof T)[], TQueryKeys extends readonly (keyof T)[], TIsGroup extends boolean = boolean, TRefCb = any, TRelationalKeys = {}, TDocumentKey extends keyof T = keyof T, TPathKey extends keyof T | undefined = undefined, TCreatedKey extends keyof T | undefined = undefined, TUpdatedKey extends keyof T | undefined = undefined, THistoryEnabled extends boolean = false> {
207
- path: string;
236
+ interface RepositoryConfig<T, TForeignKeys extends readonly (keyof T)[], TQueryKeys extends readonly (keyof T)[], TIsGroup extends boolean = boolean, TRefCb = any, TRelationalKeys = {}, TDocumentKey extends keyof T = keyof T, TPathKey extends keyof T | undefined = undefined, TCreatedKey extends keyof T | undefined = undefined, TUpdatedKey extends keyof T | undefined = undefined, THistoryEnabled extends boolean = false, TPath extends string = string> {
237
+ path: TPath;
208
238
  isGroup: TIsGroup;
209
239
  foreignKeys: TForeignKeys;
210
240
  queryKeys: TQueryKeys;
@@ -215,6 +245,10 @@ interface RepositoryConfig<T, TForeignKeys extends readonly (keyof T)[], TQueryK
215
245
  type: T;
216
246
  /** Zod schema attached when using createRepositoryConfig(schema)(config). Used by the admin server. */
217
247
  schema?: zod.ZodObject<any>;
248
+ /**
249
+ * @deprecated `refCb` is no longer needed — `documentRef` is automatically generated from `path`
250
+ * (e.g. `path: "residences/{residenceId}/res_events"`). Kept optional for backward compatibility.
251
+ */
218
252
  refCb?: TRefCb;
219
253
  relationalKeys?: TRelationalKeys;
220
254
  /**
@@ -227,8 +261,17 @@ interface RepositoryConfig<T, TForeignKeys extends readonly (keyof T)[], TQueryK
227
261
  history?: HistoryConfigForModel<T> & {
228
262
  enabled: THistoryEnabled;
229
263
  };
230
- documentRef: TRefCb extends undefined ? TIsGroup extends true ? (...pathSegments: string[]) => DocumentReference : (docId: string) => DocumentReference : ExtractDocumentRefSignature<TRefCb>;
231
- update: TRefCb extends undefined ? TIsGroup extends true ? (...args: [...string[], DeepPartial<T> & DotNotationUpdate<T>]) => Promise<T> : (docId: string, data: DeepPartial<T> & DotNotationUpdate<T>) => Promise<T> : ExtractUpdateSignature<TRefCb, T>;
264
+ documentRef: TRefCb extends undefined ? ExtractParentParams<TPath, TDocumentKey & string> extends [
265
+ string,
266
+ ...string[]
267
+ ] ? (...args: PathParamsToArgsTuple<ExtractParentParams<TPath, TDocumentKey & string>>) => DocumentReference : TIsGroup extends true ? (...pathSegments: string[]) => DocumentReference : (docId: string) => DocumentReference : ExtractDocumentRefSignature<TRefCb>;
268
+ update: TRefCb extends undefined ? ExtractParentParams<TPath, TDocumentKey & string> extends [
269
+ string,
270
+ ...string[]
271
+ ] ? (...args: [
272
+ ...PathParamsToArgsTuple<ExtractParentParams<TPath, TDocumentKey & string>>,
273
+ DeepPartial<T> & DotNotationUpdate<T>
274
+ ]) => Promise<T> : TIsGroup extends true ? (...args: [...string[], DeepPartial<T> & DotNotationUpdate<T>]) => Promise<T> : (docId: string, data: DeepPartial<T> & DotNotationUpdate<T>) => Promise<T> : ExtractUpdateSignature<TRefCb, T>;
232
275
  }
233
276
 
234
- export type { DeepPartial as D, ExtractDocumentRefSignature as E, FieldPath as F, GetOptions as G, QueryOptions as Q, RepositoryConfig as R, WhereClause as W, RelationConfig as a, DotNotationUpdate as b, ExtractUpdateSignature as c, GetResult as d, RelationalKeys as e, ExtractReturnDoc as f };
277
+ export type { DeepPartial as D, ExtractDocumentRefSignature as E, FieldPath as F, GetOptions as G, InvalidPathParams as I, PathParamsToArgsTuple as P, QueryOptions as Q, RepositoryConfig as R, ValidatedPath as V, WhereClause as W, RelationConfig as a, DotNotationUpdate as b, ExtractParentParams as c, ExtractPathParams as d, ExtractUpdateSignature as e, GetResult as f, RelationalKeys as g, ExtractReturnDoc as h };
@@ -3,7 +3,7 @@ import { onDocumentWritten, DocumentOptions } from 'firebase-functions/v2/firest
3
3
  import { onRequest, HttpsOptions } from 'firebase-functions/v2/https';
4
4
  import { onMessagePublished, PubSubOptions } from 'firebase-functions/v2/pubsub';
5
5
  import { z } from 'zod';
6
- import { F as FieldPath } from './types-Ds9DUc21.js';
6
+ import { F as FieldPath } from './types-Ci0dGbuW.js';
7
7
 
8
8
  /**
9
9
  * Cloud Functions v2 options forwarded to `onDocumentWritten()` for every
@@ -4,7 +4,7 @@ import { z } from 'zod';
4
4
  import { HttpsOptions } from 'firebase-functions/v2/https';
5
5
  import { H as HistoryMethods } from './read-15-TcgCz.js';
6
6
  import { DocumentSnapshot, Query, CollectionReference, WriteBatch, Transaction, DocumentReference } from 'firebase-admin/firestore';
7
- import { Q as QueryOptions, R as RepositoryConfig, G as GetOptions, d as GetResult, f as ExtractReturnDoc, a as RelationConfig, D as DeepPartial, b as DotNotationUpdate, F as FieldPath } from './types-Ds9DUc21.js';
7
+ import { Q as QueryOptions, R as RepositoryConfig, G as GetOptions, f as GetResult, h as ExtractReturnDoc, a as RelationConfig, D as DeepPartial, b as DotNotationUpdate, F as FieldPath } from './types-Ci0dGbuW.js';
8
8
 
9
9
  /**
10
10
  * Pagination result with data and cursor information
@@ -802,8 +802,10 @@ interface CrudRepoEntry {
802
802
  pathKey?: string;
803
803
  /** Whether this repo is a collection group (subcollection) */
804
804
  isGroup?: boolean;
805
- /** Parent key field names needed to build a subcollection document ref (auto-detected from refCb) */
805
+ /** Parent key field names needed to build a subcollection document ref (auto-detected from path template or refCb) */
806
806
  parentKeys?: string[];
807
+ /** Full Firestore document path pattern with `{param}` placeholders */
808
+ documentPathTemplate?: string;
807
809
  /** Field name for the creation timestamp (auto-set on create) */
808
810
  createdKey?: string;
809
811
  pageSize: number;
@@ -3,7 +3,7 @@ import { onDocumentWritten, DocumentOptions } from 'firebase-functions/v2/firest
3
3
  import { onRequest, HttpsOptions } from 'firebase-functions/v2/https';
4
4
  import { onMessagePublished, PubSubOptions } from 'firebase-functions/v2/pubsub';
5
5
  import { z } from 'zod';
6
- import { F as FieldPath } from './types-BFbzLuFf.cjs';
6
+ import { F as FieldPath } from './types-B51LYvQZ.cjs';
7
7
 
8
8
  /**
9
9
  * Cloud Functions v2 options forwarded to `onDocumentWritten()` for every
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@lpdjs/firestore-repo-service",
3
- "version": "3.0.12",
3
+ "version": "3.0.13",
4
4
  "workspaces": [
5
5
  "test/functions"
6
6
  ],