@lpdjs/firestore-repo-service 2.2.5 → 2.2.7
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/{create-servers-DmggzSb3.d.cts → create-servers-B3Ls46bx.d.cts} +3 -3
- package/dist/{create-servers-D4-NGpKm.d.ts → create-servers-CvVZnihM.d.ts} +3 -3
- package/dist/history/index.cjs +2 -0
- package/dist/history/index.cjs.map +1 -0
- package/dist/history/index.d.cts +127 -0
- package/dist/history/index.d.ts +127 -0
- package/dist/history/index.js +2 -0
- package/dist/history/index.js.map +1 -0
- package/dist/{index-DpD4DEqH.d.cts → index-Cw9b1crP.d.cts} +1 -1
- package/dist/{index-Cvip2Sgt.d.ts → index-DGB3Oemk.d.ts} +1 -1
- package/dist/index.cjs +587 -97
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +19 -10
- package/dist/index.d.ts +19 -10
- package/dist/index.js +587 -97
- package/dist/index.js.map +1 -1
- package/dist/{openapi-B3P2F8op.d.ts → openapi-BEf4OuG9.d.ts} +1 -1
- package/dist/{openapi-UJJ1aCFk.d.cts → openapi-D8UTm0lu.d.cts} +1 -1
- package/dist/read-DMvxeFCg.d.cts +232 -0
- package/dist/read-DMvxeFCg.d.ts +232 -0
- package/dist/servers/admin/index.cjs +566 -76
- package/dist/servers/admin/index.cjs.map +1 -1
- package/dist/servers/admin/index.d.cts +4 -2
- package/dist/servers/admin/index.d.ts +4 -2
- package/dist/servers/admin/index.js +566 -76
- package/dist/servers/admin/index.js.map +1 -1
- package/dist/servers/crud/index.d.cts +6 -4
- package/dist/servers/crud/index.d.ts +6 -4
- package/dist/servers/index.cjs +597 -107
- package/dist/servers/index.cjs.map +1 -1
- package/dist/servers/index.d.cts +7 -6
- package/dist/servers/index.d.ts +7 -6
- package/dist/servers/index.js +597 -107
- package/dist/servers/index.js.map +1 -1
- package/dist/{types-Z9Qy8Xmx.d.ts → types-CE1dws32.d.cts} +20 -3
- package/dist/{types-Z9Qy8Xmx.d.cts → types-CjexXskS.d.ts} +20 -3
- package/package.json +14 -1
|
@@ -1,6 +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
5
|
import { DocumentReference, Firestore, DocumentSnapshot, WhereFilterOp, Query, CollectionReference, WriteBatch, Transaction } from 'firebase-admin/firestore';
|
|
5
6
|
|
|
6
7
|
/**
|
|
@@ -165,7 +166,7 @@ type RelationalKeys<T = any, TMapping = any> = {
|
|
|
165
166
|
* @template TCreatedKey - The field name to store the creation timestamp (optional)
|
|
166
167
|
* @template TUpdatedKey - The field name to store the update timestamp (optional)
|
|
167
168
|
*/
|
|
168
|
-
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> {
|
|
169
|
+
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> {
|
|
169
170
|
path: string;
|
|
170
171
|
isGroup: TIsGroup;
|
|
171
172
|
foreignKeys: TForeignKeys;
|
|
@@ -179,6 +180,16 @@ interface RepositoryConfig<T, TForeignKeys extends readonly (keyof T)[], TQueryK
|
|
|
179
180
|
schema?: zod.ZodObject<any>;
|
|
180
181
|
refCb?: TRefCb;
|
|
181
182
|
relationalKeys?: TRelationalKeys;
|
|
183
|
+
/**
|
|
184
|
+
* Optional change-history configuration. When `enabled: true`, the
|
|
185
|
+
* `repo.history.*` read API is exposed and `createHistoryTriggers(...)`
|
|
186
|
+
* will register Firestore triggers for this repo.
|
|
187
|
+
*
|
|
188
|
+
* @see import("../history/types").HistoryConfigForModel
|
|
189
|
+
*/
|
|
190
|
+
history?: HistoryConfigForModel<T> & {
|
|
191
|
+
enabled: THistoryEnabled;
|
|
192
|
+
};
|
|
182
193
|
documentRef: TRefCb extends undefined ? TIsGroup extends true ? (...pathSegments: string[]) => DocumentReference : (docId: string) => DocumentReference : ExtractDocumentRefSignature<TRefCb>;
|
|
183
194
|
update: TRefCb extends undefined ? TIsGroup extends true ? (...args: [...string[], Partial<T>]) => Promise<T> : (docId: string, data: Partial<T>) => Promise<T> : ExtractUpdateSignature<TRefCb, T>;
|
|
184
195
|
}
|
|
@@ -428,7 +439,7 @@ type GenerateQueryMethods<TConfig extends RepositoryConfig<any, any, any, any, a
|
|
|
428
439
|
/**
|
|
429
440
|
* Configured repository with organized methods
|
|
430
441
|
*/
|
|
431
|
-
type ConfiguredRepository<T extends RepositoryConfig<any, any, any, any, any, any, any, any, any, any>> = {
|
|
442
|
+
type ConfiguredRepository<T extends RepositoryConfig<any, any, any, any, any, any, any, any, any, any, any>> = {
|
|
432
443
|
/** @internal Phantom property to expose the model type for generic extraction */
|
|
433
444
|
readonly _modelType: T["type"];
|
|
434
445
|
/** @internal Whether this is a collectionGroup repository */
|
|
@@ -512,7 +523,13 @@ type ConfiguredRepository<T extends RepositoryConfig<any, any, any, any, any, an
|
|
|
512
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 & {
|
|
513
524
|
populated: UnionToIntersection<K extends keyof NonNullable<T["relationalKeys"]> ? ExtractPopulatedFromRelation<NonNullable<T["relationalKeys"]>[K], K & string> : Record<string, never>>;
|
|
514
525
|
}>;
|
|
515
|
-
}
|
|
526
|
+
} & (T extends {
|
|
527
|
+
history: {
|
|
528
|
+
enabled: true;
|
|
529
|
+
};
|
|
530
|
+
} ? {
|
|
531
|
+
history: HistoryMethods<T["type"]>;
|
|
532
|
+
} : {});
|
|
516
533
|
|
|
517
534
|
/**
|
|
518
535
|
* Type definitions for the CRUD API server.
|
|
@@ -1,6 +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
5
|
import { DocumentReference, Firestore, DocumentSnapshot, WhereFilterOp, Query, CollectionReference, WriteBatch, Transaction } from 'firebase-admin/firestore';
|
|
5
6
|
|
|
6
7
|
/**
|
|
@@ -165,7 +166,7 @@ type RelationalKeys<T = any, TMapping = any> = {
|
|
|
165
166
|
* @template TCreatedKey - The field name to store the creation timestamp (optional)
|
|
166
167
|
* @template TUpdatedKey - The field name to store the update timestamp (optional)
|
|
167
168
|
*/
|
|
168
|
-
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> {
|
|
169
|
+
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> {
|
|
169
170
|
path: string;
|
|
170
171
|
isGroup: TIsGroup;
|
|
171
172
|
foreignKeys: TForeignKeys;
|
|
@@ -179,6 +180,16 @@ interface RepositoryConfig<T, TForeignKeys extends readonly (keyof T)[], TQueryK
|
|
|
179
180
|
schema?: zod.ZodObject<any>;
|
|
180
181
|
refCb?: TRefCb;
|
|
181
182
|
relationalKeys?: TRelationalKeys;
|
|
183
|
+
/**
|
|
184
|
+
* Optional change-history configuration. When `enabled: true`, the
|
|
185
|
+
* `repo.history.*` read API is exposed and `createHistoryTriggers(...)`
|
|
186
|
+
* will register Firestore triggers for this repo.
|
|
187
|
+
*
|
|
188
|
+
* @see import("../history/types").HistoryConfigForModel
|
|
189
|
+
*/
|
|
190
|
+
history?: HistoryConfigForModel<T> & {
|
|
191
|
+
enabled: THistoryEnabled;
|
|
192
|
+
};
|
|
182
193
|
documentRef: TRefCb extends undefined ? TIsGroup extends true ? (...pathSegments: string[]) => DocumentReference : (docId: string) => DocumentReference : ExtractDocumentRefSignature<TRefCb>;
|
|
183
194
|
update: TRefCb extends undefined ? TIsGroup extends true ? (...args: [...string[], Partial<T>]) => Promise<T> : (docId: string, data: Partial<T>) => Promise<T> : ExtractUpdateSignature<TRefCb, T>;
|
|
184
195
|
}
|
|
@@ -428,7 +439,7 @@ type GenerateQueryMethods<TConfig extends RepositoryConfig<any, any, any, any, a
|
|
|
428
439
|
/**
|
|
429
440
|
* Configured repository with organized methods
|
|
430
441
|
*/
|
|
431
|
-
type ConfiguredRepository<T extends RepositoryConfig<any, any, any, any, any, any, any, any, any, any>> = {
|
|
442
|
+
type ConfiguredRepository<T extends RepositoryConfig<any, any, any, any, any, any, any, any, any, any, any>> = {
|
|
432
443
|
/** @internal Phantom property to expose the model type for generic extraction */
|
|
433
444
|
readonly _modelType: T["type"];
|
|
434
445
|
/** @internal Whether this is a collectionGroup repository */
|
|
@@ -512,7 +523,13 @@ type ConfiguredRepository<T extends RepositoryConfig<any, any, any, any, any, an
|
|
|
512
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 & {
|
|
513
524
|
populated: UnionToIntersection<K extends keyof NonNullable<T["relationalKeys"]> ? ExtractPopulatedFromRelation<NonNullable<T["relationalKeys"]>[K], K & string> : Record<string, never>>;
|
|
514
525
|
}>;
|
|
515
|
-
}
|
|
526
|
+
} & (T extends {
|
|
527
|
+
history: {
|
|
528
|
+
enabled: true;
|
|
529
|
+
};
|
|
530
|
+
} ? {
|
|
531
|
+
history: HistoryMethods<T["type"]>;
|
|
532
|
+
} : {});
|
|
516
533
|
|
|
517
534
|
/**
|
|
518
535
|
* Type definitions for the CRUD API server.
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@lpdjs/firestore-repo-service",
|
|
3
|
-
"version": "2.2.
|
|
3
|
+
"version": "2.2.7",
|
|
4
4
|
"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
5
|
"type": "module",
|
|
6
6
|
"main": "./dist/index.cjs",
|
|
@@ -37,6 +37,16 @@
|
|
|
37
37
|
"default": "./dist/sync/bigquery.js"
|
|
38
38
|
}
|
|
39
39
|
},
|
|
40
|
+
"./history": {
|
|
41
|
+
"require": {
|
|
42
|
+
"types": "./dist/history/index.d.cts",
|
|
43
|
+
"default": "./dist/history/index.cjs"
|
|
44
|
+
},
|
|
45
|
+
"import": {
|
|
46
|
+
"types": "./dist/history/index.d.ts",
|
|
47
|
+
"default": "./dist/history/index.js"
|
|
48
|
+
}
|
|
49
|
+
},
|
|
40
50
|
"./servers": {
|
|
41
51
|
"require": {
|
|
42
52
|
"types": "./dist/servers/index.d.cts",
|
|
@@ -84,6 +94,9 @@
|
|
|
84
94
|
],
|
|
85
95
|
"sync/bigquery": [
|
|
86
96
|
"./dist/sync/bigquery.d.ts"
|
|
97
|
+
],
|
|
98
|
+
"history": [
|
|
99
|
+
"./dist/history/index.d.ts"
|
|
87
100
|
]
|
|
88
101
|
}
|
|
89
102
|
},
|