@lpdjs/firestore-repo-service 2.2.7 → 2.2.8

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 (33) hide show
  1. package/dist/{create-servers-B3Ls46bx.d.cts → create-servers-BGtAS0oG.d.cts} +3 -3
  2. package/dist/{create-servers-CvVZnihM.d.ts → create-servers-DMszgNtg.d.ts} +3 -3
  3. package/dist/history/index.cjs +1 -1
  4. package/dist/history/index.cjs.map +1 -1
  5. package/dist/history/index.d.cts +3 -4
  6. package/dist/history/index.d.ts +3 -4
  7. package/dist/history/index.js +1 -1
  8. package/dist/history/index.js.map +1 -1
  9. package/dist/{index-Cw9b1crP.d.cts → index-BSZP0Gz9.d.ts} +3 -3
  10. package/dist/{index-DGB3Oemk.d.ts → index-D7oj3Pft.d.cts} +3 -3
  11. package/dist/index.cjs +1 -1
  12. package/dist/index.cjs.map +1 -1
  13. package/dist/index.d.cts +8 -8
  14. package/dist/index.d.ts +8 -8
  15. package/dist/index.js +1 -1
  16. package/dist/index.js.map +1 -1
  17. package/dist/{openapi-BEf4OuG9.d.ts → openapi-BdqIkSjO.d.ts} +1 -1
  18. package/dist/{openapi-D8UTm0lu.d.cts → openapi-lY43PZXy.d.cts} +1 -1
  19. package/dist/{read-DMvxeFCg.d.cts → read-DfXXxhO4.d.cts} +2 -4
  20. package/dist/{read-DMvxeFCg.d.ts → read-DfXXxhO4.d.ts} +2 -4
  21. package/dist/servers/admin/index.cjs.map +1 -1
  22. package/dist/servers/admin/index.d.cts +3 -3
  23. package/dist/servers/admin/index.d.ts +3 -3
  24. package/dist/servers/admin/index.js.map +1 -1
  25. package/dist/servers/crud/index.d.cts +5 -5
  26. package/dist/servers/crud/index.d.ts +5 -5
  27. package/dist/servers/index.cjs.map +1 -1
  28. package/dist/servers/index.d.cts +6 -6
  29. package/dist/servers/index.d.ts +6 -6
  30. package/dist/servers/index.js.map +1 -1
  31. package/dist/{types-CjexXskS.d.ts → types-BESS89Fu.d.cts} +19 -18
  32. package/dist/{types-CE1dws32.d.cts → types-BVUFVcpl.d.ts} +19 -18
  33. package/package.json +4 -1
@@ -1,7 +1,7 @@
1
1
  import * as zod from 'zod';
2
2
  import { z } from 'zod';
3
3
  import { HttpsOptions } from 'firebase-functions/v2/https';
4
- import { H as HistoryConfigForModel, a as HistoryMethods } from './read-DMvxeFCg.js';
4
+ import { H as HistoryConfigForModel, a as HistoryMethods } from './read-DfXXxhO4.cjs';
5
5
  import { DocumentReference, Firestore, DocumentSnapshot, WhereFilterOp, Query, CollectionReference, WriteBatch, Transaction } from 'firebase-admin/firestore';
6
6
 
7
7
  /**
@@ -146,7 +146,7 @@ interface RelationConfig<TRepoKey extends string = string, TForeignKey extends s
146
146
  */
147
147
  type RelationalKeys<T = any, TMapping = any> = {
148
148
  [K in keyof T]?: TMapping extends Record<string, any> ? {
149
- [R in keyof TMapping]: TMapping[R] extends RepositoryConfig<any, infer FKeys, any, any, any, any, any, any> ? {
149
+ [R in keyof TMapping]: TMapping[R] extends RepositoryConfig<any, infer FKeys, any, any, any, any, any, any, any, any, any> ? {
150
150
  repo: R;
151
151
  key: FKeys[number];
152
152
  type: "one" | "many";
@@ -391,17 +391,17 @@ interface PaginationWithIncludeOptionsTyped<T, TRelationalKeys, K extends keyof
391
391
  * Helper type to get the system keys (documentKey + pathKey + updatedKey) that should be excluded from updates
392
392
  * @internal
393
393
  */
394
- type SystemKeys<T extends RepositoryConfig<any, any, any, any, any, any, any, any, any, any>> = T["documentKey"] | Extract<T["pathKey"], keyof T["type"]> | Extract<T["updatedKey"], keyof T["type"]>;
394
+ type SystemKeys<T extends RepositoryConfig<any, any, any, any, any, any, any, any, any, any, any>> = T["documentKey"] | Extract<T["pathKey"], keyof T["type"]> | Extract<T["updatedKey"], keyof T["type"]>;
395
395
  /**
396
396
  * Type for updatable data - excludes documentKey, pathKey and updatedKey (all auto-managed)
397
397
  * @internal
398
398
  */
399
- type UpdatableData<T extends RepositoryConfig<any, any, any, any, any, any, any, any, any, any>> = Omit<Partial<T["type"]>, SystemKeys<T>>;
399
+ type UpdatableData<T extends RepositoryConfig<any, any, any, any, any, any, any, any, any, any, any>> = Omit<Partial<T["type"]>, SystemKeys<T>>;
400
400
  /**
401
401
  * Type for create data - excludes pathKey, createdKey and updatedKey (auto-managed), documentKey is optional
402
402
  * @internal
403
403
  */
404
- type CreateData<T extends RepositoryConfig<any, any, any, any, any, any, any, any, any, any>> = Omit<T["type"], T["documentKey"] | Extract<T["pathKey"], keyof T["type"]> | Extract<T["createdKey"], keyof T["type"]> | Extract<T["updatedKey"], keyof T["type"]>> & {
404
+ type CreateData<T extends RepositoryConfig<any, any, any, any, any, any, any, any, any, any, any>> = Omit<T["type"], T["documentKey"] | Extract<T["pathKey"], keyof T["type"]> | Extract<T["createdKey"], keyof T["type"]> | Extract<T["updatedKey"], keyof T["type"]>> & {
405
405
  [K in T["documentKey"]]?: T["type"][K];
406
406
  };
407
407
  /**
@@ -424,7 +424,7 @@ type UnionToIntersection<U> = (U extends any ? (k: U) => void : never) extends (
424
424
  * Return type is narrowed based on whether returnDoc is true.
425
425
  * @internal
426
426
  */
427
- type GenerateGetMethods<TConfig extends RepositoryConfig<any, any, any, any, any, any, any, any, any, any>> = {
427
+ type GenerateGetMethods<TConfig extends RepositoryConfig<any, any, any, any, any, any, any, any, any, any, any>> = {
428
428
  [K in TConfig["foreignKeys"][number] as K extends string ? `by${Capitalize<K>}` : never]: <ReturnDoc extends boolean = false>(value: TConfig["type"][K extends keyof TConfig["type"] ? K : never], options?: ReturnDoc | (GetOptions<TConfig["type"]> & {
429
429
  returnDoc?: ReturnDoc;
430
430
  })) => Promise<GetResult<TConfig["type"], ReturnDoc>>;
@@ -433,7 +433,7 @@ type GenerateGetMethods<TConfig extends RepositoryConfig<any, any, any, any, any
433
433
  * Generates query.by* methods from query keys
434
434
  * @internal
435
435
  */
436
- type GenerateQueryMethods<TConfig extends RepositoryConfig<any, any, any, any, any, any, any, any, any, any>> = {
436
+ type GenerateQueryMethods<TConfig extends RepositoryConfig<any, any, any, any, any, any, any, any, any, any, any>> = {
437
437
  [K in TConfig["queryKeys"][number] as K extends string ? `by${Capitalize<K>}` : never]: (value: TConfig["type"][K], options?: QueryOptions<TConfig["type"]>) => Promise<TConfig["type"][]>;
438
438
  };
439
439
  /**
@@ -523,13 +523,14 @@ type ConfiguredRepository<T extends RepositoryConfig<any, any, any, any, any, an
523
523
  populate: <K extends keyof NonNullable<T["relationalKeys"]>, TDoc extends Pick<T["type"], K & keyof T["type"]>>(document: TDoc, relationKeyOrOptions: K | K[] | PopulateOptionsTyped<NonNullable<T["relationalKeys"]>, K>) => Promise<TDoc & {
524
524
  populated: UnionToIntersection<K extends keyof NonNullable<T["relationalKeys"]> ? ExtractPopulatedFromRelation<NonNullable<T["relationalKeys"]>[K], K & string> : Record<string, never>>;
525
525
  }>;
526
- } & (T extends {
527
- history: {
528
- enabled: true;
529
- };
530
- } ? {
531
- history: HistoryMethods<T["type"]>;
532
- } : {});
526
+ /**
527
+ * Change-history namespace. Present at the type level when the repo is
528
+ * configured with `history.enabled: true`, otherwise `undefined` at runtime.
529
+ * Kept optional (rather than conditional) so `ConfiguredRepository<any>`
530
+ * stays assignable from any concrete repo config.
531
+ */
532
+ history?: HistoryMethods<T["type"]>;
533
+ };
533
534
 
534
535
  /**
535
536
  * Type definitions for the CRUD API server.
@@ -562,13 +563,13 @@ interface OpenAPISpecOptions {
562
563
  * `createRepositoryConfig(schema)`).
563
564
  * @internal
564
565
  */
565
- type RepoModelType<TRepo> = TRepo extends ConfiguredRepository<infer C> ? C extends RepositoryConfig<infer T, any, any, any, any, any, any, any, any, any> ? T : never : never;
566
+ type RepoModelType<TRepo> = TRepo extends ConfiguredRepository<infer C> ? C extends RepositoryConfig<infer T, any, any, any, any, any, any, any, any, any, any> ? T : never : never;
566
567
  /**
567
568
  * Extracts the auto-managed system keys (documentKey, pathKey, createdKey, updatedKey)
568
569
  * from a `ConfiguredRepository`. These keys must never appear in create/update payloads.
569
570
  * @internal
570
571
  */
571
- type RepoSystemKeys<TRepo> = TRepo extends ConfiguredRepository<infer C> ? C extends RepositoryConfig<any, any, any, any, any, any, infer TDocKey, infer TPathKey, infer TCreatedKey, infer TUpdatedKey> ? (TDocKey extends string ? TDocKey : never) | (TPathKey extends string ? TPathKey : never) | (TCreatedKey extends string ? TCreatedKey : never) | (TUpdatedKey extends string ? TUpdatedKey : never) : never : never;
572
+ type RepoSystemKeys<TRepo> = TRepo extends ConfiguredRepository<infer C> ? C extends RepositoryConfig<any, any, any, any, any, any, infer TDocKey, infer TPathKey, infer TCreatedKey, infer TUpdatedKey, any> ? (TDocKey extends string ? TDocKey : never) | (TPathKey extends string ? TPathKey : never) | (TCreatedKey extends string ? TCreatedKey : never) | (TUpdatedKey extends string ? TUpdatedKey : never) : never : never;
572
573
  /**
573
574
  * `true` when `T` is `any` (the `0 extends (1 & T)` trick).
574
575
  * @internal
@@ -600,7 +601,7 @@ type RepoFieldPath<TRepo> = IsAny<TRepo> extends true ? string : IsAny<RepoModel
600
601
  * Falls back to `string` when `TRepo` is unresolved (`any`).
601
602
  * @internal
602
603
  */
603
- type RepoRelationKeys<TRepo> = IsAny<TRepo> extends true ? string : TRepo extends ConfiguredRepository<RepositoryConfig<any, any, any, any, any, infer TRelKeys, any, any, any, any>> ? IsAny<TRelKeys> extends true ? string : keyof TRelKeys & string : string;
604
+ type RepoRelationKeys<TRepo> = IsAny<TRepo> extends true ? string : TRepo extends ConfiguredRepository<RepositoryConfig<any, any, any, any, any, infer TRelKeys, any, any, any, any, any>> ? IsAny<TRelKeys> extends true ? string : keyof TRelKeys & string : string;
604
605
  /**
605
606
  * Configuration for a single repository in the CRUD server.
606
607
  *
@@ -667,7 +668,7 @@ interface CrudRepoConfig<TRepo extends ConfiguredRepository<any> = ConfiguredRep
667
668
  interface CrudRepoEntry {
668
669
  name: string;
669
670
  path: string;
670
- repo: ConfiguredRepository<RepositoryConfig<any, any, any, any, any, any, any, any, any, any>>;
671
+ repo: ConfiguredRepository<RepositoryConfig<any, any, any, any, any, any, any, any, any, any, any>>;
671
672
  schema: z.ZodObject<any>;
672
673
  /** Keys automatically managed by Firestore (docId, path, timestamps) — excluded from create/update payloads */
673
674
  systemKeys: string[];
@@ -1,7 +1,7 @@
1
1
  import * as zod from 'zod';
2
2
  import { z } from 'zod';
3
3
  import { HttpsOptions } from 'firebase-functions/v2/https';
4
- import { H as HistoryConfigForModel, a as HistoryMethods } from './read-DMvxeFCg.cjs';
4
+ import { H as HistoryConfigForModel, a as HistoryMethods } from './read-DfXXxhO4.js';
5
5
  import { DocumentReference, Firestore, DocumentSnapshot, WhereFilterOp, Query, CollectionReference, WriteBatch, Transaction } from 'firebase-admin/firestore';
6
6
 
7
7
  /**
@@ -146,7 +146,7 @@ interface RelationConfig<TRepoKey extends string = string, TForeignKey extends s
146
146
  */
147
147
  type RelationalKeys<T = any, TMapping = any> = {
148
148
  [K in keyof T]?: TMapping extends Record<string, any> ? {
149
- [R in keyof TMapping]: TMapping[R] extends RepositoryConfig<any, infer FKeys, any, any, any, any, any, any> ? {
149
+ [R in keyof TMapping]: TMapping[R] extends RepositoryConfig<any, infer FKeys, any, any, any, any, any, any, any, any, any> ? {
150
150
  repo: R;
151
151
  key: FKeys[number];
152
152
  type: "one" | "many";
@@ -391,17 +391,17 @@ interface PaginationWithIncludeOptionsTyped<T, TRelationalKeys, K extends keyof
391
391
  * Helper type to get the system keys (documentKey + pathKey + updatedKey) that should be excluded from updates
392
392
  * @internal
393
393
  */
394
- type SystemKeys<T extends RepositoryConfig<any, any, any, any, any, any, any, any, any, any>> = T["documentKey"] | Extract<T["pathKey"], keyof T["type"]> | Extract<T["updatedKey"], keyof T["type"]>;
394
+ type SystemKeys<T extends RepositoryConfig<any, any, any, any, any, any, any, any, any, any, any>> = T["documentKey"] | Extract<T["pathKey"], keyof T["type"]> | Extract<T["updatedKey"], keyof T["type"]>;
395
395
  /**
396
396
  * Type for updatable data - excludes documentKey, pathKey and updatedKey (all auto-managed)
397
397
  * @internal
398
398
  */
399
- type UpdatableData<T extends RepositoryConfig<any, any, any, any, any, any, any, any, any, any>> = Omit<Partial<T["type"]>, SystemKeys<T>>;
399
+ type UpdatableData<T extends RepositoryConfig<any, any, any, any, any, any, any, any, any, any, any>> = Omit<Partial<T["type"]>, SystemKeys<T>>;
400
400
  /**
401
401
  * Type for create data - excludes pathKey, createdKey and updatedKey (auto-managed), documentKey is optional
402
402
  * @internal
403
403
  */
404
- type CreateData<T extends RepositoryConfig<any, any, any, any, any, any, any, any, any, any>> = Omit<T["type"], T["documentKey"] | Extract<T["pathKey"], keyof T["type"]> | Extract<T["createdKey"], keyof T["type"]> | Extract<T["updatedKey"], keyof T["type"]>> & {
404
+ type CreateData<T extends RepositoryConfig<any, any, any, any, any, any, any, any, any, any, any>> = Omit<T["type"], T["documentKey"] | Extract<T["pathKey"], keyof T["type"]> | Extract<T["createdKey"], keyof T["type"]> | Extract<T["updatedKey"], keyof T["type"]>> & {
405
405
  [K in T["documentKey"]]?: T["type"][K];
406
406
  };
407
407
  /**
@@ -424,7 +424,7 @@ type UnionToIntersection<U> = (U extends any ? (k: U) => void : never) extends (
424
424
  * Return type is narrowed based on whether returnDoc is true.
425
425
  * @internal
426
426
  */
427
- type GenerateGetMethods<TConfig extends RepositoryConfig<any, any, any, any, any, any, any, any, any, any>> = {
427
+ type GenerateGetMethods<TConfig extends RepositoryConfig<any, any, any, any, any, any, any, any, any, any, any>> = {
428
428
  [K in TConfig["foreignKeys"][number] as K extends string ? `by${Capitalize<K>}` : never]: <ReturnDoc extends boolean = false>(value: TConfig["type"][K extends keyof TConfig["type"] ? K : never], options?: ReturnDoc | (GetOptions<TConfig["type"]> & {
429
429
  returnDoc?: ReturnDoc;
430
430
  })) => Promise<GetResult<TConfig["type"], ReturnDoc>>;
@@ -433,7 +433,7 @@ type GenerateGetMethods<TConfig extends RepositoryConfig<any, any, any, any, any
433
433
  * Generates query.by* methods from query keys
434
434
  * @internal
435
435
  */
436
- type GenerateQueryMethods<TConfig extends RepositoryConfig<any, any, any, any, any, any, any, any, any, any>> = {
436
+ type GenerateQueryMethods<TConfig extends RepositoryConfig<any, any, any, any, any, any, any, any, any, any, any>> = {
437
437
  [K in TConfig["queryKeys"][number] as K extends string ? `by${Capitalize<K>}` : never]: (value: TConfig["type"][K], options?: QueryOptions<TConfig["type"]>) => Promise<TConfig["type"][]>;
438
438
  };
439
439
  /**
@@ -523,13 +523,14 @@ type ConfiguredRepository<T extends RepositoryConfig<any, any, any, any, any, an
523
523
  populate: <K extends keyof NonNullable<T["relationalKeys"]>, TDoc extends Pick<T["type"], K & keyof T["type"]>>(document: TDoc, relationKeyOrOptions: K | K[] | PopulateOptionsTyped<NonNullable<T["relationalKeys"]>, K>) => Promise<TDoc & {
524
524
  populated: UnionToIntersection<K extends keyof NonNullable<T["relationalKeys"]> ? ExtractPopulatedFromRelation<NonNullable<T["relationalKeys"]>[K], K & string> : Record<string, never>>;
525
525
  }>;
526
- } & (T extends {
527
- history: {
528
- enabled: true;
529
- };
530
- } ? {
531
- history: HistoryMethods<T["type"]>;
532
- } : {});
526
+ /**
527
+ * Change-history namespace. Present at the type level when the repo is
528
+ * configured with `history.enabled: true`, otherwise `undefined` at runtime.
529
+ * Kept optional (rather than conditional) so `ConfiguredRepository<any>`
530
+ * stays assignable from any concrete repo config.
531
+ */
532
+ history?: HistoryMethods<T["type"]>;
533
+ };
533
534
 
534
535
  /**
535
536
  * Type definitions for the CRUD API server.
@@ -562,13 +563,13 @@ interface OpenAPISpecOptions {
562
563
  * `createRepositoryConfig(schema)`).
563
564
  * @internal
564
565
  */
565
- type RepoModelType<TRepo> = TRepo extends ConfiguredRepository<infer C> ? C extends RepositoryConfig<infer T, any, any, any, any, any, any, any, any, any> ? T : never : never;
566
+ type RepoModelType<TRepo> = TRepo extends ConfiguredRepository<infer C> ? C extends RepositoryConfig<infer T, any, any, any, any, any, any, any, any, any, any> ? T : never : never;
566
567
  /**
567
568
  * Extracts the auto-managed system keys (documentKey, pathKey, createdKey, updatedKey)
568
569
  * from a `ConfiguredRepository`. These keys must never appear in create/update payloads.
569
570
  * @internal
570
571
  */
571
- type RepoSystemKeys<TRepo> = TRepo extends ConfiguredRepository<infer C> ? C extends RepositoryConfig<any, any, any, any, any, any, infer TDocKey, infer TPathKey, infer TCreatedKey, infer TUpdatedKey> ? (TDocKey extends string ? TDocKey : never) | (TPathKey extends string ? TPathKey : never) | (TCreatedKey extends string ? TCreatedKey : never) | (TUpdatedKey extends string ? TUpdatedKey : never) : never : never;
572
+ type RepoSystemKeys<TRepo> = TRepo extends ConfiguredRepository<infer C> ? C extends RepositoryConfig<any, any, any, any, any, any, infer TDocKey, infer TPathKey, infer TCreatedKey, infer TUpdatedKey, any> ? (TDocKey extends string ? TDocKey : never) | (TPathKey extends string ? TPathKey : never) | (TCreatedKey extends string ? TCreatedKey : never) | (TUpdatedKey extends string ? TUpdatedKey : never) : never : never;
572
573
  /**
573
574
  * `true` when `T` is `any` (the `0 extends (1 & T)` trick).
574
575
  * @internal
@@ -600,7 +601,7 @@ type RepoFieldPath<TRepo> = IsAny<TRepo> extends true ? string : IsAny<RepoModel
600
601
  * Falls back to `string` when `TRepo` is unresolved (`any`).
601
602
  * @internal
602
603
  */
603
- type RepoRelationKeys<TRepo> = IsAny<TRepo> extends true ? string : TRepo extends ConfiguredRepository<RepositoryConfig<any, any, any, any, any, infer TRelKeys, any, any, any, any>> ? IsAny<TRelKeys> extends true ? string : keyof TRelKeys & string : string;
604
+ type RepoRelationKeys<TRepo> = IsAny<TRepo> extends true ? string : TRepo extends ConfiguredRepository<RepositoryConfig<any, any, any, any, any, infer TRelKeys, any, any, any, any, any>> ? IsAny<TRelKeys> extends true ? string : keyof TRelKeys & string : string;
604
605
  /**
605
606
  * Configuration for a single repository in the CRUD server.
606
607
  *
@@ -667,7 +668,7 @@ interface CrudRepoConfig<TRepo extends ConfiguredRepository<any> = ConfiguredRep
667
668
  interface CrudRepoEntry {
668
669
  name: string;
669
670
  path: string;
670
- repo: ConfiguredRepository<RepositoryConfig<any, any, any, any, any, any, any, any, any, any>>;
671
+ repo: ConfiguredRepository<RepositoryConfig<any, any, any, any, any, any, any, any, any, any, any>>;
671
672
  schema: z.ZodObject<any>;
672
673
  /** Keys automatically managed by Firestore (docId, path, timestamps) — excluded from create/update payloads */
673
674
  systemKeys: string[];
package/package.json CHANGED
@@ -1,6 +1,9 @@
1
1
  {
2
2
  "name": "@lpdjs/firestore-repo-service",
3
- "version": "2.2.7",
3
+ "version": "2.2.8",
4
+ "workspaces": [
5
+ "test/functions"
6
+ ],
4
7
  "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
8
  "type": "module",
6
9
  "main": "./dist/index.cjs",