@tech4good/platform-data 0.1.0-alpha.0
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/BACKENDS.md +161 -0
- package/EXTRACTION-CHANGES.md +1011 -0
- package/FUTURE-WORK.md +328 -0
- package/MIGRATION.md +227 -0
- package/README.md +536 -0
- package/fesm2022/tech4good-platform-data-firestore.mjs +281 -0
- package/fesm2022/tech4good-platform-data-firestore.mjs.map +1 -0
- package/fesm2022/tech4good-platform-data-material.mjs +15 -0
- package/fesm2022/tech4good-platform-data-material.mjs.map +1 -0
- package/fesm2022/tech4good-platform-data-testing.mjs +479 -0
- package/fesm2022/tech4good-platform-data-testing.mjs.map +1 -0
- package/fesm2022/tech4good-platform-data.mjs +2190 -0
- package/fesm2022/tech4good-platform-data.mjs.map +1 -0
- package/package.json +51 -0
- package/types/tech4good-platform-data-firestore.d.ts +83 -0
- package/types/tech4good-platform-data-firestore.d.ts.map +1 -0
- package/types/tech4good-platform-data-material.d.ts +7 -0
- package/types/tech4good-platform-data-material.d.ts.map +1 -0
- package/types/tech4good-platform-data-testing.d.ts +236 -0
- package/types/tech4good-platform-data-testing.d.ts.map +1 -0
- package/types/tech4good-platform-data.d.ts +686 -0
- package/types/tech4good-platform-data.d.ts.map +1 -0
|
@@ -0,0 +1,686 @@
|
|
|
1
|
+
import * as _angular_core from '@angular/core';
|
|
2
|
+
import { InjectionToken, WritableSignal, EnvironmentProviders, DestroyRef } from '@angular/core';
|
|
3
|
+
import { Observable } from 'rxjs';
|
|
4
|
+
import * as _ngrx_signals_entities from '@ngrx/signals/entities';
|
|
5
|
+
import * as _ngrx_signals from '@ngrx/signals';
|
|
6
|
+
import { Logger } from '@tech4good/platform-logging';
|
|
7
|
+
|
|
8
|
+
/** A finite instant relative to 1970-01-01T00:00:00Z. No timezone or database SDK. */
|
|
9
|
+
interface DataTimestamp {
|
|
10
|
+
/** Explicit JSON-safe marker; ordinary seconds/nanoseconds objects remain ordinary data. */
|
|
11
|
+
readonly __type: 'DataTimestamp';
|
|
12
|
+
readonly seconds: number;
|
|
13
|
+
readonly nanoseconds: number;
|
|
14
|
+
}
|
|
15
|
+
/**
|
|
16
|
+
* Construct an immutable value from already-normalized parts; out-of-range
|
|
17
|
+
* nanoseconds are rejected, not carried into seconds. Negative instants use
|
|
18
|
+
* negative seconds and positive nanoseconds: (-1, 500000000) is 0.5s before epoch.
|
|
19
|
+
*/
|
|
20
|
+
declare function dataTimestamp(seconds: number, nanoseconds?: number): DataTimestamp;
|
|
21
|
+
/** Validate the marker and numeric parts, including values read back from JSON. */
|
|
22
|
+
declare function isDataTimestamp(value: unknown): value is DataTimestamp;
|
|
23
|
+
/** Millisecond input is rounded to the nearest nanosecond; use dataTimestamp for exact values. */
|
|
24
|
+
declare function dataTimestampFromMillis(milliseconds: number): DataTimestamp;
|
|
25
|
+
/** Local clock estimate for optimistic records; database adapters own authoritative write times. */
|
|
26
|
+
declare function dataTimestampNow(): DataTimestamp;
|
|
27
|
+
/** Convert a valid Date; its timezone display does not change the represented instant. */
|
|
28
|
+
declare function dataTimestampFromDate(date: Date): DataTimestamp;
|
|
29
|
+
/** Potentially lossy numeric conversion, intended for display and the existing load-time clock. */
|
|
30
|
+
declare function dataTimestampToMillis(value: DataTimestamp): number;
|
|
31
|
+
/** Millisecond display conversion. Do not use this to round-trip database timestamps. */
|
|
32
|
+
declare function dataTimestampToDate(value: DataTimestamp): Date;
|
|
33
|
+
/** Exact chronological comparison without floating-point epoch conversion. */
|
|
34
|
+
declare function compareDataTimestamps(a: DataTimestamp, b: DataTimestamp): number;
|
|
35
|
+
/** Compare timestamp values rather than object identity; matching null/undefined also compare equal. */
|
|
36
|
+
declare function dataTimestampEquals(a: DataTimestamp | null | undefined, b: DataTimestamp | null | undefined): boolean;
|
|
37
|
+
|
|
38
|
+
/**
|
|
39
|
+
* A stored record, including the metadata required by loading and streaming.
|
|
40
|
+
* App models extend this with domain fields. Use NewDataEntity for creation
|
|
41
|
+
* inputs that do not have metadata yet; persisted records must have all fields.
|
|
42
|
+
*/
|
|
43
|
+
interface DataEntity {
|
|
44
|
+
/** Stable document identity used by store selectors and write operations. */
|
|
45
|
+
__id: string;
|
|
46
|
+
/** Creation time, retained when a record is updated. */
|
|
47
|
+
_createdAt: DataTimestamp;
|
|
48
|
+
/** Last write time, used to fetch changes since a previous load. */
|
|
49
|
+
_updatedAt: DataTimestamp;
|
|
50
|
+
/** Soft-deletion marker; retained records let later loads discover removals. */
|
|
51
|
+
_deleted: boolean;
|
|
52
|
+
}
|
|
53
|
+
/** Creation input: domain fields are required; the store/adapter supplies metadata. */
|
|
54
|
+
type NewDataEntity<T extends DataEntity = DataEntity> = Omit<T, keyof DataEntity> & Partial<DataEntity>;
|
|
55
|
+
/** Legacy name for the shared contract, not a union of an application's models. */
|
|
56
|
+
type AnyEntity = DataEntity;
|
|
57
|
+
/**
|
|
58
|
+
* AND-combined [field path, operator, operand] filters, for example
|
|
59
|
+
* [['__userId', '==', userId]]. Firestore supports querying for null, but not
|
|
60
|
+
* undefined. A nested query such as [['__hashtagId', '==', q.__hashtagId]] may
|
|
61
|
+
* encounter a parent whose optional __hashtagId field is absent. In that case
|
|
62
|
+
* we ignore the undefined filter and apply the remaining filters; we do not
|
|
63
|
+
* skip the entire query. Supported operators are defined by the configured adapter.
|
|
64
|
+
*/
|
|
65
|
+
type QueryParams = [string, string, any][];
|
|
66
|
+
/** Ordering, result limits and cursor bounds shared by stores and adapters. */
|
|
67
|
+
type QueryOptions = {
|
|
68
|
+
/** A field defaults to ascending; tuples specify 'asc' or 'desc' explicitly. */
|
|
69
|
+
orderBy?: string | [string, string] | [string, string][];
|
|
70
|
+
limit?: number;
|
|
71
|
+
/** Inclusive lower bound: a scalar for one ordering, or a tuple in ordering order. */
|
|
72
|
+
startAt?: any;
|
|
73
|
+
/** Exclusive lower bound, using the same scalar/tuple convention as startAt. */
|
|
74
|
+
startAfter?: any;
|
|
75
|
+
/** Inclusive upper bound, using the same scalar/tuple convention as startAt. */
|
|
76
|
+
endAt?: any;
|
|
77
|
+
/** Exclusive upper bound, using the same scalar/tuple convention as startAt. */
|
|
78
|
+
endBefore?: any;
|
|
79
|
+
};
|
|
80
|
+
|
|
81
|
+
declare const entityType: unique symbol;
|
|
82
|
+
/**
|
|
83
|
+
* Runtime collection identity paired with a compile-time record type.
|
|
84
|
+
* Keep the definition beside its interface in *.model.ts. It contains no seeds
|
|
85
|
+
* or store instances, so production code can import it without mock dependencies.
|
|
86
|
+
*/
|
|
87
|
+
interface EntityDefinition<T extends DataEntity = DataEntity> {
|
|
88
|
+
/** Persisted collection name, shared by the entity store and generated registry. */
|
|
89
|
+
readonly collection: string;
|
|
90
|
+
/** Type-only association. No entity instance or mock data is stored here. */
|
|
91
|
+
readonly [entityType]?: T;
|
|
92
|
+
}
|
|
93
|
+
/** Recover the record type from a definition, as the generated AppEntityMap does. */
|
|
94
|
+
type EntityType<D extends EntityDefinition> = D extends EntityDefinition<infer T> ? T : never;
|
|
95
|
+
/**
|
|
96
|
+
* Declare an entity for t4g-entities to discover; this does not create a database
|
|
97
|
+
* collection or register Angular providers. Export a top-level const with a
|
|
98
|
+
* literal collection name so discovery can read it without executing app code.
|
|
99
|
+
*
|
|
100
|
+
* @example
|
|
101
|
+
* export const problemEntity = defineEntity<Problem>({ collection: 'problems' });
|
|
102
|
+
*/
|
|
103
|
+
declare function defineEntity<T extends DataEntity>(definition: {
|
|
104
|
+
collection: string;
|
|
105
|
+
}): EntityDefinition<T>;
|
|
106
|
+
|
|
107
|
+
/** UI-neutral configuration; the Material adapter accepts MatSnackBarConfig. */
|
|
108
|
+
type FeedbackConfig = object;
|
|
109
|
+
/**
|
|
110
|
+
* Minimal notification interface used by write success/failure and undo flows.
|
|
111
|
+
* An adapter presents the message and emits onAction when the user chooses Undo.
|
|
112
|
+
* Keeping the interface here lets core run without Angular Material.
|
|
113
|
+
*/
|
|
114
|
+
interface DataFeedback {
|
|
115
|
+
open(message: string, action?: string, config?: FeedbackConfig): {
|
|
116
|
+
onAction(): Observable<void>;
|
|
117
|
+
};
|
|
118
|
+
}
|
|
119
|
+
/** Silent default: writes still work, but no notification or undo action is presented. */
|
|
120
|
+
declare const NOOP_DATA_FEEDBACK: DataFeedback;
|
|
121
|
+
declare const DATA_FEEDBACK: InjectionToken<DataFeedback>;
|
|
122
|
+
|
|
123
|
+
/** Minimal common surface of Firestore and mock write batches. */
|
|
124
|
+
interface WriteBatchI {
|
|
125
|
+
update(docRef: any, changes: any): any;
|
|
126
|
+
set(docRef: any, entity: any): any;
|
|
127
|
+
delete(docRef: any): any;
|
|
128
|
+
commit(): Promise<unknown>;
|
|
129
|
+
}
|
|
130
|
+
/** Mutable work queues shared by store writes participating in one batch. */
|
|
131
|
+
interface BatchConfig {
|
|
132
|
+
/** Forward backend writes, committed after the preparation callback finishes. */
|
|
133
|
+
batch: WriteBatchI;
|
|
134
|
+
/** Inverse backend writes prepared for a later user-requested undo. */
|
|
135
|
+
revertBatch: WriteBatchI;
|
|
136
|
+
/** Local patches applied after commit when optimistic mode is off. */
|
|
137
|
+
patchFns: Array<() => void>;
|
|
138
|
+
/** Local compensations, run in reverse order on rollback or successful undo. */
|
|
139
|
+
revertFns: Array<() => void>;
|
|
140
|
+
/** Restore backend state directly or queue inverse writes into revertBatch. */
|
|
141
|
+
dbRevertFns: Array<() => void | Promise<unknown>>;
|
|
142
|
+
optimistic?: boolean;
|
|
143
|
+
}
|
|
144
|
+
/** Controls local update timing, an optional busy signal and write notifications. */
|
|
145
|
+
interface WriteOptions {
|
|
146
|
+
/** Apply local changes while preparing writes; revert them if preparation/commit fails. */
|
|
147
|
+
optimistic?: boolean;
|
|
148
|
+
/** Set true across preparation and commit, then reset even when either fails. */
|
|
149
|
+
loading?: WritableSignal<boolean>;
|
|
150
|
+
snackBarConfig?: {
|
|
151
|
+
successMessage: string;
|
|
152
|
+
failureMessage: string;
|
|
153
|
+
undoOnAction?: boolean;
|
|
154
|
+
config?: FeedbackConfig;
|
|
155
|
+
};
|
|
156
|
+
}
|
|
157
|
+
/** Coordinates store writes through one adapter-owned batch and rollback boundary. */
|
|
158
|
+
interface BatchWriteService {
|
|
159
|
+
batchWrite(batchFn: (config: BatchConfig) => void | Promise<unknown>, options?: WriteOptions): Promise<void>;
|
|
160
|
+
}
|
|
161
|
+
declare const BATCH_WRITE_SERVICE: InjectionToken<BatchWriteService>;
|
|
162
|
+
/**
|
|
163
|
+
* Shared coordinator for real and mock batches. The callback queues backend
|
|
164
|
+
* writes and records local patches/compensations; this function commits once.
|
|
165
|
+
* Keep the original optimistic/non-optimistic branches visible: one patches
|
|
166
|
+
* during preparation, the other patches after commit. Preparation is inside
|
|
167
|
+
* the try block so a preparation failure also rolls back optimistic changes.
|
|
168
|
+
*/
|
|
169
|
+
declare function processBatchWrite(batchFn: (config: BatchConfig) => void | Promise<unknown>, options: WriteOptions | undefined, batch: WriteBatchI, revertBatch: WriteBatchI, feedback: DataFeedback): Promise<void>;
|
|
170
|
+
|
|
171
|
+
/**
|
|
172
|
+
* Backend operations consumed by entity stores. Implementations translate
|
|
173
|
+
* shared timestamps and query descriptors into their backend's representation.
|
|
174
|
+
* These methods apply only the supplied filters; the store layer adds its
|
|
175
|
+
* active/deleted and incremental-load filters. Authentication is app-owned.
|
|
176
|
+
*/
|
|
177
|
+
interface DataAccess {
|
|
178
|
+
/** Allocate an ID without persisting a record. */
|
|
179
|
+
createId(): string;
|
|
180
|
+
/** Observe a document, emitting null when absent; unsubscribe releases the listener. */
|
|
181
|
+
streamEntity<T>(collectionName: string, id: string): Observable<T | null>;
|
|
182
|
+
/** Observe complete query results on each update. */
|
|
183
|
+
streamEntities<T>(collectionName: any, queryParams: any, queryOptions?: any): Observable<T[]>;
|
|
184
|
+
/**
|
|
185
|
+
* Observe added/modified/removed query members, including initial added records.
|
|
186
|
+
* A removed event can mean the record left the query, not that it was deleted.
|
|
187
|
+
*/
|
|
188
|
+
streamEntitiesChanges<T>(collectionName: any, queryParams: any, queryOptions?: any): Observable<{
|
|
189
|
+
type: string;
|
|
190
|
+
docData: T;
|
|
191
|
+
}[]>;
|
|
192
|
+
/** Read once without opening a persistent listener. */
|
|
193
|
+
getEntity<T>(collectionName: string, id: string): Promise<T | null>;
|
|
194
|
+
getEntities<S>(collectionName: string, queryParams: [string, string, any][], queryOptions?: {
|
|
195
|
+
[index: string]: any;
|
|
196
|
+
}): Promise<S[]>;
|
|
197
|
+
count(collectionName: string, queryParams: QueryParams, queryOptions?: QueryOptions): Promise<number>;
|
|
198
|
+
/** Named aggregates: { total: ['count'], averageScore: ['average', 'score'] }. */
|
|
199
|
+
aggregate<S extends {
|
|
200
|
+
[k: string]: number;
|
|
201
|
+
}>(collectionName: string, queryParams: QueryParams, queryOptions: QueryOptions, aggregateParams: {
|
|
202
|
+
[K in keyof S]: [string] | [string, string];
|
|
203
|
+
}): Promise<{
|
|
204
|
+
[K in keyof S]: number | null;
|
|
205
|
+
}>;
|
|
206
|
+
/** Write a record with metadata, or queue it in the supplied uncommitted batch. */
|
|
207
|
+
addEntity<T extends NewDataEntity & {
|
|
208
|
+
__id: string;
|
|
209
|
+
}>(collectionName: string, entity: T, batch?: WriteBatchI): Promise<any>;
|
|
210
|
+
/** Apply changes and advance _updatedAt; a supplied batch must be committed separately. */
|
|
211
|
+
updateEntity<T extends object>(collectionName: string, id: string, changes: Partial<T>, batch?: WriteBatchI): Promise<any>;
|
|
212
|
+
/** Soft-delete and advance _updatedAt so incremental loads can observe the removal. */
|
|
213
|
+
removeEntity(collectionName: string, id: string, batch?: WriteBatchI): Promise<any>;
|
|
214
|
+
incrementEntityField(collectionName: any, id: any, field: any, delta: any): Promise<void>;
|
|
215
|
+
}
|
|
216
|
+
/** Provide the selected adapter here; core stores never inject a backend SDK. */
|
|
217
|
+
declare const DATA_ACCESS: InjectionToken<DataAccess>;
|
|
218
|
+
/** Compatibility alias; this is the same token, not another provider. */
|
|
219
|
+
declare const DATABASE_SERVICE: InjectionToken<DataAccess>;
|
|
220
|
+
type DatabaseService = DataAccess;
|
|
221
|
+
|
|
222
|
+
/** Optional write-feedback integration; omitting it retains the no-op implementation. */
|
|
223
|
+
interface PlatformDataOptions {
|
|
224
|
+
feedback?: DataFeedback;
|
|
225
|
+
}
|
|
226
|
+
/**
|
|
227
|
+
* Configure write feedback in the application's providers. App-wide diagnostic
|
|
228
|
+
* logging is configured separately with providePlatformLogging from platform-logging.
|
|
229
|
+
* This does not select a database: also provide a DATA_ACCESS adapter and a
|
|
230
|
+
* matching batch service, using provideFirestoreData or provideMockData.
|
|
231
|
+
*/
|
|
232
|
+
declare function providePlatformData(options?: PlatformDataOptions): EnvironmentProviders;
|
|
233
|
+
|
|
234
|
+
/** Read dotted field paths; local __name__ queries refer to the record's __id. */
|
|
235
|
+
declare function fieldValue(entity: any, path: string): any;
|
|
236
|
+
/** Stable, type-preserving keys; never mutates a query supplied by the app. */
|
|
237
|
+
declare function stableQueryKey(collection: string, params?: QueryParams, options?: QueryOptions): string;
|
|
238
|
+
/** Normalize the three supported orderBy shapes without changing the caller's options. */
|
|
239
|
+
declare function queryOrderings(options?: QueryOptions): [string, string][];
|
|
240
|
+
/**
|
|
241
|
+
* Check whether the entity satisfies the query results.
|
|
242
|
+
* We use this to double-check whether a 'removed' change was truly removed from
|
|
243
|
+
* the backend or whether it just doesn't match the query anymore. For example,
|
|
244
|
+
* a post whose authorId changes leaves the old author's query, but can still be
|
|
245
|
+
* needed by another query and should not be removed from the shared store solely
|
|
246
|
+
* for leaving that result set.
|
|
247
|
+
*
|
|
248
|
+
* This checks filters, ordered fields and cursor bounds. A single entity cannot
|
|
249
|
+
* establish membership in a limited result window; that also depends on other records.
|
|
250
|
+
*/
|
|
251
|
+
declare function entityInQueryResults<T>(entity: T, params?: QueryParams, options?: QueryOptions): boolean;
|
|
252
|
+
/**
|
|
253
|
+
* Mock database query: use the ID-first steps in runQuery without hiding deletions.
|
|
254
|
+
* In particular, the loader's _deleted == true query must return those records.
|
|
255
|
+
*/
|
|
256
|
+
declare function queryEntities<T>(entityMap: Record<string, T>, params?: QueryParams, options?: QueryOptions): T[];
|
|
257
|
+
/**
|
|
258
|
+
* Select entities already in the store, given its entityMap and query constraints.
|
|
259
|
+
* Filters out records marked _deleted even if a caller explicitly includes a
|
|
260
|
+
* _deleted filter, so a frontend selector cannot expose a soft-deleted record.
|
|
261
|
+
* The mock backend instead uses queryEntities: the loader needs its separate
|
|
262
|
+
* _deleted == true query to return deletion markers and remove cached records.
|
|
263
|
+
*/
|
|
264
|
+
declare function selectEntities<T>(entityMap: Record<string, T>, params?: QueryParams, options?: QueryOptions): T[];
|
|
265
|
+
|
|
266
|
+
/**
|
|
267
|
+
* Expand child-load descriptors for parent records and execute compatible groups
|
|
268
|
+
* together. Each position in the callback's returned array represents one child
|
|
269
|
+
* relationship; batching also checks collection/store/callback identity before
|
|
270
|
+
* combining requests. Firestore rejects an empty `in` list, so the helper skips
|
|
271
|
+
* the entire descriptor containing it. Other descriptors still run, and skipping
|
|
272
|
+
* a load does not clear records already held in the frontend store.
|
|
273
|
+
*/
|
|
274
|
+
declare function processLoadQueries<T extends {
|
|
275
|
+
__id: string;
|
|
276
|
+
}>(entities: T[], loadQueries: (entity: T) => EntityLoadQuery<DataEntity>[]): Promise<void>;
|
|
277
|
+
/**
|
|
278
|
+
* Description of a nested one-shot load. Construction does not run the query;
|
|
279
|
+
* processLoadQueries passes it to the owning store. Generated Load<Entity>
|
|
280
|
+
* subclasses supply collection identity and the entity's domain type.
|
|
281
|
+
*/
|
|
282
|
+
declare class EntityLoadQuery<T> {
|
|
283
|
+
collection: string;
|
|
284
|
+
queryParams: QueryParams;
|
|
285
|
+
queryOptions: QueryOptions;
|
|
286
|
+
loadQueries: (entity: T) => EntityLoadQuery<DataEntity>[];
|
|
287
|
+
store: any;
|
|
288
|
+
constructor(collection: string, store: any, queryParams: QueryParams, queryOptions: QueryOptions, loadQueries?: (entity: T) => EntityLoadQuery<DataEntity>[]);
|
|
289
|
+
static areBatchableEqualityQueries<T>(queries: EntityLoadQuery<T>[]): boolean;
|
|
290
|
+
/**
|
|
291
|
+
* Optimize N+1 loads: N parents requesting children with one equality filter
|
|
292
|
+
* each (e.g. [['__postId', '==', x]]) would otherwise cause N separate requests.
|
|
293
|
+
* With no queryOptions, compatible requests can be combined into an 'in' query;
|
|
294
|
+
* load() then splits it into backend-sized chunks of at most 30 values.
|
|
295
|
+
* See https://firebase.google.com/docs/firestore/query-data/queries#in_and_array-contains-any.
|
|
296
|
+
*
|
|
297
|
+
* Batching changes the query key when a parent is added or removed. Tracking
|
|
298
|
+
* only the whole query's lastLoadTime would then lose incremental-load reuse
|
|
299
|
+
* and could refetch already-loaded children. The current loader tracks cutoff
|
|
300
|
+
* times per field/value and groups compatible times before chunking, retaining
|
|
301
|
+
* that reuse while reducing separate backend requests.
|
|
302
|
+
*/
|
|
303
|
+
static optimize<T>(queries: EntityLoadQuery<T>[]): EntityLoadQuery<T>[];
|
|
304
|
+
}
|
|
305
|
+
/**
|
|
306
|
+
* Description of a nested live query. CachedListenersService establishes the
|
|
307
|
+
* listener using the caller's injector and processes further child descriptors
|
|
308
|
+
* as parent records change. Constructing a descriptor alone opens no listener.
|
|
309
|
+
*/
|
|
310
|
+
declare class EntityStreamQuery<T> {
|
|
311
|
+
collection: string;
|
|
312
|
+
queryParams: QueryParams;
|
|
313
|
+
queryOptions: QueryOptions;
|
|
314
|
+
streamQueries: (entity: T) => EntityStreamQuery<DataEntity>[];
|
|
315
|
+
store: any;
|
|
316
|
+
constructor(collection: string, store: any, queryParams: QueryParams, queryOptions: QueryOptions, streamQueries?: (entity: T) => EntityStreamQuery<DataEntity>[]);
|
|
317
|
+
static areBatchableEqualityQueries<T>(queries: EntityStreamQuery<T>[]): boolean;
|
|
318
|
+
/**
|
|
319
|
+
* Optimize N+1 streams: combine compatible single-equality child queries such
|
|
320
|
+
* as [['__postId', '==', x]], with no queryOptions, into one descriptor. The
|
|
321
|
+
* multiplexer opens 'in' listeners with at most 30 values per batch downstream.
|
|
322
|
+
* See https://firebase.google.com/docs/firestore/query-data/queries#in_and_array-contains-any.
|
|
323
|
+
*
|
|
324
|
+
* The pairwise diff in CachedListenersService re-evaluates nested queries only
|
|
325
|
+
* for changed parents. The initial N parents can be collapsed together, while
|
|
326
|
+
* later individual changes typically request a single value; the multiplexer
|
|
327
|
+
* manages those sparse listeners and repacks them when appropriate.
|
|
328
|
+
*
|
|
329
|
+
* Batched listeners share the parent component's DestroyRef for cleanup, just
|
|
330
|
+
* as individual listeners do. Batching does not give them a longer lifetime.
|
|
331
|
+
*/
|
|
332
|
+
static optimize<T>(queries: EntityStreamQuery<T>[]): EntityStreamQuery<T>[];
|
|
333
|
+
}
|
|
334
|
+
|
|
335
|
+
/**
|
|
336
|
+
* Add in-memory entity state, stream-change application and synchronous selectors.
|
|
337
|
+
* Selectors hide soft-deleted records and only inspect already-loaded state;
|
|
338
|
+
* they do not query the backend. Used by frontend and mock backend stores.
|
|
339
|
+
*/
|
|
340
|
+
declare function withEntitiesAndSelectMethods<S extends DataEntity>(): _ngrx_signals.SignalStoreFeature<_ngrx_signals.EmptyFeatureResult, {
|
|
341
|
+
state: {
|
|
342
|
+
entityMap: _ngrx_signals_entities.EntityMap<S>;
|
|
343
|
+
ids: _ngrx_signals_entities.EntityId[];
|
|
344
|
+
};
|
|
345
|
+
props: {
|
|
346
|
+
entities: _angular_core.Signal<S[]>;
|
|
347
|
+
};
|
|
348
|
+
methods: {
|
|
349
|
+
handleStreamChanges: (entitiesToAdd: S[], entitiesToModify: S[], entitiesToRemove: string[]) => void;
|
|
350
|
+
selectEntity: (id: string) => S | null;
|
|
351
|
+
selectFirst: (queryParams: QueryParams, queryOptions: QueryOptions) => S | null;
|
|
352
|
+
selectEntities: (queryParams: QueryParams, queryOptions: QueryOptions) => S[];
|
|
353
|
+
};
|
|
354
|
+
}>;
|
|
355
|
+
/**
|
|
356
|
+
* Add collection-specific load/stream/write methods to an NgRx signal store.
|
|
357
|
+
* Provide one root store per collection so components share records and listeners.
|
|
358
|
+
* DATA_ACCESS selects the backend. The app ends listeners through the cache service
|
|
359
|
+
* and explicitly chooses which local stores to reset during logout.
|
|
360
|
+
*
|
|
361
|
+
* @example
|
|
362
|
+
* export const ProblemStore = signalStore(
|
|
363
|
+
* { providedIn: 'root' },
|
|
364
|
+
* withEntitiesAndDBMethods<Problem>(problemEntity.collection),
|
|
365
|
+
* );
|
|
366
|
+
*/
|
|
367
|
+
declare function withEntitiesAndDBMethods<S extends DataEntity>(collectionName: string): _ngrx_signals.SignalStoreFeature<_ngrx_signals.EmptyFeatureResult, {
|
|
368
|
+
state: {
|
|
369
|
+
entityMap: _ngrx_signals_entities.EntityMap<S>;
|
|
370
|
+
ids: _ngrx_signals_entities.EntityId[];
|
|
371
|
+
};
|
|
372
|
+
props: {
|
|
373
|
+
entities: _angular_core.Signal<S[]>;
|
|
374
|
+
};
|
|
375
|
+
methods: {
|
|
376
|
+
handleStreamChanges: (entitiesToAdd: S[], entitiesToModify: S[], entitiesToRemove: string[]) => void;
|
|
377
|
+
selectEntity: (id: string) => S;
|
|
378
|
+
selectFirst: (queryParams: QueryParams, queryOptions: QueryOptions) => S;
|
|
379
|
+
selectEntities: (queryParams: QueryParams, queryOptions: QueryOptions) => S[];
|
|
380
|
+
init: (entities: S[]) => void;
|
|
381
|
+
reset: () => void;
|
|
382
|
+
stream: (queryParams: QueryParams, queryOptions: QueryOptions, injector: any, streamQueries?: (entity: S) => EntityStreamQuery<DataEntity>[], options?: {
|
|
383
|
+
loading?: WritableSignal<boolean>;
|
|
384
|
+
}) => Promise<void>;
|
|
385
|
+
load: (queryParams: QueryParams, queryOptions: QueryOptions, loadQueries?: (entity: S) => EntityLoadQuery<DataEntity>[], options?: {
|
|
386
|
+
loading?: WritableSignal<boolean>;
|
|
387
|
+
}) => Promise<void>;
|
|
388
|
+
count: (queryParams: QueryParams, queryOptions: QueryOptions, options?: {
|
|
389
|
+
loading?: WritableSignal<boolean>;
|
|
390
|
+
}) => Promise<number>;
|
|
391
|
+
aggregate: <T extends {
|
|
392
|
+
[k: string]: number;
|
|
393
|
+
}>(queryParams: QueryParams, queryOptions: QueryOptions, aggregateParams: { [K in keyof T]: [string] | [string, string]; }, options?: {
|
|
394
|
+
loading?: WritableSignal<boolean>;
|
|
395
|
+
}) => Promise<{ [K in keyof T]: number | null; }>;
|
|
396
|
+
increment: (id: string, field: string, delta: number, options?: {
|
|
397
|
+
loading?: WritableSignal<boolean>;
|
|
398
|
+
optimistic?: boolean;
|
|
399
|
+
}) => Promise<void>;
|
|
400
|
+
add: (entityOpId: NewDataEntity<S>, options?: {
|
|
401
|
+
optimistic?: boolean;
|
|
402
|
+
loading?: WritableSignal<boolean>;
|
|
403
|
+
snackBarConfig?: {
|
|
404
|
+
successMessage: string;
|
|
405
|
+
failureMessage: string;
|
|
406
|
+
undoOnAction?: boolean;
|
|
407
|
+
config?: FeedbackConfig;
|
|
408
|
+
};
|
|
409
|
+
batchConfig?: {
|
|
410
|
+
batch: WriteBatchI;
|
|
411
|
+
revertBatch: WriteBatchI;
|
|
412
|
+
patchFns: Array<() => void>;
|
|
413
|
+
revertFns: Array<() => void>;
|
|
414
|
+
dbRevertFns: Array<() => void>;
|
|
415
|
+
optimistic?: boolean;
|
|
416
|
+
};
|
|
417
|
+
}) => Promise<void>;
|
|
418
|
+
update: (id: string, changes: Partial<S>, options?: {
|
|
419
|
+
optimistic?: boolean;
|
|
420
|
+
loading?: WritableSignal<boolean>;
|
|
421
|
+
snackBarConfig?: {
|
|
422
|
+
successMessage: string;
|
|
423
|
+
failureMessage: string;
|
|
424
|
+
undoOnAction?: boolean;
|
|
425
|
+
config?: FeedbackConfig;
|
|
426
|
+
};
|
|
427
|
+
batchConfig?: {
|
|
428
|
+
batch: WriteBatchI;
|
|
429
|
+
revertBatch: WriteBatchI;
|
|
430
|
+
patchFns?: Array<() => void>;
|
|
431
|
+
revertFns: Array<() => void>;
|
|
432
|
+
dbRevertFns: Array<() => void>;
|
|
433
|
+
optimistic?: boolean;
|
|
434
|
+
};
|
|
435
|
+
}) => Promise<void>;
|
|
436
|
+
remove: (id: string, options?: {
|
|
437
|
+
optimistic?: boolean;
|
|
438
|
+
loading?: WritableSignal<boolean>;
|
|
439
|
+
snackBarConfig?: {
|
|
440
|
+
successMessage: string;
|
|
441
|
+
failureMessage: string;
|
|
442
|
+
undoOnAction?: boolean;
|
|
443
|
+
config?: FeedbackConfig;
|
|
444
|
+
};
|
|
445
|
+
batchConfig?: {
|
|
446
|
+
batch: WriteBatchI;
|
|
447
|
+
revertBatch: WriteBatchI;
|
|
448
|
+
patchFns?: Array<() => void>;
|
|
449
|
+
revertFns: Array<() => void>;
|
|
450
|
+
dbRevertFns: Array<() => void>;
|
|
451
|
+
optimistic?: boolean;
|
|
452
|
+
};
|
|
453
|
+
}) => Promise<void>;
|
|
454
|
+
};
|
|
455
|
+
}>;
|
|
456
|
+
|
|
457
|
+
interface CachedConnection {
|
|
458
|
+
queryKey: string;
|
|
459
|
+
registeredSet: Set<DestroyRef>;
|
|
460
|
+
closed?: boolean;
|
|
461
|
+
}
|
|
462
|
+
/**
|
|
463
|
+
* CachedListenersService manages database connections and their lifecycles to
|
|
464
|
+
* ensure optimal performance, prevent memory leaks, and solve the N+1 query problem.
|
|
465
|
+
*
|
|
466
|
+
* Responsibilities:
|
|
467
|
+
* 1. **Listener Pooling**: Deduplicates active database snapshot listeners. If
|
|
468
|
+
* multiple components request the exact same query, only one actual database
|
|
469
|
+
* listener is opened. Components share one root store per collection, so the
|
|
470
|
+
* shared listener updates the same records for all those components.
|
|
471
|
+
* 2. **Reference Counting & Lifecycle Management**: Tracks which components are using
|
|
472
|
+
* which stream via their Angular `DestroyRef`. When a component is destroyed, its
|
|
473
|
+
* reference is removed.
|
|
474
|
+
* 3. **Graceful Teardown**: Implements a 5-second grace period before fully closing a
|
|
475
|
+
* database connection after its last reference drops. This prevents UI flicker and
|
|
476
|
+
* unnecessary DB reads if the user navigates away and immediately back.
|
|
477
|
+
* 4. **Load Time Tracking (One-shot Loads)**: Tracks `lastLoadTime` for general queries
|
|
478
|
+
* and precise `entityLoadTime` for optimized batch equality queries. This enables
|
|
479
|
+
* incremental (delta-only) fetching, drastically reducing bandwidth by only fetching
|
|
480
|
+
* entities modified since the last load.
|
|
481
|
+
*/
|
|
482
|
+
declare class CachedListenersService {
|
|
483
|
+
private db;
|
|
484
|
+
/** Prevent nested stream callbacks from restarting listeners after global teardown. */
|
|
485
|
+
private streamGeneration;
|
|
486
|
+
private queryLogger;
|
|
487
|
+
private streamErrors;
|
|
488
|
+
private nestedObservers;
|
|
489
|
+
private reportStreamError;
|
|
490
|
+
/** Dispose nested signal observers on component destruction or global listener teardown. */
|
|
491
|
+
private observeNested;
|
|
492
|
+
/** Nested asynchronous failures, which cannot be returned from the initial stream call. */
|
|
493
|
+
readonly errors$: Observable<unknown>;
|
|
494
|
+
/** Listener claims keyed by collection and canonical query. */
|
|
495
|
+
private connectionByQueryKey;
|
|
496
|
+
/** Active equality multiplexers keyed by collection and field. */
|
|
497
|
+
private streamMultiplexers;
|
|
498
|
+
/** Close connection events. */
|
|
499
|
+
private closeConnection$;
|
|
500
|
+
/** Query cutoffs grouped by collection so resetting one store preserves the others. */
|
|
501
|
+
private lastLoadTime;
|
|
502
|
+
/** Per-value equality cutoffs grouped by collection, in local-clock milliseconds. */
|
|
503
|
+
private entityLoadTime;
|
|
504
|
+
getEntityLoadTime(collection: string, field: string, value: string): number;
|
|
505
|
+
setEntityLoadTime(collection: string, field: string, value: string, time: number): void;
|
|
506
|
+
/** Define a unique key for each connection. */
|
|
507
|
+
private getQueryKey;
|
|
508
|
+
/**
|
|
509
|
+
* Tears down active adapter listeners before authentication is removed.
|
|
510
|
+
* Retains records and load history so cached stores can keep loading deltas.
|
|
511
|
+
* Ordinary reads/writes already in flight still finish normally.
|
|
512
|
+
*/
|
|
513
|
+
teardownAllStreams(): void;
|
|
514
|
+
/** Forget all query/value cutoffs for one collection when its store is reset. */
|
|
515
|
+
clearLoadHistory(collection: string): void;
|
|
516
|
+
/**
|
|
517
|
+
* Explicitly close all listeners and clear every collection's load history, e.g. in tests.
|
|
518
|
+
* Does not clear entity records or cancel pending reads/writes.
|
|
519
|
+
*/
|
|
520
|
+
clearCache(): void;
|
|
521
|
+
/** Return whether a stream exists for this query. */
|
|
522
|
+
isStreamForQuery(collection: string, queryParams: QueryParams, queryOptions: QueryOptions): boolean;
|
|
523
|
+
/** Return whether a specific ID is currently being streamed by a multiplexer. */
|
|
524
|
+
isIdStreamed(collection: string, field: string, id: string): boolean;
|
|
525
|
+
/** Get the last load time for a particular query. */
|
|
526
|
+
getLastLoadTime(collection: string, queryParams: QueryParams, queryOptions: QueryOptions): number;
|
|
527
|
+
/** Set the last load time for a particular query. */
|
|
528
|
+
setLastLoadTime(collection: string, queryParams: QueryParams, queryOptions: QueryOptions, time: number): void;
|
|
529
|
+
/** Gets a cached connection if one exists. */
|
|
530
|
+
private getConnection;
|
|
531
|
+
/**
|
|
532
|
+
* Attach/reuse a general query listener for this store and calling component.
|
|
533
|
+
* DestroyRef releases the component's claim after the navigation grace period;
|
|
534
|
+
* session resets bypass that delay. Optional descriptors add nested streams.
|
|
535
|
+
*/
|
|
536
|
+
processStreamQuery<T extends DataEntity>(collection: string, store: any, queryParams: QueryParams, queryOptions: QueryOptions, injector: any, streamQueries?: (entity: T) => EntityStreamQuery<DataEntity>[], options?: {
|
|
537
|
+
loading?: WritableSignal<boolean>;
|
|
538
|
+
}): Promise<CachedConnection>;
|
|
539
|
+
/**
|
|
540
|
+
* Optimized fast-path for simple streaming queries (e.g., `id in [1, 2, 3]`).
|
|
541
|
+
* Instead of managing distinct complex RxJS subscription chains for every component, this delegates
|
|
542
|
+
* ID registration to a centralized `StreamMultiplexer` (per collection/field).
|
|
543
|
+
*
|
|
544
|
+
* It also handles nested `streamQueries` (e.g. streaming a post's author) by listening to changes
|
|
545
|
+
* to the parent entities, diffing them (`pairwise`), and setting up streams for the new children.
|
|
546
|
+
*/
|
|
547
|
+
processSimpleStreamQuery<T extends DataEntity>(collection: string, field: string, ids: string[], store: any, injector: any, streamQueries?: (entity: T) => EntityStreamQuery<DataEntity>[], options?: {
|
|
548
|
+
loading?: WritableSignal<boolean>;
|
|
549
|
+
}): Promise<void>;
|
|
550
|
+
private createConnection;
|
|
551
|
+
constructor(db: DataAccess);
|
|
552
|
+
static ɵfac: _angular_core.ɵɵFactoryDeclaration<CachedListenersService, never>;
|
|
553
|
+
static ɵprov: _angular_core.ɵɵInjectableDeclaration<CachedListenersService>;
|
|
554
|
+
}
|
|
555
|
+
|
|
556
|
+
/**
|
|
557
|
+
* Combines component requests for one store/collection/field into batched 'in'
|
|
558
|
+
* queries through DataAccess. The current batch size follows Firestore's limit.
|
|
559
|
+
*
|
|
560
|
+
* It manages two pools of logical listeners (transport connections belong to the adapter):
|
|
561
|
+
* 1. `batchedListeners`: fully packed 'in' queries (chunks of 30 IDs).
|
|
562
|
+
* 2. `singleListeners`: sparse 'in' queries handling newly requested IDs.
|
|
563
|
+
*
|
|
564
|
+
* It balances stream connection limits with UI rendering performance by maintaining
|
|
565
|
+
* sparse streams until a threshold is reached, at which point it automatically triggers
|
|
566
|
+
* an `executeSmartRepack` to consolidate streams and release redundant listeners.
|
|
567
|
+
*
|
|
568
|
+
* It tracks component lifecycles using `DestroyRef` to gracefully tear down streams
|
|
569
|
+
* when components are destroyed and their requested IDs become "orphaned".
|
|
570
|
+
*/
|
|
571
|
+
declare class StreamMultiplexer<T extends DataEntity = DataEntity> {
|
|
572
|
+
private collection;
|
|
573
|
+
private field;
|
|
574
|
+
private db;
|
|
575
|
+
private store;
|
|
576
|
+
private queryLogger;
|
|
577
|
+
private onError;
|
|
578
|
+
private retiring;
|
|
579
|
+
private generation;
|
|
580
|
+
private destroyRefsById;
|
|
581
|
+
private idsByDestroyRef;
|
|
582
|
+
private batchedListeners;
|
|
583
|
+
private singleListeners;
|
|
584
|
+
private readonly MAX_ORPHANED_IDS_PER_BATCH;
|
|
585
|
+
private readonly MAX_SINGLE_LISTENERS_BEFORE_REPACK;
|
|
586
|
+
constructor(collection: string, field: string, db: DataAccess, store: {
|
|
587
|
+
handleStreamChanges(entitiesToAdd: T[], entitiesToModify: T[], entitiesToRemove: string[]): void;
|
|
588
|
+
}, // NgRx Signal Store with handleStreamChanges
|
|
589
|
+
queryLogger?: Logger, onError?: (error: unknown) => void);
|
|
590
|
+
/**
|
|
591
|
+
* Checks if an ID is currently being actively streamed by any component.
|
|
592
|
+
*/
|
|
593
|
+
isIdActive(id: string): boolean;
|
|
594
|
+
/**
|
|
595
|
+
* Registers a list of query values to stream through the configured adapter.
|
|
596
|
+
* Duplicate requests for the same ID are deduplicated.
|
|
597
|
+
* Automatically handles teardown when the provided destroyRef fires.
|
|
598
|
+
*/
|
|
599
|
+
registerIds(ids: string[], destroyRef: DestroyRef): void;
|
|
600
|
+
/**
|
|
601
|
+
* Evaluates whether the multiplexer should execute a repack operation.
|
|
602
|
+
* A repack is executed if either:
|
|
603
|
+
* 1. A new ID request pushes the projected single listener count over the MAX_SINGLE_LISTENERS_BEFORE_REPACK threshold.
|
|
604
|
+
* 2. An orphaned batch cleanup check triggered this evaluation.
|
|
605
|
+
*
|
|
606
|
+
* If new IDs are requested but the threshold is not met, this method simply spins up
|
|
607
|
+
* a single sparse stream for those IDs to prioritize immediate UI rendering speed.
|
|
608
|
+
*
|
|
609
|
+
* @param newIds - Array of newly requested IDs that are not yet streamed.
|
|
610
|
+
*/
|
|
611
|
+
private checkAndExecuteRepack;
|
|
612
|
+
/**
|
|
613
|
+
* Completely tears down all active streams and resets the multiplexer state.
|
|
614
|
+
* Useful when the user logs out or the entire parent collection listener is destroyed.
|
|
615
|
+
*/
|
|
616
|
+
teardownAll(): void;
|
|
617
|
+
/**
|
|
618
|
+
* Identifies any listeners (both single and batched) where EVERY SINGLE ID has 0 active holds.
|
|
619
|
+
* If an entire stream is completely abandoned, it is immediately unsubscribed and purged to prevent
|
|
620
|
+
* dead sockets from hanging around indefinitely.
|
|
621
|
+
*/
|
|
622
|
+
private cleanupEmptyListeners;
|
|
623
|
+
/**
|
|
624
|
+
* Checks if any of the currently active websocket listeners has too many "orphaned" IDs
|
|
625
|
+
* (IDs that are being streamed from Firestore but are no longer requested by any component).
|
|
626
|
+
*/
|
|
627
|
+
private hasBatchWithTooManyOrphans;
|
|
628
|
+
/**
|
|
629
|
+
* Consolidates sparse streams and tears down bloated batches.
|
|
630
|
+
*
|
|
631
|
+
* It uses a greedy mathematical algorithm to evaluate "candidate batches" (those with <= 25 active IDs)
|
|
632
|
+
* and determine if tearing them down and bundling their active IDs with the single listeners will
|
|
633
|
+
* result in a net reduction in the total number of websocket streams.
|
|
634
|
+
*
|
|
635
|
+
* Note: This method does not check threshold conditions before executing. Callers
|
|
636
|
+
* (e.g. checkAndExecuteRepack) must verify that a repack is strictly necessary
|
|
637
|
+
* before invoking this method.
|
|
638
|
+
*
|
|
639
|
+
* @param newIds - Array of newly requested IDs that need to be streamed.
|
|
640
|
+
*/
|
|
641
|
+
private executeSmartRepack;
|
|
642
|
+
/**
|
|
643
|
+
* Opens new Firestore snapshot streams for the given chunks of IDs.
|
|
644
|
+
*
|
|
645
|
+
* @param newChunks - The fully chunked arrays of IDs to stream (max 30 per chunk).
|
|
646
|
+
* @param oldBatchesToTeardown - The old websocket listeners that these new chunks are replacing.
|
|
647
|
+
* They are only torn down *after* the new stream emits its first
|
|
648
|
+
* payload, preventing UI flickering.
|
|
649
|
+
*/
|
|
650
|
+
private startNewBatches;
|
|
651
|
+
/**
|
|
652
|
+
* Unsubscribes from the old listener sockets to clean up the network connections.
|
|
653
|
+
*/
|
|
654
|
+
private teardownOldListeners;
|
|
655
|
+
/**
|
|
656
|
+
* Cleans up the multiplexer state arrays by removing the objects for the torn down streams
|
|
657
|
+
* and pushing the newly created streams into the correct `batchedListeners` or `singleListeners` array.
|
|
658
|
+
*/
|
|
659
|
+
private finalizeRepackState;
|
|
660
|
+
/**
|
|
661
|
+
* Utility to split an array of IDs into smaller chunks (max 30 for Firestore 'in' queries).
|
|
662
|
+
*/
|
|
663
|
+
private chunkArray;
|
|
664
|
+
/**
|
|
665
|
+
* Takes the raw DocumentChange payload from Firestore and formats it into
|
|
666
|
+
* added/modified/removed arrays that the NgRx Signal Store can easily process.
|
|
667
|
+
*/
|
|
668
|
+
private patchToStore;
|
|
669
|
+
}
|
|
670
|
+
|
|
671
|
+
/**
|
|
672
|
+
* Present successful-write feedback with an optional compensating undo.
|
|
673
|
+
* Backend restoration must succeed before local state is reverted. Inverse
|
|
674
|
+
* operations run in reverse order so dependent writes unwind correctly.
|
|
675
|
+
* Undo is a new write attempt, not cancellation of the original commit.
|
|
676
|
+
*/
|
|
677
|
+
declare function openSnackBarWithUndoOption(snackBar: DataFeedback, snackBarConfig: {
|
|
678
|
+
successMessage: string;
|
|
679
|
+
failureMessage: string;
|
|
680
|
+
undoOnAction?: boolean;
|
|
681
|
+
config?: FeedbackConfig;
|
|
682
|
+
}, revertFns: Array<() => void>, dbRevertFns: Array<() => void>, revertBatch?: WriteBatchI): void;
|
|
683
|
+
|
|
684
|
+
export { BATCH_WRITE_SERVICE, CachedListenersService, DATABASE_SERVICE, DATA_ACCESS, DATA_FEEDBACK, EntityLoadQuery, EntityStreamQuery, NOOP_DATA_FEEDBACK, StreamMultiplexer, compareDataTimestamps, dataTimestamp, dataTimestampEquals, dataTimestampFromDate, dataTimestampFromMillis, dataTimestampNow, dataTimestampToDate, dataTimestampToMillis, defineEntity, entityInQueryResults, fieldValue, isDataTimestamp, openSnackBarWithUndoOption, processBatchWrite, processLoadQueries, providePlatformData, queryEntities, queryOrderings, selectEntities, stableQueryKey, withEntitiesAndDBMethods, withEntitiesAndSelectMethods };
|
|
685
|
+
export type { AnyEntity, BatchConfig, BatchWriteService, CachedConnection, DataAccess, DataEntity, DataFeedback, DataTimestamp, DatabaseService, EntityDefinition, EntityType, FeedbackConfig, NewDataEntity, PlatformDataOptions, QueryOptions, QueryParams, WriteBatchI, WriteOptions };
|
|
686
|
+
//# sourceMappingURL=tech4good-platform-data.d.ts.map
|