@lpdjs/firestore-repo-service 2.6.30 → 2.6.31

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/dist/index.d.cts CHANGED
@@ -1,17 +1,17 @@
1
1
  import { d as HistoryConfigForModel } from './read-CTWZjxyh.cjs';
2
2
  import { Query, QuerySnapshot, Firestore } from 'firebase-admin/firestore';
3
3
  import { z } from 'zod';
4
- import { h as QueryOptions, P as PaginationOptions, f as RepositoryConfig, i as RelationConfig, C as ConfiguredRepository } from './types-Qd4tuEq9.cjs';
5
- export { A as ApiResponse, b as CrudRepoConfig, a as CrudServerOptions, E as ExtractDocumentRefSignature, j as ExtractUpdateSignature, g as FieldPath, F as FieldRole, t as GenerateGetMethods, u as GenerateQueryMethods, G as GetOptions, k as GetResult, I as IncludeConfigTyped, L as ListResponseData, o as PaginationResult, v as PaginationWithIncludeOptionsTyped, w as PopulateOptionsTyped, Q as QueryRequestBody, l as RelationalKeys, R as RepoFieldPath, e as RepoRelationKeys, p as SystemBackfillFailure, q as SystemBackfillOptions, r as SystemBackfillResult, U as UserFieldPath, W as WhereClause, m as createPaginationIterator, n as executePaginatedQuery } from './types-Qd4tuEq9.cjs';
6
- export { B as BoundAdminRepoConfig, a as BoundAdminServerOptions, b as BoundCrudRepoConfig, d as BoundCrudServerOptions, e as BoundFirestoreSyncConfig, C as CreateServersDeps, c as createServers } from './create-servers-C3CIViuc.cjs';
7
- export { a as AdminRepoConfig, b as AdminRepoEntry, A as AdminServerOptions, B as BasicAuthConfig } from './index-D0KRndyL.cjs';
4
+ import { h as QueryOptions, P as PaginationOptions, f as RepositoryConfig, i as RelationConfig, C as ConfiguredRepository } from './types-CpkQQn4b.cjs';
5
+ export { A as ApiResponse, b as CrudRepoConfig, a as CrudServerOptions, E as ExtractDocumentRefSignature, j as ExtractUpdateSignature, g as FieldPath, F as FieldRole, t as GenerateGetMethods, u as GenerateQueryMethods, G as GetOptions, k as GetResult, I as IncludeConfigTyped, L as ListResponseData, o as PaginationResult, v as PaginationWithIncludeOptionsTyped, w as PopulateOptionsTyped, Q as QueryRequestBody, l as RelationalKeys, R as RepoFieldPath, e as RepoRelationKeys, p as SystemBackfillFailure, q as SystemBackfillOptions, r as SystemBackfillResult, U as UserFieldPath, W as WhereClause, m as createPaginationIterator, n as executePaginatedQuery } from './types-CpkQQn4b.cjs';
6
+ export { B as BoundAdminRepoConfig, a as BoundAdminServerOptions, b as BoundCrudRepoConfig, d as BoundCrudServerOptions, e as BoundFirestoreSyncConfig, C as CreateServersDeps, c as createServers } from './create-servers-DlVgnO_m.cjs';
7
+ export { a as AdminRepoConfig, b as AdminRepoEntry, A as AdminServerOptions, B as BasicAuthConfig } from './index-BfTEw4r1.cjs';
8
8
  export { M as MiniRouter } from './firebase-auth-DZ8lb2Ec.cjs';
9
9
  import 'firebase-functions/v2/firestore';
10
10
  import 'firebase-functions/v2/https';
11
11
  import './queue-CQyWCQBk.cjs';
12
12
  import './types-BwH1C-wi.cjs';
13
13
  import 'firebase-functions/v2/pubsub';
14
- import './openapi-BdatGOqK.cjs';
14
+ import './openapi-BHW1HViI.cjs';
15
15
 
16
16
  /**
17
17
  * Apply QueryOptions to a Firestore query.
@@ -162,7 +162,13 @@ type ResolveRelation<TMapping, TRelationConfig> = TRelationConfig extends {
162
162
  *
163
163
  * const mappingWithRelations = buildRepositoryRelations(mapping, {
164
164
  * posts: {
165
- * userId: { repo: "users", key: "docId", type: "one" as const }
165
+ * // Using the property name directly as the relation key (sourceKey is inferred)
166
+ * userId: { repo: "users", key: "docId", type: "one" }
167
+ * },
168
+ * users: {
169
+ * // Using an arbitrary name with a specific sourceKey (useful for multiple relations from same field)
170
+ * userPosts: { repo: "posts", key: "userId", type: "many", sourceKey: "docId" },
171
+ * userDrafts: { repo: "posts", key: "userId", type: "many", sourceKey: "docId" }
166
172
  * }
167
173
  * });
168
174
  *
@@ -171,17 +177,25 @@ type ResolveRelation<TMapping, TRelationConfig> = TRelationConfig extends {
171
177
  */
172
178
  declare function buildRepositoryRelations<TMapping extends Record<string, any>, const TRelations extends {
173
179
  [K in keyof TMapping]?: TMapping[K] extends RepositoryConfig<infer T, any, any, any, any, any, any, any, any, any, any> ? {
174
- [RK in keyof TRelations[K]]?: RK extends keyof T ? {
175
- [R in keyof TMapping]: TMapping[R] extends RepositoryConfig<infer TTargetModel, infer TForeignKeys extends readonly any[], infer TQueryKeys extends readonly any[], any, any, any, any, any, any, any, any> ? ({
180
+ [RK in keyof TRelations[K]]?: {
181
+ [R in keyof TMapping]: TMapping[R] extends RepositoryConfig<infer TTargetModel, infer TForeignKeys extends readonly any[], infer TQueryKeys extends readonly any[], any, any, any, any, any, any, any, any> ? (({
176
182
  repo: R;
177
183
  key: TForeignKeys[number];
178
184
  type: "one";
179
- } | {
185
+ } & (RK extends keyof T ? {
186
+ sourceKey?: keyof T;
187
+ } : {
188
+ sourceKey: keyof T;
189
+ })) | ({
180
190
  repo: R;
181
191
  key: TQueryKeys[number];
182
192
  type: "many";
183
- }) : never;
184
- }[keyof TMapping] : never;
193
+ } & (RK extends keyof T ? {
194
+ sourceKey?: keyof T;
195
+ } : {
196
+ sourceKey: keyof T;
197
+ }))) : never;
198
+ }[keyof TMapping];
185
199
  } : never;
186
200
  }>(mapping: TMapping, relations: TRelations): {
187
201
  [K in keyof TMapping]: K extends keyof TRelations ? TMapping[K] extends RepositoryConfig<infer T, infer TForeignKeys, infer TQueryKeys, infer TIsGroup, infer TRefCb, any, infer TDocumentKey, infer TPathKey, infer TCreatedKey, infer TUpdatedKey, infer THistoryEnabled> ? RepositoryConfig<T, TForeignKeys, TQueryKeys, TIsGroup, TRefCb, {
package/dist/index.d.ts CHANGED
@@ -1,17 +1,17 @@
1
1
  import { d as HistoryConfigForModel } from './read-CTWZjxyh.js';
2
2
  import { Query, QuerySnapshot, Firestore } from 'firebase-admin/firestore';
3
3
  import { z } from 'zod';
4
- import { h as QueryOptions, P as PaginationOptions, f as RepositoryConfig, i as RelationConfig, C as ConfiguredRepository } from './types-wzqw45jH.js';
5
- export { A as ApiResponse, b as CrudRepoConfig, a as CrudServerOptions, E as ExtractDocumentRefSignature, j as ExtractUpdateSignature, g as FieldPath, F as FieldRole, t as GenerateGetMethods, u as GenerateQueryMethods, G as GetOptions, k as GetResult, I as IncludeConfigTyped, L as ListResponseData, o as PaginationResult, v as PaginationWithIncludeOptionsTyped, w as PopulateOptionsTyped, Q as QueryRequestBody, l as RelationalKeys, R as RepoFieldPath, e as RepoRelationKeys, p as SystemBackfillFailure, q as SystemBackfillOptions, r as SystemBackfillResult, U as UserFieldPath, W as WhereClause, m as createPaginationIterator, n as executePaginatedQuery } from './types-wzqw45jH.js';
6
- export { B as BoundAdminRepoConfig, a as BoundAdminServerOptions, b as BoundCrudRepoConfig, d as BoundCrudServerOptions, e as BoundFirestoreSyncConfig, C as CreateServersDeps, c as createServers } from './create-servers-O2stZ-yF.js';
7
- export { a as AdminRepoConfig, b as AdminRepoEntry, A as AdminServerOptions, B as BasicAuthConfig } from './index-TTSjUi4p.js';
4
+ import { h as QueryOptions, P as PaginationOptions, f as RepositoryConfig, i as RelationConfig, C as ConfiguredRepository } from './types-BcT92G9B.js';
5
+ export { A as ApiResponse, b as CrudRepoConfig, a as CrudServerOptions, E as ExtractDocumentRefSignature, j as ExtractUpdateSignature, g as FieldPath, F as FieldRole, t as GenerateGetMethods, u as GenerateQueryMethods, G as GetOptions, k as GetResult, I as IncludeConfigTyped, L as ListResponseData, o as PaginationResult, v as PaginationWithIncludeOptionsTyped, w as PopulateOptionsTyped, Q as QueryRequestBody, l as RelationalKeys, R as RepoFieldPath, e as RepoRelationKeys, p as SystemBackfillFailure, q as SystemBackfillOptions, r as SystemBackfillResult, U as UserFieldPath, W as WhereClause, m as createPaginationIterator, n as executePaginatedQuery } from './types-BcT92G9B.js';
6
+ export { B as BoundAdminRepoConfig, a as BoundAdminServerOptions, b as BoundCrudRepoConfig, d as BoundCrudServerOptions, e as BoundFirestoreSyncConfig, C as CreateServersDeps, c as createServers } from './create-servers-n4q5BhVK.js';
7
+ export { a as AdminRepoConfig, b as AdminRepoEntry, A as AdminServerOptions, B as BasicAuthConfig } from './index-Da_8eLPb.js';
8
8
  export { M as MiniRouter } from './firebase-auth-DZ8lb2Ec.js';
9
9
  import 'firebase-functions/v2/firestore';
10
10
  import 'firebase-functions/v2/https';
11
11
  import './queue-B4uwef6c.js';
12
12
  import './types-DT7Nypd_.js';
13
13
  import 'firebase-functions/v2/pubsub';
14
- import './openapi-uTAic4s0.js';
14
+ import './openapi-BupSdudk.js';
15
15
 
16
16
  /**
17
17
  * Apply QueryOptions to a Firestore query.
@@ -162,7 +162,13 @@ type ResolveRelation<TMapping, TRelationConfig> = TRelationConfig extends {
162
162
  *
163
163
  * const mappingWithRelations = buildRepositoryRelations(mapping, {
164
164
  * posts: {
165
- * userId: { repo: "users", key: "docId", type: "one" as const }
165
+ * // Using the property name directly as the relation key (sourceKey is inferred)
166
+ * userId: { repo: "users", key: "docId", type: "one" }
167
+ * },
168
+ * users: {
169
+ * // Using an arbitrary name with a specific sourceKey (useful for multiple relations from same field)
170
+ * userPosts: { repo: "posts", key: "userId", type: "many", sourceKey: "docId" },
171
+ * userDrafts: { repo: "posts", key: "userId", type: "many", sourceKey: "docId" }
166
172
  * }
167
173
  * });
168
174
  *
@@ -171,17 +177,25 @@ type ResolveRelation<TMapping, TRelationConfig> = TRelationConfig extends {
171
177
  */
172
178
  declare function buildRepositoryRelations<TMapping extends Record<string, any>, const TRelations extends {
173
179
  [K in keyof TMapping]?: TMapping[K] extends RepositoryConfig<infer T, any, any, any, any, any, any, any, any, any, any> ? {
174
- [RK in keyof TRelations[K]]?: RK extends keyof T ? {
175
- [R in keyof TMapping]: TMapping[R] extends RepositoryConfig<infer TTargetModel, infer TForeignKeys extends readonly any[], infer TQueryKeys extends readonly any[], any, any, any, any, any, any, any, any> ? ({
180
+ [RK in keyof TRelations[K]]?: {
181
+ [R in keyof TMapping]: TMapping[R] extends RepositoryConfig<infer TTargetModel, infer TForeignKeys extends readonly any[], infer TQueryKeys extends readonly any[], any, any, any, any, any, any, any, any> ? (({
176
182
  repo: R;
177
183
  key: TForeignKeys[number];
178
184
  type: "one";
179
- } | {
185
+ } & (RK extends keyof T ? {
186
+ sourceKey?: keyof T;
187
+ } : {
188
+ sourceKey: keyof T;
189
+ })) | ({
180
190
  repo: R;
181
191
  key: TQueryKeys[number];
182
192
  type: "many";
183
- }) : never;
184
- }[keyof TMapping] : never;
193
+ } & (RK extends keyof T ? {
194
+ sourceKey?: keyof T;
195
+ } : {
196
+ sourceKey: keyof T;
197
+ }))) : never;
198
+ }[keyof TMapping];
185
199
  } : never;
186
200
  }>(mapping: TMapping, relations: TRelations): {
187
201
  [K in keyof TMapping]: K extends keyof TRelations ? TMapping[K] extends RepositoryConfig<infer T, infer TForeignKeys, infer TQueryKeys, infer TIsGroup, infer TRefCb, any, infer TDocumentKey, infer TPathKey, infer TCreatedKey, infer TUpdatedKey, infer THistoryEnabled> ? RepositoryConfig<T, TForeignKeys, TQueryKeys, TIsGroup, TRefCb, {