@lpdjs/firestore-repo-service 2.6.30 → 2.6.32

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.
@@ -133,6 +133,7 @@ interface RelationConfig<TRepoKey extends string = string, TForeignKey extends s
133
133
  repo: TRepoKey;
134
134
  key: TForeignKey;
135
135
  type: TType;
136
+ sourceKey?: string;
136
137
  targetType?: TTargetModel;
137
138
  }
138
139
  /**
@@ -141,17 +142,21 @@ interface RelationConfig<TRepoKey extends string = string, TForeignKey extends s
141
142
  * @template T - Current model type
142
143
  * @template TMapping - All repositories mapping for validation
143
144
  * @example { userId: { repo: "users", key: "docId", type: "one" } }
144
- *
145
- * IMPORTANT: Keys must exist in T (the current model)
146
- * This prevents creating relations on non-existent fields
145
+ * @example { events: { repo: "events", key: "residenceId", type: "many", sourceKey: "docId" } }
147
146
  */
148
147
  type RelationalKeys<T = any, TMapping = any> = {
149
- [K in keyof T]?: TMapping extends Record<string, any> ? {
150
- [R in keyof TMapping]: TMapping[R] extends RepositoryConfig<any, infer FKeys, any, any, any, any, any, any, any, any, any> ? {
148
+ [K in string]?: TMapping extends Record<string, any> ? {
149
+ [R in keyof TMapping]: TMapping[R] extends RepositoryConfig<any, infer FKeys extends readonly any[], infer QKeys extends readonly any[], any, any, any, any, any, any, any, any> ? ({
151
150
  repo: R;
152
151
  key: FKeys[number];
153
- type: "one" | "many";
154
- } : never;
152
+ type: "one";
153
+ sourceKey?: keyof T;
154
+ } | {
155
+ repo: R;
156
+ key: QKeys[number];
157
+ type: "many";
158
+ sourceKey?: keyof T;
159
+ }) : never;
155
160
  }[keyof TMapping] : RelationConfig;
156
161
  };
157
162
  /**
@@ -133,6 +133,7 @@ interface RelationConfig<TRepoKey extends string = string, TForeignKey extends s
133
133
  repo: TRepoKey;
134
134
  key: TForeignKey;
135
135
  type: TType;
136
+ sourceKey?: string;
136
137
  targetType?: TTargetModel;
137
138
  }
138
139
  /**
@@ -141,17 +142,21 @@ interface RelationConfig<TRepoKey extends string = string, TForeignKey extends s
141
142
  * @template T - Current model type
142
143
  * @template TMapping - All repositories mapping for validation
143
144
  * @example { userId: { repo: "users", key: "docId", type: "one" } }
144
- *
145
- * IMPORTANT: Keys must exist in T (the current model)
146
- * This prevents creating relations on non-existent fields
145
+ * @example { events: { repo: "events", key: "residenceId", type: "many", sourceKey: "docId" } }
147
146
  */
148
147
  type RelationalKeys<T = any, TMapping = any> = {
149
- [K in keyof T]?: TMapping extends Record<string, any> ? {
150
- [R in keyof TMapping]: TMapping[R] extends RepositoryConfig<any, infer FKeys, any, any, any, any, any, any, any, any, any> ? {
148
+ [K in string]?: TMapping extends Record<string, any> ? {
149
+ [R in keyof TMapping]: TMapping[R] extends RepositoryConfig<any, infer FKeys extends readonly any[], infer QKeys extends readonly any[], any, any, any, any, any, any, any, any> ? ({
151
150
  repo: R;
152
151
  key: FKeys[number];
153
- type: "one" | "many";
154
- } : never;
152
+ type: "one";
153
+ sourceKey?: keyof T;
154
+ } | {
155
+ repo: R;
156
+ key: QKeys[number];
157
+ type: "many";
158
+ sourceKey?: keyof T;
159
+ }) : never;
155
160
  }[keyof TMapping] : RelationConfig;
156
161
  };
157
162
  /**
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@lpdjs/firestore-repo-service",
3
- "version": "2.6.30",
3
+ "version": "2.6.32",
4
4
  "workspaces": [
5
5
  "test/functions"
6
6
  ],