@lpdjs/firestore-repo-service 3.0.13 → 3.0.15
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/actor-context-DQZgWqj3.d.cts +117 -0
- package/dist/actor-context-DQZgWqj3.d.ts +117 -0
- package/dist/{create-servers-LyRLAOh3.d.cts → create-servers-B5Z5v2SP.d.cts} +11 -5
- package/dist/{create-servers-Db1xUY2N.d.ts → create-servers-p1-jJNTG.d.ts} +11 -5
- package/dist/history/index.cjs +1 -1
- package/dist/history/index.cjs.map +1 -1
- package/dist/history/index.d.cts +67 -7
- package/dist/history/index.d.ts +67 -7
- package/dist/history/index.js +1 -1
- package/dist/history/index.js.map +1 -1
- package/dist/index.cjs +81 -81
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +20 -14
- package/dist/index.d.ts +20 -14
- package/dist/index.js +81 -81
- package/dist/index.js.map +1 -1
- package/dist/llms-full.txt +1 -1
- package/dist/llms.txt +1 -1
- package/dist/{openapi-QVpqnnes.d.cts → openapi-B9utXiEH.d.cts} +1 -1
- package/dist/{openapi-CNIA7QRw.d.ts → openapi-Bsqq2zgh.d.ts} +1 -1
- package/dist/{queue-BEB-ujA3.d.ts → queue-NFod6hTT.d.ts} +1 -1
- package/dist/{queue-CpHe6M5j.d.cts → queue-zw2B7GPx.d.cts} +1 -1
- package/dist/{read-15-TcgCz.d.ts → read-BPov7lws.d.ts} +30 -7
- package/dist/{read-B15YaPyR.d.cts → read-Dfah1PPl.d.cts} +30 -7
- package/dist/{rules-Cafrkb9v.d.ts → rules-18wH7Uak.d.ts} +1 -1
- package/dist/{rules-Bu2NB7Eb.d.cts → rules-oSXoV4Js.d.cts} +1 -1
- package/dist/servers/admin/index.cjs +5 -5
- package/dist/servers/admin/index.cjs.map +1 -1
- package/dist/servers/admin/index.d.cts +5 -4
- package/dist/servers/admin/index.d.ts +5 -4
- package/dist/servers/admin/index.js +5 -5
- package/dist/servers/admin/index.js.map +1 -1
- package/dist/servers/crud/index.cjs +2 -2
- package/dist/servers/crud/index.cjs.map +1 -1
- package/dist/servers/crud/index.d.cts +10 -9
- package/dist/servers/crud/index.d.ts +10 -9
- package/dist/servers/crud/index.js +2 -2
- package/dist/servers/crud/index.js.map +1 -1
- package/dist/servers/hono/index.cjs +14 -14
- package/dist/servers/hono/index.cjs.map +1 -1
- package/dist/servers/hono/index.d.cts +11 -3
- package/dist/servers/hono/index.d.ts +11 -3
- package/dist/servers/hono/index.js +14 -14
- package/dist/servers/hono/index.js.map +1 -1
- package/dist/servers/index.cjs +94 -94
- package/dist/servers/index.cjs.map +1 -1
- package/dist/servers/index.d.cts +13 -12
- package/dist/servers/index.d.ts +13 -12
- package/dist/servers/index.js +94 -94
- package/dist/servers/index.js.map +1 -1
- package/dist/sync/bigquery.d.cts +2 -2
- package/dist/sync/bigquery.d.ts +2 -2
- package/dist/sync/index.cjs +55 -55
- package/dist/sync/index.cjs.map +1 -1
- package/dist/sync/index.d.cts +6 -6
- package/dist/sync/index.d.ts +6 -6
- package/dist/sync/index.js +55 -55
- package/dist/sync/index.js.map +1 -1
- package/dist/sync/meilisearch.cjs +2 -2
- package/dist/sync/meilisearch.cjs.map +1 -1
- package/dist/sync/meilisearch.d.cts +2 -2
- package/dist/sync/meilisearch.d.ts +2 -2
- package/dist/sync/meilisearch.js +2 -2
- package/dist/sync/meilisearch.js.map +1 -1
- package/dist/{types-o-9qoExc.d.cts → types-BDTx8VPg.d.cts} +8 -0
- package/dist/{types-CNseHqF7.d.cts → types-BGh5_2fl.d.cts} +4 -4
- package/dist/{types-DGQURFSq.d.ts → types-B_FrzmO4.d.ts} +1 -1
- package/dist/{types-DmXW_fVz.d.ts → types-Cc6lelk1.d.ts} +4 -4
- package/dist/{types--RamYGF1.d.cts → types-D6zvWzRt.d.cts} +96 -2
- package/dist/{types--RamYGF1.d.ts → types-D6zvWzRt.d.ts} +96 -2
- package/dist/{types-VVuLlmfc.d.cts → types-D78FPJeF.d.cts} +1 -1
- package/dist/{types-B51LYvQZ.d.cts → types-Dc3lX99O.d.cts} +20 -19
- package/dist/{types-Ci0dGbuW.d.ts → types-DgFJLwAu.d.ts} +20 -19
- package/dist/{types-D3W_RaDA.d.ts → types-w1rEqs0Z.d.ts} +8 -0
- package/package.json +1 -1
|
@@ -16,7 +16,32 @@ import { DocumentOptions, onDocumentWritten } from 'firebase-functions/v2/firest
|
|
|
16
16
|
*/
|
|
17
17
|
type TriggerOptions = Omit<DocumentOptions, "document">;
|
|
18
18
|
type HistoryTriggerOptions = TriggerOptions;
|
|
19
|
-
type HistoryOperation = "create" | "update" | "delete";
|
|
19
|
+
type HistoryOperation = "create" | "update" | "delete" | "custom";
|
|
20
|
+
/**
|
|
21
|
+
* Structured payload attached to `operation: "custom"` history entries
|
|
22
|
+
* (business actions independent of model fields, e.g. manual invoice creation,
|
|
23
|
+
* PDF export, email sent, etc.).
|
|
24
|
+
*/
|
|
25
|
+
interface HistoryCustomData {
|
|
26
|
+
/** Human-readable title (e.g. `"Création de la facture"`). */
|
|
27
|
+
title: string;
|
|
28
|
+
/** Optional human-readable description (e.g. `"Facture #F-2026-042 créée manuellement"`). */
|
|
29
|
+
description?: string;
|
|
30
|
+
/** Optional business action key for filtering/grouping/icons (e.g. `"invoice_create_manually"`). */
|
|
31
|
+
key?: string;
|
|
32
|
+
/** Optional front-end visibility flag (default: `true`). */
|
|
33
|
+
display?: boolean;
|
|
34
|
+
/** Optional arbitrary structured business payload (e.g. `{ invoiceId, amount }`). */
|
|
35
|
+
data?: Record<string, unknown>;
|
|
36
|
+
}
|
|
37
|
+
/** Input payload accepted by `repo.history.recordCustom(...)`. */
|
|
38
|
+
interface HistoryCustomInput extends HistoryCustomData {
|
|
39
|
+
/**
|
|
40
|
+
* Optional metadata overrides (`reason`, `comment`, `extras`, `userId`,
|
|
41
|
+
* `userEmail`). Automatically merged on top of the active ALS actor.
|
|
42
|
+
*/
|
|
43
|
+
meta?: HistoryMeta;
|
|
44
|
+
}
|
|
20
45
|
/**
|
|
21
46
|
* Detected JS/Firestore type of a value as stored in a history entry.
|
|
22
47
|
* Matches the values returned by {@link valueType}.
|
|
@@ -57,6 +82,8 @@ interface HistoryEntry<T = Record<string, unknown>> {
|
|
|
57
82
|
operation: HistoryOperation;
|
|
58
83
|
/** Captured author / context information. */
|
|
59
84
|
meta: HistoryMeta;
|
|
85
|
+
/** Present on `operation: "custom"` entries (business actions independent of model fields). */
|
|
86
|
+
custom?: HistoryCustomData;
|
|
60
87
|
/** Per-field changes. Keys are field names of T. */
|
|
61
88
|
changes: {
|
|
62
89
|
[K in keyof T & string]?: HistoryFieldChange;
|
|
@@ -72,6 +99,8 @@ interface V2HistoryDoc {
|
|
|
72
99
|
historySetAt: Timestamp;
|
|
73
100
|
operation: HistoryOperation;
|
|
74
101
|
meta: HistoryMeta;
|
|
102
|
+
/** Present on `operation: "custom"` entries. */
|
|
103
|
+
custom?: HistoryCustomData;
|
|
75
104
|
changes: Record<string, HistoryFieldChange>;
|
|
76
105
|
/** Optional TTL marker (Firestore deletes the doc after this date). */
|
|
77
106
|
expiresAt?: Timestamp;
|
|
@@ -105,6 +134,49 @@ interface V1HistoryDoc {
|
|
|
105
134
|
extraContentKeys?: Record<string, unknown> | null;
|
|
106
135
|
objectType?: string;
|
|
107
136
|
}
|
|
137
|
+
/** Default top-level shadow field name stored on Firestore documents for auto-injected history metadata. */
|
|
138
|
+
declare const DEFAULT_HISTORY_SHADOW_KEY = "_historyMeta";
|
|
139
|
+
/**
|
|
140
|
+
* Customize (or disable via `false`) the sub-field names stored inside the
|
|
141
|
+
* shadow metadata object on Firestore documents.
|
|
142
|
+
*/
|
|
143
|
+
interface HistoryShadowFieldsConfig {
|
|
144
|
+
/** Key inside the shadow object for author userId, or `false` to omit. Default: `"userId"`. */
|
|
145
|
+
userId?: string | false;
|
|
146
|
+
/** Key inside the shadow object for author userEmail, or `false` to omit. Default: `"userEmail"`. */
|
|
147
|
+
userEmail?: string | false;
|
|
148
|
+
/** Key inside the shadow object for change reason, or `false` to omit. Default: `"reason"`. */
|
|
149
|
+
reason?: string | false;
|
|
150
|
+
/** Key inside the shadow object for change comment, or `false` to omit. Default: `"comment"`. */
|
|
151
|
+
comment?: string | false;
|
|
152
|
+
/** Key inside the shadow object for extras map, or `false` to omit. Default: `"extras"`. */
|
|
153
|
+
extras?: string | false;
|
|
154
|
+
}
|
|
155
|
+
/**
|
|
156
|
+
* Configuration for the internal shadow field used to transport actor metadata
|
|
157
|
+
* to Firestore `onDocumentWritten` triggers without modifying Zod schemas.
|
|
158
|
+
*/
|
|
159
|
+
interface HistoryShadowConfig {
|
|
160
|
+
/**
|
|
161
|
+
* Top-level field name stored on the Firestore document (not required in the
|
|
162
|
+
* Zod schema, automatically excluded from diffs and sync, and stripped on read).
|
|
163
|
+
* Default: `"_historyMeta"`.
|
|
164
|
+
*/
|
|
165
|
+
key?: string;
|
|
166
|
+
/**
|
|
167
|
+
* Customize or disable individual sub-field names inside the shadow object.
|
|
168
|
+
* Default: `{ userId: "userId", userEmail: "userEmail", reason: "reason", comment: "comment", extras: "extras" }`.
|
|
169
|
+
*/
|
|
170
|
+
fields?: HistoryShadowFieldsConfig;
|
|
171
|
+
}
|
|
172
|
+
/**
|
|
173
|
+
* Fallback author values written when no actor is active in `AsyncLocalStorage`
|
|
174
|
+
* (crons, scripts, admin UI, public routes).
|
|
175
|
+
*/
|
|
176
|
+
interface HistoryFallbackActor {
|
|
177
|
+
userId?: string | null;
|
|
178
|
+
userEmail?: string | null;
|
|
179
|
+
}
|
|
108
180
|
/**
|
|
109
181
|
* Per-repo history configuration. Attached on the repository config under
|
|
110
182
|
* the `history` key. All meta sub-keys must reference fields that exist on
|
|
@@ -115,6 +187,27 @@ interface HistoryConfigBase {
|
|
|
115
187
|
enabled: boolean;
|
|
116
188
|
/** Subcollection name used to store history docs. Default: "history". */
|
|
117
189
|
subcollection?: string;
|
|
190
|
+
/**
|
|
191
|
+
* Automatically inject actor metadata from `AsyncLocalStorage` into the
|
|
192
|
+
* shadow field on repository writes (`create`, `set`, `update`, `batch`,
|
|
193
|
+
* `transaction`, `bulk`). Default: `true` when `enabled: true`.
|
|
194
|
+
*/
|
|
195
|
+
autoInjectMeta?: boolean;
|
|
196
|
+
/**
|
|
197
|
+
* Shadow field configuration (zero Zod schema changes).
|
|
198
|
+
*
|
|
199
|
+
* - Omitted or `true` (when `meta` is absent): uses `"_historyMeta"` with default sub-fields.
|
|
200
|
+
* - `string`: shorthand for `{ key: "<customKey>" }`.
|
|
201
|
+
* - `HistoryShadowConfig`: customize both `key` and nested `fields`.
|
|
202
|
+
* - `false`: disable shadow metadata injection/reading.
|
|
203
|
+
*/
|
|
204
|
+
shadow?: boolean | string | HistoryShadowConfig;
|
|
205
|
+
/**
|
|
206
|
+
* Fallback actor written when no actor is active in `AsyncLocalStorage` so
|
|
207
|
+
* previous author metadata never leaks onto subsequent writes.
|
|
208
|
+
* Default: `{ userId: null, userEmail: null }`.
|
|
209
|
+
*/
|
|
210
|
+
fallbackActor?: HistoryFallbackActor;
|
|
118
211
|
/**
|
|
119
212
|
* Optional Firestore TTL configuration. When set, every written history doc
|
|
120
213
|
* gets an `expiresAt` Timestamp at `now + days`. You still need to enable
|
|
@@ -219,4 +312,5 @@ interface HistoryTriggersConfig<M = Record<string, any>> {
|
|
|
219
312
|
repos?: Partial<Record<keyof M & string, HistoryTriggerRepoOverride>>;
|
|
220
313
|
}
|
|
221
314
|
|
|
222
|
-
export
|
|
315
|
+
export { DEFAULT_HISTORY_SHADOW_KEY as D };
|
|
316
|
+
export type { HistoryTriggersConfig as H, TriggerOptions as T, V1HistoryDoc as V, HistoryListOptions as a, HistoryEntry as b, HistoryRawListOptions as c, V2HistoryDoc as d, HistoryOperation as e, HistoryMeta as f, HistoryCustomData as g, HistoryCustomInput as h, HistoryConfigForModel as i, HistoryFieldChange as j, HistoryValueType as k, HistoryConfigBase as l, HistoryFallbackActor as m, HistoryFirestoreTriggersDep as n, HistoryShadowConfig as o, HistoryShadowFieldsConfig as p, HistoryTriggerOptions as q, HistoryTriggerRepoOverride as r };
|
|
@@ -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-
|
|
6
|
+
import { F as FieldPath } from './types-Dc3lX99O.cjs';
|
|
7
7
|
|
|
8
8
|
/**
|
|
9
9
|
* Cloud Functions v2 options forwarded to `onDocumentWritten()` for every
|
|
@@ -1,12 +1,17 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { i as HistoryConfigForModel } from './types-D6zvWzRt.cjs';
|
|
2
2
|
import * as zod from 'zod';
|
|
3
3
|
import { DocumentReference, Firestore, DocumentSnapshot, WhereFilterOp } from 'firebase-admin/firestore';
|
|
4
4
|
|
|
5
|
+
/**
|
|
6
|
+
* `true` when `T` is `any` (the `0 extends (1 & T)` trick).
|
|
7
|
+
* @internal
|
|
8
|
+
*/
|
|
9
|
+
type IsAny<T> = 0 extends 1 & T ? true : false;
|
|
5
10
|
/**
|
|
6
11
|
* Extract the documentRef signature from refCb (without the db parameter)
|
|
7
12
|
* @internal
|
|
8
13
|
*/
|
|
9
|
-
type ExtractDocumentRefSignature<T> = T extends (db: Firestore, ...args: infer P) => DocumentReference ? (...args: P) => DocumentReference : never;
|
|
14
|
+
type ExtractDocumentRefSignature<T> = IsAny<T> extends true ? (...args: any[]) => DocumentReference : T extends (db: Firestore, ...args: infer P) => DocumentReference ? (...args: P) => DocumentReference : never;
|
|
10
15
|
/**
|
|
11
16
|
* Extract all `{param}` names from a path template string in left-to-right order.
|
|
12
17
|
* @example ExtractPathParams<"prevention/prev_rules/prev_workshops/{workshopId}/prev_events"> // ["workshopId"]
|
|
@@ -38,15 +43,20 @@ type PathParamsToArgsTuple<TParams extends readonly string[]> = [
|
|
|
38
43
|
docId: string
|
|
39
44
|
];
|
|
40
45
|
/**
|
|
41
|
-
*
|
|
46
|
+
* Synthesize a `refCb` function signature from a `TPath` template when `refCb` is omitted.
|
|
42
47
|
* @internal
|
|
43
48
|
*/
|
|
44
|
-
type
|
|
49
|
+
type SynthesizedRefCb<TPath extends string, TDocumentKey extends string, TIsGroup extends boolean> = ExtractParentParams<TPath, TDocumentKey> extends [string, ...string[]] ? (db: Firestore, ...args: PathParamsToArgsTuple<ExtractParentParams<TPath, TDocumentKey>>) => DocumentReference : TIsGroup extends true ? (db: Firestore, ...pathSegments: string[]) => DocumentReference : (db: Firestore, docId: string) => DocumentReference;
|
|
50
|
+
/**
|
|
51
|
+
* Resolve the effective `refCb` signature: either the user-provided `TRefCb` or the synthesized signature from `TPath`.
|
|
52
|
+
* @internal
|
|
53
|
+
*/
|
|
54
|
+
type EffectiveRefCb<TPath extends string, TDocumentKey extends string, TIsGroup extends boolean, TRefCb> = IsAny<TRefCb> extends true ? any : [TRefCb] extends [undefined] ? SynthesizedRefCb<TPath, TDocumentKey, TIsGroup> : TRefCb;
|
|
45
55
|
/**
|
|
46
56
|
* Extract the update signature from refCb
|
|
47
57
|
* @internal
|
|
48
58
|
*/
|
|
49
|
-
type ExtractUpdateSignature<T, TType> = T extends (db: Firestore, ...args: infer P) => DocumentReference ? (...args: [...P, DeepPartial<TType> & DotNotationUpdate<TType>]) => Promise<TType> : never;
|
|
59
|
+
type ExtractUpdateSignature<T, TType> = IsAny<T> extends true ? (...args: any[]) => Promise<TType> : T extends (db: Firestore, ...args: infer P) => DocumentReference ? (...args: [...P, DeepPartial<TType> & DotNotationUpdate<TType>]) => Promise<TType> : never;
|
|
50
60
|
/**
|
|
51
61
|
* Check if an object type has any method properties (e.g. Timestamp.toDate, GeoPoint.isEqual)
|
|
52
62
|
* @internal
|
|
@@ -233,8 +243,8 @@ type RelationalKeys<T = any, TMapping = any> = {
|
|
|
233
243
|
* @template TCreatedKey - The field name to store the creation timestamp (optional)
|
|
234
244
|
* @template TUpdatedKey - The field name to store the update timestamp (optional)
|
|
235
245
|
*/
|
|
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
|
|
237
|
-
path:
|
|
246
|
+
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> {
|
|
247
|
+
path: string;
|
|
238
248
|
isGroup: TIsGroup;
|
|
239
249
|
foreignKeys: TForeignKeys;
|
|
240
250
|
queryKeys: TQueryKeys;
|
|
@@ -261,17 +271,8 @@ interface RepositoryConfig<T, TForeignKeys extends readonly (keyof T)[], TQueryK
|
|
|
261
271
|
history?: HistoryConfigForModel<T> & {
|
|
262
272
|
enabled: THistoryEnabled;
|
|
263
273
|
};
|
|
264
|
-
documentRef: TRefCb extends undefined ?
|
|
265
|
-
|
|
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>;
|
|
274
|
+
documentRef: IsAny<TRefCb> extends true ? (...args: any[]) => DocumentReference : [TRefCb] extends [undefined] ? TIsGroup extends true ? (...pathSegments: string[]) => DocumentReference : (docId: string) => DocumentReference : ExtractDocumentRefSignature<TRefCb>;
|
|
275
|
+
update: IsAny<TRefCb> extends true ? (...args: any[]) => Promise<T> : [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>;
|
|
275
276
|
}
|
|
276
277
|
|
|
277
|
-
export type { DeepPartial as D,
|
|
278
|
+
export type { DeepPartial as D, EffectiveRefCb as E, FieldPath as F, GetOptions as G, InvalidPathParams as I, PathParamsToArgsTuple as P, QueryOptions as Q, RepositoryConfig as R, SynthesizedRefCb as S, ValidatedPath as V, WhereClause as W, RelationConfig as a, DotNotationUpdate as b, ExtractDocumentRefSignature as c, ExtractParentParams as d, ExtractPathParams as e, ExtractUpdateSignature as f, GetResult as g, RelationalKeys as h, ExtractReturnDoc as i };
|
|
@@ -1,12 +1,17 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { i as HistoryConfigForModel } from './types-D6zvWzRt.js';
|
|
2
2
|
import * as zod from 'zod';
|
|
3
3
|
import { DocumentReference, Firestore, DocumentSnapshot, WhereFilterOp } from 'firebase-admin/firestore';
|
|
4
4
|
|
|
5
|
+
/**
|
|
6
|
+
* `true` when `T` is `any` (the `0 extends (1 & T)` trick).
|
|
7
|
+
* @internal
|
|
8
|
+
*/
|
|
9
|
+
type IsAny<T> = 0 extends 1 & T ? true : false;
|
|
5
10
|
/**
|
|
6
11
|
* Extract the documentRef signature from refCb (without the db parameter)
|
|
7
12
|
* @internal
|
|
8
13
|
*/
|
|
9
|
-
type ExtractDocumentRefSignature<T> = T extends (db: Firestore, ...args: infer P) => DocumentReference ? (...args: P) => DocumentReference : never;
|
|
14
|
+
type ExtractDocumentRefSignature<T> = IsAny<T> extends true ? (...args: any[]) => DocumentReference : T extends (db: Firestore, ...args: infer P) => DocumentReference ? (...args: P) => DocumentReference : never;
|
|
10
15
|
/**
|
|
11
16
|
* Extract all `{param}` names from a path template string in left-to-right order.
|
|
12
17
|
* @example ExtractPathParams<"prevention/prev_rules/prev_workshops/{workshopId}/prev_events"> // ["workshopId"]
|
|
@@ -38,15 +43,20 @@ type PathParamsToArgsTuple<TParams extends readonly string[]> = [
|
|
|
38
43
|
docId: string
|
|
39
44
|
];
|
|
40
45
|
/**
|
|
41
|
-
*
|
|
46
|
+
* Synthesize a `refCb` function signature from a `TPath` template when `refCb` is omitted.
|
|
42
47
|
* @internal
|
|
43
48
|
*/
|
|
44
|
-
type
|
|
49
|
+
type SynthesizedRefCb<TPath extends string, TDocumentKey extends string, TIsGroup extends boolean> = ExtractParentParams<TPath, TDocumentKey> extends [string, ...string[]] ? (db: Firestore, ...args: PathParamsToArgsTuple<ExtractParentParams<TPath, TDocumentKey>>) => DocumentReference : TIsGroup extends true ? (db: Firestore, ...pathSegments: string[]) => DocumentReference : (db: Firestore, docId: string) => DocumentReference;
|
|
50
|
+
/**
|
|
51
|
+
* Resolve the effective `refCb` signature: either the user-provided `TRefCb` or the synthesized signature from `TPath`.
|
|
52
|
+
* @internal
|
|
53
|
+
*/
|
|
54
|
+
type EffectiveRefCb<TPath extends string, TDocumentKey extends string, TIsGroup extends boolean, TRefCb> = IsAny<TRefCb> extends true ? any : [TRefCb] extends [undefined] ? SynthesizedRefCb<TPath, TDocumentKey, TIsGroup> : TRefCb;
|
|
45
55
|
/**
|
|
46
56
|
* Extract the update signature from refCb
|
|
47
57
|
* @internal
|
|
48
58
|
*/
|
|
49
|
-
type ExtractUpdateSignature<T, TType> = T extends (db: Firestore, ...args: infer P) => DocumentReference ? (...args: [...P, DeepPartial<TType> & DotNotationUpdate<TType>]) => Promise<TType> : never;
|
|
59
|
+
type ExtractUpdateSignature<T, TType> = IsAny<T> extends true ? (...args: any[]) => Promise<TType> : T extends (db: Firestore, ...args: infer P) => DocumentReference ? (...args: [...P, DeepPartial<TType> & DotNotationUpdate<TType>]) => Promise<TType> : never;
|
|
50
60
|
/**
|
|
51
61
|
* Check if an object type has any method properties (e.g. Timestamp.toDate, GeoPoint.isEqual)
|
|
52
62
|
* @internal
|
|
@@ -233,8 +243,8 @@ type RelationalKeys<T = any, TMapping = any> = {
|
|
|
233
243
|
* @template TCreatedKey - The field name to store the creation timestamp (optional)
|
|
234
244
|
* @template TUpdatedKey - The field name to store the update timestamp (optional)
|
|
235
245
|
*/
|
|
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
|
|
237
|
-
path:
|
|
246
|
+
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> {
|
|
247
|
+
path: string;
|
|
238
248
|
isGroup: TIsGroup;
|
|
239
249
|
foreignKeys: TForeignKeys;
|
|
240
250
|
queryKeys: TQueryKeys;
|
|
@@ -261,17 +271,8 @@ interface RepositoryConfig<T, TForeignKeys extends readonly (keyof T)[], TQueryK
|
|
|
261
271
|
history?: HistoryConfigForModel<T> & {
|
|
262
272
|
enabled: THistoryEnabled;
|
|
263
273
|
};
|
|
264
|
-
documentRef: TRefCb extends undefined ?
|
|
265
|
-
|
|
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>;
|
|
274
|
+
documentRef: IsAny<TRefCb> extends true ? (...args: any[]) => DocumentReference : [TRefCb] extends [undefined] ? TIsGroup extends true ? (...pathSegments: string[]) => DocumentReference : (docId: string) => DocumentReference : ExtractDocumentRefSignature<TRefCb>;
|
|
275
|
+
update: IsAny<TRefCb> extends true ? (...args: any[]) => Promise<T> : [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>;
|
|
275
276
|
}
|
|
276
277
|
|
|
277
|
-
export type { DeepPartial as D,
|
|
278
|
+
export type { DeepPartial as D, EffectiveRefCb as E, FieldPath as F, GetOptions as G, InvalidPathParams as I, PathParamsToArgsTuple as P, QueryOptions as Q, RepositoryConfig as R, SynthesizedRefCb as S, ValidatedPath as V, WhereClause as W, RelationConfig as a, DotNotationUpdate as b, ExtractDocumentRefSignature as c, ExtractParentParams as d, ExtractPathParams as e, ExtractUpdateSignature as f, GetResult as g, RelationalKeys as h, ExtractReturnDoc as i };
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { z, ZodError } from 'zod';
|
|
2
2
|
import { Env, Context, MiddlewareHandler } from 'hono';
|
|
3
3
|
import { F as FirebaseAdminAuthLike, D as DecodedIdTokenLike } from './firebase-auth-nG3prKoj.js';
|
|
4
|
+
import { A as ActorResolverOption } from './actor-context-DQZgWqj3.js';
|
|
4
5
|
|
|
5
6
|
/**
|
|
6
7
|
* Global DI services container for the Hono server.
|
|
@@ -855,6 +856,13 @@ interface HonoServerOptions<TEnv extends Env = Env> {
|
|
|
855
856
|
* project — declare it once and pass it to {@link createApiRegistry}.
|
|
856
857
|
*/
|
|
857
858
|
services?: AnyServicesContainer;
|
|
859
|
+
/**
|
|
860
|
+
* Optional resolver (function or declarative field config) used to extract
|
|
861
|
+
* the authenticated actor from the Hono `Context` for automatic history
|
|
862
|
+
* shadow metadata injection. Defaults to {@link defaultActorResolver}
|
|
863
|
+
* (`c.get("user") ?? c.get("docsUser")`).
|
|
864
|
+
*/
|
|
865
|
+
actorResolver?: ActorResolverOption;
|
|
858
866
|
}
|
|
859
867
|
|
|
860
868
|
export { basicAuth as N, createRequestContextMiddleware as Q, createServices as T, defineRoutes as U, ValidationError as V, firebaseBearerAuth as W, firebaseDocsAuth as X, isDocsAuthExtension as Y, withRequestContext as Z };
|