@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,479 @@
|
|
|
1
|
+
import * as i0 from '@angular/core';
|
|
2
|
+
import { InjectionToken, inject, DestroyRef, signal, effect, untracked, Injectable, Injector } from '@angular/core';
|
|
3
|
+
import { defer, NEVER, throwError, Observable, delay, startWith, pairwise, map } from 'rxjs';
|
|
4
|
+
import { dataTimestamp, isDataTimestamp, withEntitiesAndSelectMethods, queryEntities, fieldValue, dataTimestampNow, DATA_FEEDBACK, DATA_ACCESS, processBatchWrite, BATCH_WRITE_SERVICE } from '@tech4good/platform-data';
|
|
5
|
+
import { injectLogger } from '@tech4good/platform-logging';
|
|
6
|
+
import { signalStoreFeature, withMethods, patchState } from '@ngrx/signals';
|
|
7
|
+
import { setAllEntities, removeEntity, updateEntity, setEntity } from '@ngrx/signals/entities';
|
|
8
|
+
|
|
9
|
+
const MOCK_PERSISTENCE = new InjectionToken('PlatformMockPersistence', {
|
|
10
|
+
providedIn: 'root', factory: () => ({ enabled: false, keyPrefix: 'mockDB_' }),
|
|
11
|
+
});
|
|
12
|
+
function serialize(value) { return JSON.stringify(value); }
|
|
13
|
+
function deserialize(text) {
|
|
14
|
+
const value = JSON.parse(text, (_, value) => {
|
|
15
|
+
if (value?.__type === 'DataTimestamp' || value?.__type === 'Timestamp') {
|
|
16
|
+
// Read previously persisted mock timestamps without loading the Firebase SDK.
|
|
17
|
+
return dataTimestamp(value.seconds, value.nanoseconds);
|
|
18
|
+
}
|
|
19
|
+
return value;
|
|
20
|
+
});
|
|
21
|
+
if (!Array.isArray(value) || value.some(entity => !entity || typeof entity.__id !== 'string' ||
|
|
22
|
+
!isDataTimestamp(entity._createdAt) || !isDataTimestamp(entity._updatedAt) || typeof entity._deleted !== 'boolean')) {
|
|
23
|
+
throw new Error('Invalid persisted mock entities.');
|
|
24
|
+
}
|
|
25
|
+
return value;
|
|
26
|
+
}
|
|
27
|
+
/**
|
|
28
|
+
* Build an app-owned mock collection with selectors and optional localStorage
|
|
29
|
+
* persistence. init prefers valid saved records over seeds; replaceAll installs
|
|
30
|
+
* explicit records. Storage events synchronize other tabs, and injector
|
|
31
|
+
* destruction removes the event listener. This is mock backend state, not the
|
|
32
|
+
* frontend store populated by load/stream.
|
|
33
|
+
*/
|
|
34
|
+
function withEntitiesForMockDB(collectionName) {
|
|
35
|
+
return signalStoreFeature(withEntitiesAndSelectMethods(), withMethods(store => {
|
|
36
|
+
const config = inject(MOCK_PERSISTENCE);
|
|
37
|
+
const destroyRef = inject(DestroyRef);
|
|
38
|
+
const logger = injectLogger('data');
|
|
39
|
+
const key = `${config.keyPrefix ?? 'mockDB_'}${collectionName}`;
|
|
40
|
+
const selectId = (entity) => entity.__id;
|
|
41
|
+
let listening = false;
|
|
42
|
+
const onStorage = (event) => {
|
|
43
|
+
if (event.key !== key || !event.newValue)
|
|
44
|
+
return;
|
|
45
|
+
try {
|
|
46
|
+
patchState(store, setAllEntities(deserialize(event.newValue), { selectId }));
|
|
47
|
+
}
|
|
48
|
+
catch (error) {
|
|
49
|
+
logger.warn('Could not read persisted mock data', error);
|
|
50
|
+
}
|
|
51
|
+
};
|
|
52
|
+
const persist = () => {
|
|
53
|
+
if (!config.enabled || typeof window === 'undefined')
|
|
54
|
+
return;
|
|
55
|
+
try {
|
|
56
|
+
window.localStorage.setItem(key, serialize(store.entities()));
|
|
57
|
+
}
|
|
58
|
+
catch (error) {
|
|
59
|
+
logger.warn('Could not persist mock data', error);
|
|
60
|
+
}
|
|
61
|
+
};
|
|
62
|
+
destroyRef.onDestroy(() => { if (listening)
|
|
63
|
+
window.removeEventListener('storage', onStorage); });
|
|
64
|
+
return {
|
|
65
|
+
/** Restore valid saved records when enabled, otherwise use the supplied fixtures. */
|
|
66
|
+
init(entities) {
|
|
67
|
+
let initial = entities;
|
|
68
|
+
if (config.enabled && typeof window !== 'undefined') {
|
|
69
|
+
try {
|
|
70
|
+
const saved = window.localStorage.getItem(key);
|
|
71
|
+
if (saved)
|
|
72
|
+
initial = deserialize(saved);
|
|
73
|
+
}
|
|
74
|
+
catch (error) {
|
|
75
|
+
logger.warn('Could not restore mock data; using seed data', error);
|
|
76
|
+
}
|
|
77
|
+
if (!listening) {
|
|
78
|
+
window.addEventListener('storage', onStorage);
|
|
79
|
+
listening = true;
|
|
80
|
+
}
|
|
81
|
+
}
|
|
82
|
+
patchState(store, setAllEntities(initial, { selectId }));
|
|
83
|
+
},
|
|
84
|
+
add(entity) { patchState(store, setEntity(entity, { selectId })); persist(); },
|
|
85
|
+
update(id, changes) {
|
|
86
|
+
if (!store.entityMap()[id])
|
|
87
|
+
throw new Error(`Missing mock entity ${collectionName}/${id}`);
|
|
88
|
+
patchState(store, updateEntity({ id, changes }, { selectId }));
|
|
89
|
+
persist();
|
|
90
|
+
},
|
|
91
|
+
delete(id) { patchState(store, removeEntity(id)); persist(); },
|
|
92
|
+
/** Atomic batch installation bypasses persistence restore. */
|
|
93
|
+
replaceAll(entities) { patchState(store, setAllEntities(entities, { selectId })); persist(); },
|
|
94
|
+
};
|
|
95
|
+
}));
|
|
96
|
+
}
|
|
97
|
+
|
|
98
|
+
const MOCK_COLLECTIONS = new InjectionToken('PlatformMockCollections', {
|
|
99
|
+
providedIn: 'root', factory: () => ({}),
|
|
100
|
+
});
|
|
101
|
+
/**
|
|
102
|
+
* Small signal-backed collection with no persistence or injection requirement.
|
|
103
|
+
* Used for generated entities without a custom mock store and for direct seeds
|
|
104
|
+
* passed to provideMockData. Use withEntitiesForMockDB for opt-in persistence.
|
|
105
|
+
*/
|
|
106
|
+
function createMockCollection(entities = []) {
|
|
107
|
+
const state = signal({}, ...(ngDevMode ? [{ debugName: "state" }] : /* istanbul ignore next */ []));
|
|
108
|
+
const replaceAll = (values) => state.set(Object.fromEntries(values.map(value => [value.__id, value])));
|
|
109
|
+
replaceAll(entities);
|
|
110
|
+
return {
|
|
111
|
+
entityMap: state.asReadonly(), init: replaceAll, replaceAll,
|
|
112
|
+
add: entity => state.update(map => ({ ...map, [entity.__id]: entity })),
|
|
113
|
+
update: (id, changes) => {
|
|
114
|
+
if (!state()[id])
|
|
115
|
+
throw new Error(`Missing mock entity: ${id}`);
|
|
116
|
+
state.update(map => ({ ...map, [id]: { ...map[id], ...changes } }));
|
|
117
|
+
},
|
|
118
|
+
};
|
|
119
|
+
}
|
|
120
|
+
const wait = (ms) => new Promise(resolve => setTimeout(resolve, ms));
|
|
121
|
+
/**
|
|
122
|
+
* In-memory DataAccess adapter for local development and tests. Reactive
|
|
123
|
+
* collections drive streams; configurable delays, errors and stalled reads
|
|
124
|
+
* exercise loading/failure UI. This does not enforce Firestore security rules.
|
|
125
|
+
*/
|
|
126
|
+
class MockDataService {
|
|
127
|
+
injector;
|
|
128
|
+
DB = inject(MOCK_COLLECTIONS);
|
|
129
|
+
GET_LATENCY_SIMULATION_DELAY = 100;
|
|
130
|
+
PUT_LATENCY_SIMULATION_DELAY = 300;
|
|
131
|
+
/**
|
|
132
|
+
* Collections that throw/reject on reads. Configure through provideMockData({
|
|
133
|
+
* failCollections: [...] }) or mutate db.failCollections during a test to
|
|
134
|
+
* exercise error → recovery: make a read fail, verify the error banner, clear
|
|
135
|
+
* failCollections, click Retry, then verify the successful state.
|
|
136
|
+
*/
|
|
137
|
+
failCollections = [];
|
|
138
|
+
/**
|
|
139
|
+
* Collections whose reads never emit/resolve, simulating perpetual loading.
|
|
140
|
+
* Configure through provideMockData({ stallCollections: [...] }) or mutate
|
|
141
|
+
* db.stallCollections before the next read/subscription to exercise loading UI.
|
|
142
|
+
*/
|
|
143
|
+
stallCollections = [];
|
|
144
|
+
failWriteCollections = [];
|
|
145
|
+
constructor(injector) {
|
|
146
|
+
this.injector = injector;
|
|
147
|
+
}
|
|
148
|
+
createId() {
|
|
149
|
+
const bytes = crypto.getRandomValues(new Uint8Array(20));
|
|
150
|
+
const chars = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789';
|
|
151
|
+
return Array.from(bytes, byte => chars[byte % chars.length]).join('');
|
|
152
|
+
}
|
|
153
|
+
collection(name) {
|
|
154
|
+
const store = this.DB[name];
|
|
155
|
+
if (!store)
|
|
156
|
+
throw new Error(`No mock collection registered for "${name}". Register app-owned seeds with provideMockData().`);
|
|
157
|
+
return store;
|
|
158
|
+
}
|
|
159
|
+
async read(name) {
|
|
160
|
+
const store = this.collection(name);
|
|
161
|
+
if (this.stallCollections.includes(name))
|
|
162
|
+
return new Promise(() => { });
|
|
163
|
+
if (this.failCollections.includes(name))
|
|
164
|
+
throw new Error(`Simulated read error for collection: ${name}`);
|
|
165
|
+
await wait(this.GET_LATENCY_SIMULATION_DELAY);
|
|
166
|
+
return store;
|
|
167
|
+
}
|
|
168
|
+
/** Give each subscriber its own effect and release it when that subscription ends. */
|
|
169
|
+
observe(name, read) {
|
|
170
|
+
return defer(() => {
|
|
171
|
+
const store = this.collection(name);
|
|
172
|
+
if (this.stallCollections.includes(name))
|
|
173
|
+
return NEVER;
|
|
174
|
+
if (this.failCollections.includes(name))
|
|
175
|
+
return throwError(() => new Error(`Simulated read error for collection: ${name}`));
|
|
176
|
+
return new Observable(subscriber => {
|
|
177
|
+
const watcher = effect(() => {
|
|
178
|
+
try {
|
|
179
|
+
const value = read(store);
|
|
180
|
+
untracked(() => subscriber.next(value));
|
|
181
|
+
}
|
|
182
|
+
catch (error) {
|
|
183
|
+
subscriber.error(error);
|
|
184
|
+
}
|
|
185
|
+
}, { ...(ngDevMode ? { debugName: "watcher" } : /* istanbul ignore next */ {}), injector: this.injector, manualCleanup: true });
|
|
186
|
+
return () => watcher.destroy();
|
|
187
|
+
}).pipe(delay(this.GET_LATENCY_SIMULATION_DELAY));
|
|
188
|
+
});
|
|
189
|
+
}
|
|
190
|
+
streamEntity(name, id) {
|
|
191
|
+
return this.observe(name, store => store.entityMap()[id] ?? null);
|
|
192
|
+
}
|
|
193
|
+
streamEntities(name, params = [], options) {
|
|
194
|
+
return this.observe(name, store => queryEntities(store.entityMap(), params, options));
|
|
195
|
+
}
|
|
196
|
+
streamEntitiesChanges(name, params = [], options) {
|
|
197
|
+
// Keep the original snapshot -> pairwise -> changes flow. Capture the full
|
|
198
|
+
// map too, so a record that leaves the query can carry its deletion marker.
|
|
199
|
+
return this.observe(name, store => {
|
|
200
|
+
const entityMap = store.entityMap();
|
|
201
|
+
const entities = queryEntities(entityMap, params, options);
|
|
202
|
+
const matchingEntities = Object.create(null);
|
|
203
|
+
for (const entity of entities) {
|
|
204
|
+
matchingEntities[entity.__id] = entity;
|
|
205
|
+
}
|
|
206
|
+
return { matchingEntities, entityMap };
|
|
207
|
+
}).pipe(
|
|
208
|
+
// pairwise keeps separate prior state for each subscriber. Starting empty
|
|
209
|
+
// makes the first snapshot report every matching record as added.
|
|
210
|
+
startWith({ matchingEntities: {}, entityMap: {} }), pairwise(), map(([previous, current]) => {
|
|
211
|
+
const prevEntities = previous.matchingEntities;
|
|
212
|
+
const currEntities = current.matchingEntities;
|
|
213
|
+
const changes = [];
|
|
214
|
+
for (const key in currEntities) {
|
|
215
|
+
if (!Object.hasOwn(prevEntities, key)) {
|
|
216
|
+
changes.push({ type: 'added', docData: currEntities[key] });
|
|
217
|
+
}
|
|
218
|
+
else if (currEntities[key] !== prevEntities[key]) {
|
|
219
|
+
// Immutable record replacements detect changes even within one clock tick.
|
|
220
|
+
changes.push({ type: 'modified', docData: currEntities[key] });
|
|
221
|
+
}
|
|
222
|
+
}
|
|
223
|
+
// The original loop only inspected current matches and missed records
|
|
224
|
+
// that stopped matching. Report those removals using this snapshot's data.
|
|
225
|
+
for (const key in prevEntities) {
|
|
226
|
+
if (!Object.hasOwn(currEntities, key)) {
|
|
227
|
+
changes.push({ type: 'removed', docData: (current.entityMap[key] ?? prevEntities[key]) });
|
|
228
|
+
}
|
|
229
|
+
}
|
|
230
|
+
return changes;
|
|
231
|
+
}));
|
|
232
|
+
}
|
|
233
|
+
async getEntity(name, id) {
|
|
234
|
+
return (await this.read(name)).entityMap()[id] ?? null;
|
|
235
|
+
}
|
|
236
|
+
async getEntities(name, params = [], options) {
|
|
237
|
+
// Match the supplied filters, as the Firestore adapter does. The loader asks
|
|
238
|
+
// for _deleted == true separately so it can remove previously cached records.
|
|
239
|
+
// A frontend selectEntities call would hide those records and break that load.
|
|
240
|
+
return queryEntities((await this.read(name)).entityMap(), params, options);
|
|
241
|
+
}
|
|
242
|
+
async count(name, params = [], options) {
|
|
243
|
+
return (await this.getEntities(name, params, options)).length;
|
|
244
|
+
}
|
|
245
|
+
async aggregate(name, params, options, spec) {
|
|
246
|
+
const entities = await this.getEntities(name, params, options);
|
|
247
|
+
const result = {};
|
|
248
|
+
for (const [alias, [operator, field]] of Object.entries(spec)) {
|
|
249
|
+
const values = entities.map(entity => fieldValue(entity, field ?? '')).filter(value => typeof value === 'number');
|
|
250
|
+
if (operator === 'count')
|
|
251
|
+
result[alias] = entities.length;
|
|
252
|
+
else if (operator === 'sum' && field)
|
|
253
|
+
result[alias] = values.reduce((sum, value) => sum + value, 0);
|
|
254
|
+
else if (operator === 'average' && field)
|
|
255
|
+
result[alias] = values.length ? values.reduce((sum, value) => sum + value, 0) / values.length : null;
|
|
256
|
+
else
|
|
257
|
+
throw new Error(`Invalid aggregate ${alias}: ${operator}`);
|
|
258
|
+
}
|
|
259
|
+
return result;
|
|
260
|
+
}
|
|
261
|
+
async addEntity(collectionName, entity, batch) {
|
|
262
|
+
const entityFinal = Object.assign({}, entity, {
|
|
263
|
+
_createdAt: entity._createdAt ?? dataTimestampNow(),
|
|
264
|
+
_updatedAt: dataTimestampNow(),
|
|
265
|
+
_deleted: false,
|
|
266
|
+
});
|
|
267
|
+
const docRef = { path: `${collectionName}/${entity.__id}` };
|
|
268
|
+
if (batch) {
|
|
269
|
+
return batch.set(docRef, entityFinal);
|
|
270
|
+
}
|
|
271
|
+
else {
|
|
272
|
+
// A single write uses the collection's add method. Only batches need to
|
|
273
|
+
// stage a complete collection before replacing it atomically.
|
|
274
|
+
await wait(this.PUT_LATENCY_SIMULATION_DELAY);
|
|
275
|
+
const store = this.collection(collectionName);
|
|
276
|
+
if (!entity.__id)
|
|
277
|
+
throw new Error(`Invalid mock document path: ${docRef.path}`);
|
|
278
|
+
if (this.failWriteCollections.includes(collectionName))
|
|
279
|
+
throw new Error(`Simulated write error for collection: ${collectionName}`);
|
|
280
|
+
return store.add(entityFinal);
|
|
281
|
+
}
|
|
282
|
+
}
|
|
283
|
+
async updateEntity(collectionName, id, changes, batch) {
|
|
284
|
+
const changesFinal = Object.assign({}, changes, { __id: id, _updatedAt: dataTimestampNow() });
|
|
285
|
+
const docRef = { path: `${collectionName}/${id}` };
|
|
286
|
+
if (batch) {
|
|
287
|
+
return batch.update(docRef, changesFinal);
|
|
288
|
+
}
|
|
289
|
+
else {
|
|
290
|
+
await wait(this.PUT_LATENCY_SIMULATION_DELAY);
|
|
291
|
+
const store = this.collection(collectionName);
|
|
292
|
+
if (!store.entityMap()[id])
|
|
293
|
+
throw new Error(`Missing mock entity: ${docRef.path}`);
|
|
294
|
+
if (this.failWriteCollections.includes(collectionName))
|
|
295
|
+
throw new Error(`Simulated write error for collection: ${collectionName}`);
|
|
296
|
+
return store.update(id, changesFinal);
|
|
297
|
+
}
|
|
298
|
+
}
|
|
299
|
+
async removeEntity(collectionName, id, batch) {
|
|
300
|
+
const changes = { _updatedAt: dataTimestampNow(), _deleted: true };
|
|
301
|
+
const docRef = { path: `${collectionName}/${id}` };
|
|
302
|
+
if (batch) {
|
|
303
|
+
return batch.update(docRef, changes);
|
|
304
|
+
}
|
|
305
|
+
else {
|
|
306
|
+
await wait(this.PUT_LATENCY_SIMULATION_DELAY);
|
|
307
|
+
const store = this.collection(collectionName);
|
|
308
|
+
if (!store.entityMap()[id])
|
|
309
|
+
throw new Error(`Missing mock entity: ${docRef.path}`);
|
|
310
|
+
if (this.failWriteCollections.includes(collectionName))
|
|
311
|
+
throw new Error(`Simulated write error for collection: ${collectionName}`);
|
|
312
|
+
return store.update(id, changes);
|
|
313
|
+
}
|
|
314
|
+
}
|
|
315
|
+
async incrementEntityField(name, id, field, delta) {
|
|
316
|
+
await wait(this.PUT_LATENCY_SIMULATION_DELAY);
|
|
317
|
+
const store = this.collection(name);
|
|
318
|
+
if (this.failWriteCollections.includes(name))
|
|
319
|
+
throw new Error(`Simulated write error for collection: ${name}`);
|
|
320
|
+
const entity = store.entityMap()[id];
|
|
321
|
+
if (!entity)
|
|
322
|
+
throw new Error(`Missing mock entity: ${name}/${id}`);
|
|
323
|
+
const before = fieldValue(entity, field);
|
|
324
|
+
store.update(id, { [field]: (typeof before === 'number' ? before : 0) + delta, _updatedAt: dataTimestampNow() });
|
|
325
|
+
}
|
|
326
|
+
/** Stage all operations, validate, then install synchronously. No partial batch on failure. */
|
|
327
|
+
async commitOperations(operations) {
|
|
328
|
+
await wait(this.PUT_LATENCY_SIMULATION_DELAY);
|
|
329
|
+
const staged = new Map();
|
|
330
|
+
for (const operation of operations) {
|
|
331
|
+
const split = operation.path.lastIndexOf('/');
|
|
332
|
+
const name = operation.path.slice(0, split);
|
|
333
|
+
const id = operation.path.slice(split + 1);
|
|
334
|
+
if (split < 1 || !id)
|
|
335
|
+
throw new Error(`Invalid mock document path: ${operation.path}`);
|
|
336
|
+
const store = this.collection(name);
|
|
337
|
+
if (this.failWriteCollections.includes(name))
|
|
338
|
+
throw new Error(`Simulated write error for collection: ${name}`);
|
|
339
|
+
if (!staged.has(name))
|
|
340
|
+
staged.set(name, { ...store.entityMap() });
|
|
341
|
+
const values = staged.get(name);
|
|
342
|
+
if (operation.kind === 'update') {
|
|
343
|
+
if (!values[id])
|
|
344
|
+
throw new Error(`Missing mock entity: ${operation.path}`);
|
|
345
|
+
values[id] = { ...values[id], ...operation.value, __id: id };
|
|
346
|
+
}
|
|
347
|
+
else if (operation.kind === 'set')
|
|
348
|
+
values[id] = { ...operation.value, __id: id };
|
|
349
|
+
else
|
|
350
|
+
delete values[id];
|
|
351
|
+
}
|
|
352
|
+
for (const [name, values] of staged)
|
|
353
|
+
this.collection(name).replaceAll(Object.values(values));
|
|
354
|
+
}
|
|
355
|
+
static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "21.2.23", ngImport: i0, type: MockDataService, deps: [{ token: i0.Injector }], target: i0.ɵɵFactoryTarget.Injectable });
|
|
356
|
+
static ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "21.2.23", ngImport: i0, type: MockDataService, providedIn: 'root' });
|
|
357
|
+
}
|
|
358
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "21.2.23", ngImport: i0, type: MockDataService, decorators: [{
|
|
359
|
+
type: Injectable,
|
|
360
|
+
args: [{ providedIn: 'root' }]
|
|
361
|
+
}], ctorParameters: () => [{ type: i0.Injector }] });
|
|
362
|
+
/** One-use batch that defers mutations until commitOperations validates the whole batch. */
|
|
363
|
+
class WriteBatchMock {
|
|
364
|
+
db;
|
|
365
|
+
operations = [];
|
|
366
|
+
committed = false;
|
|
367
|
+
constructor(db) {
|
|
368
|
+
this.db = db;
|
|
369
|
+
}
|
|
370
|
+
append(kind, ref, value) {
|
|
371
|
+
if (this.committed)
|
|
372
|
+
throw new Error('This mock batch has already been committed.');
|
|
373
|
+
this.operations.push({ kind, path: ref.path, value });
|
|
374
|
+
return this;
|
|
375
|
+
}
|
|
376
|
+
set(ref, value) { return this.append('set', ref, value); }
|
|
377
|
+
update(ref, value) { return this.append('update', ref, value); }
|
|
378
|
+
delete(ref) { return this.append('delete', ref); }
|
|
379
|
+
async commit() {
|
|
380
|
+
if (this.committed)
|
|
381
|
+
throw new Error('This mock batch has already been committed.');
|
|
382
|
+
this.committed = true;
|
|
383
|
+
return this.db.commitOperations(this.operations);
|
|
384
|
+
}
|
|
385
|
+
}
|
|
386
|
+
/** Pair forward and inverse mock batches with the same feedback/rollback flow as Firestore. */
|
|
387
|
+
class MockBatchWriteService {
|
|
388
|
+
feedback = inject(DATA_FEEDBACK);
|
|
389
|
+
db = inject(DATA_ACCESS);
|
|
390
|
+
batchWrite(fn, options) {
|
|
391
|
+
return processBatchWrite(fn, options, new WriteBatchMock(this.db), new WriteBatchMock(this.db), this.feedback);
|
|
392
|
+
}
|
|
393
|
+
static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "21.2.23", ngImport: i0, type: MockBatchWriteService, deps: [], target: i0.ɵɵFactoryTarget.Injectable });
|
|
394
|
+
static ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "21.2.23", ngImport: i0, type: MockBatchWriteService, providedIn: 'root' });
|
|
395
|
+
}
|
|
396
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "21.2.23", ngImport: i0, type: MockBatchWriteService, decorators: [{
|
|
397
|
+
type: Injectable,
|
|
398
|
+
args: [{ providedIn: 'root' }]
|
|
399
|
+
}] });
|
|
400
|
+
/**
|
|
401
|
+
* Install the mock data adapter and matching batch service in an Angular injector.
|
|
402
|
+
* This is sufficient for data-only consumers; generated apps layer their local
|
|
403
|
+
* authentication/profile facade over the same mock infrastructure.
|
|
404
|
+
*
|
|
405
|
+
* @example
|
|
406
|
+
* providers: [provideMockData({ collections: { problems: [] }, disableLatency: true })]
|
|
407
|
+
*/
|
|
408
|
+
function provideMockData(options = {}) {
|
|
409
|
+
return [
|
|
410
|
+
{ provide: MOCK_COLLECTIONS, useFactory: () => typeof options.collections === 'function' ? options.collections() :
|
|
411
|
+
Object.fromEntries(Object.entries(options.collections ?? {}).map(([name, seed]) => [name, createMockCollection(seed)])) },
|
|
412
|
+
{ provide: MOCK_PERSISTENCE, useValue: options.persistence ?? {} },
|
|
413
|
+
{ provide: MockDataService, useFactory: () => {
|
|
414
|
+
const db = new MockDataService(inject(Injector));
|
|
415
|
+
if (options.disableLatency) {
|
|
416
|
+
db.GET_LATENCY_SIMULATION_DELAY = 0;
|
|
417
|
+
db.PUT_LATENCY_SIMULATION_DELAY = 0;
|
|
418
|
+
}
|
|
419
|
+
db.failCollections = [...(options.failCollections ?? [])];
|
|
420
|
+
db.stallCollections = [...(options.stallCollections ?? [])];
|
|
421
|
+
db.failWriteCollections = [...(options.failWriteCollections ?? [])];
|
|
422
|
+
return db;
|
|
423
|
+
} },
|
|
424
|
+
{ provide: DATA_ACCESS, useExisting: MockDataService },
|
|
425
|
+
{ provide: BATCH_WRITE_SERVICE, useExisting: MockBatchWriteService },
|
|
426
|
+
];
|
|
427
|
+
}
|
|
428
|
+
|
|
429
|
+
function defineEntityMock(entity, options) {
|
|
430
|
+
const store = options.store ?? new InjectionToken(`MockCollection:${entity.collection}`, {
|
|
431
|
+
providedIn: 'root', factory: () => createMockCollection(),
|
|
432
|
+
});
|
|
433
|
+
return Object.freeze({ entity, ...options, store });
|
|
434
|
+
}
|
|
435
|
+
/**
|
|
436
|
+
* Inject and initialize every generated mock definition in the current injection
|
|
437
|
+
* context (for example, a service field initializer). Call once per mock facade.
|
|
438
|
+
* Custom stores may restore persisted data during init; seeds are their fallback.
|
|
439
|
+
* Unrelated injectors do not share a global mutable registry.
|
|
440
|
+
*/
|
|
441
|
+
function createMockRegistry(definitions) {
|
|
442
|
+
const registry = Object.create(null);
|
|
443
|
+
for (const [name, definition] of Object.entries(definitions)) {
|
|
444
|
+
if (name !== definition.entity.collection)
|
|
445
|
+
throw new Error(`Mock registry key does not match collection: ${name}`);
|
|
446
|
+
const store = inject(definition.store);
|
|
447
|
+
const seeds = typeof definition.seeds === 'function' ? definition.seeds() : definition.seeds;
|
|
448
|
+
store.init([...seeds]);
|
|
449
|
+
registry[name] = store;
|
|
450
|
+
}
|
|
451
|
+
return registry;
|
|
452
|
+
}
|
|
453
|
+
/**
|
|
454
|
+
* Replace only the named collections after registry initialization. Unlike init,
|
|
455
|
+
* replaceAll bypasses persistence restoration, so explicit test seeds win even
|
|
456
|
+
* when they are an empty array. Omitted collections retain their initial data.
|
|
457
|
+
* Persistence-enabled custom stores may save these replacements to storage.
|
|
458
|
+
*/
|
|
459
|
+
function seedMockRegistry(registry, overrides) {
|
|
460
|
+
for (const [name, seeds] of Object.entries(overrides)) {
|
|
461
|
+
if (!Object.prototype.hasOwnProperty.call(registry, name))
|
|
462
|
+
throw new Error(`Unknown mock collection: ${name}`);
|
|
463
|
+
if (seeds !== undefined)
|
|
464
|
+
registry[name].replaceAll([...seeds]);
|
|
465
|
+
}
|
|
466
|
+
}
|
|
467
|
+
|
|
468
|
+
/**
|
|
469
|
+
* Development/testing entry point for mock adapters, stores and entity seeds.
|
|
470
|
+
* Import through development/test provider composition to keep mocks out of
|
|
471
|
+
* production entry points; generated apps use a provider-file replacement.
|
|
472
|
+
*/
|
|
473
|
+
|
|
474
|
+
/**
|
|
475
|
+
* Generated bundle index. Do not edit.
|
|
476
|
+
*/
|
|
477
|
+
|
|
478
|
+
export { MockBatchWriteService as BatchWriteMockService, MOCK_COLLECTIONS, MOCK_PERSISTENCE, MockBatchWriteService, MockDataService, WriteBatchMock, createMockCollection, createMockRegistry, defineEntityMock, provideMockData, seedMockRegistry, withEntitiesForMockDB };
|
|
479
|
+
//# sourceMappingURL=tech4good-platform-data-testing.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"tech4good-platform-data-testing.mjs","sources":["../../testing/mock-entities.ts","../../testing/mock-data.ts","../../testing/entity-mocks.ts","../../testing/public-api.ts","../../testing/tech4good-platform-data-testing.ts"],"sourcesContent":["import { injectLogger } from '@tech4good/platform-logging';\nimport { DestroyRef, InjectionToken, inject } from '@angular/core';\nimport { signalStoreFeature, withMethods, patchState } from '@ngrx/signals';\nimport { setAllEntities, setEntity, updateEntity, removeEntity } from '@ngrx/signals/entities';\nimport { dataTimestamp, isDataTimestamp, DataEntity, withEntitiesAndSelectMethods } from '@tech4good/platform-data';\n\n/** Optional browser persistence for mock data, scoped by collection and key prefix. */\nexport interface MockPersistenceOptions {\n /** Off by default; storage is also skipped when window is unavailable. */\n enabled?: boolean;\n /** Separate fixtures across apps; use a new prefix after an incompatible fixture change. */\n keyPrefix?: string;\n}\nexport const MOCK_PERSISTENCE = new InjectionToken<MockPersistenceOptions>('PlatformMockPersistence', {\n providedIn: 'root', factory: () => ({ enabled: false, keyPrefix: 'mockDB_' }),\n});\nfunction serialize(value: unknown): string { return JSON.stringify(value); }\nfunction deserialize<T extends DataEntity>(text: string): T[] {\n const value = JSON.parse(text, (_, value) => {\n if (value?.__type === 'DataTimestamp' || value?.__type === 'Timestamp') {\n // Read previously persisted mock timestamps without loading the Firebase SDK.\n return dataTimestamp(value.seconds, value.nanoseconds);\n }\n return value;\n });\n if (!Array.isArray(value) || value.some(entity => !entity || typeof entity.__id !== 'string' ||\n !isDataTimestamp(entity._createdAt) || !isDataTimestamp(entity._updatedAt) || typeof entity._deleted !== 'boolean')) {\n throw new Error('Invalid persisted mock entities.');\n }\n return value;\n}\n/**\n * Build an app-owned mock collection with selectors and optional localStorage\n * persistence. init prefers valid saved records over seeds; replaceAll installs\n * explicit records. Storage events synchronize other tabs, and injector\n * destruction removes the event listener. This is mock backend state, not the\n * frontend store populated by load/stream.\n */\nexport function withEntitiesForMockDB<T extends DataEntity>(collectionName: string) {\n return signalStoreFeature(\n withEntitiesAndSelectMethods<T>(),\n withMethods(store => {\n const config = inject(MOCK_PERSISTENCE);\n const destroyRef = inject(DestroyRef);\n const logger = injectLogger('data');\n const key = `${config.keyPrefix ?? 'mockDB_'}${collectionName}`;\n const selectId = (entity: T) => entity.__id;\n let listening = false;\n const onStorage = (event: StorageEvent) => {\n if (event.key !== key || !event.newValue) return;\n try { patchState(store, setAllEntities(deserialize<T>(event.newValue), { selectId })); }\n catch (error) { logger.warn('Could not read persisted mock data', error); }\n };\n const persist = () => {\n if (!config.enabled || typeof window === 'undefined') return;\n try { window.localStorage.setItem(key, serialize(store.entities())); }\n catch (error) { logger.warn('Could not persist mock data', error); }\n };\n destroyRef.onDestroy(() => { if (listening) window.removeEventListener('storage', onStorage); });\n return {\n /** Restore valid saved records when enabled, otherwise use the supplied fixtures. */\n init(entities: T[]) {\n let initial = entities;\n if (config.enabled && typeof window !== 'undefined') {\n try {\n const saved = window.localStorage.getItem(key);\n if (saved) initial = deserialize<T>(saved);\n } catch (error) { logger.warn('Could not restore mock data; using seed data', error); }\n if (!listening) { window.addEventListener('storage', onStorage); listening = true; }\n }\n patchState(store, setAllEntities(initial, { selectId }));\n },\n add(entity: T) { patchState(store, setEntity(entity, { selectId })); persist(); },\n update(id: string, changes: Partial<T>) {\n if (!store.entityMap()[id]) throw new Error(`Missing mock entity ${collectionName}/${id}`);\n patchState(store, updateEntity({ id, changes }, { selectId })); persist();\n },\n delete(id: string) { patchState(store, removeEntity(id)); persist(); },\n /** Atomic batch installation bypasses persistence restore. */\n replaceAll(entities: T[]) { patchState(store, setAllEntities(entities, { selectId })); persist(); },\n };\n }),\n );\n}\n","import { Injectable, Injector, InjectionToken, inject, signal, effect, untracked, Provider } from '@angular/core';\nimport { Observable, NEVER, throwError, defer, delay, map, startWith, pairwise } from 'rxjs';\nimport {\n dataTimestampNow, DataEntity, NewDataEntity, DataAccess, DATA_ACCESS, QueryOptions, QueryParams, queryEntities, fieldValue,\n WriteBatchI, DATA_FEEDBACK, BATCH_WRITE_SERVICE, BatchWriteService, BatchConfig, WriteOptions, processBatchWrite,\n} from '@tech4good/platform-data';\nimport { MOCK_PERSISTENCE, MockPersistenceOptions } from './mock-entities';\n\n/**\n * Storage surface consumed by MockDataService, separate from the frontend store.\n * Implementations expose reactive snapshots and replace records on mutation so\n * query streams can detect changes. All records must include DataEntity metadata.\n */\nexport interface MockCollection<T extends DataEntity = DataEntity> {\n entityMap(): Record<string, T>;\n /** Initialize defaults; persistence-aware stores may restore saved data instead. */\n init(entities: T[]): void;\n add(entity: T): void;\n update(id: string, changes: Partial<T>): void;\n /** Install exactly these records, without restoring older persisted data. */\n replaceAll(entities: T[]): void;\n}\nexport type MockCollections = Record<string, MockCollection<any>>;\nexport const MOCK_COLLECTIONS = new InjectionToken<MockCollections>('PlatformMockCollections', {\n providedIn: 'root', factory: () => ({}),\n});\n/**\n * Small signal-backed collection with no persistence or injection requirement.\n * Used for generated entities without a custom mock store and for direct seeds\n * passed to provideMockData. Use withEntitiesForMockDB for opt-in persistence.\n */\nexport function createMockCollection<T extends DataEntity>(entities: T[] = []): MockCollection<T> {\n const state = signal<Record<string, T>>({});\n const replaceAll = (values: T[]) => state.set(Object.fromEntries(values.map(value => [value.__id, value])));\n replaceAll(entities);\n return {\n entityMap: state.asReadonly(), init: replaceAll, replaceAll,\n add: entity => state.update(map => ({ ...map, [entity.__id]: entity })),\n update: (id, changes) => {\n if (!state()[id]) throw new Error(`Missing mock entity: ${id}`);\n state.update(map => ({ ...map, [id]: { ...map[id], ...changes } }));\n },\n };\n}\ntype MockOperation = { kind: 'set' | 'update' | 'delete'; path: string; value?: any };\nconst wait = (ms: number) => new Promise<void>(resolve => setTimeout(resolve, ms));\n\n/**\n * In-memory DataAccess adapter for local development and tests. Reactive\n * collections drive streams; configurable delays, errors and stalled reads\n * exercise loading/failure UI. This does not enforce Firestore security rules.\n */\n@Injectable({ providedIn: 'root' })\nexport class MockDataService implements DataAccess {\n readonly DB: MockCollections = inject(MOCK_COLLECTIONS);\n GET_LATENCY_SIMULATION_DELAY = 100;\n PUT_LATENCY_SIMULATION_DELAY = 300;\n /**\n * Collections that throw/reject on reads. Configure through provideMockData({\n * failCollections: [...] }) or mutate db.failCollections during a test to\n * exercise error → recovery: make a read fail, verify the error banner, clear\n * failCollections, click Retry, then verify the successful state.\n */\n failCollections: string[] = [];\n /**\n * Collections whose reads never emit/resolve, simulating perpetual loading.\n * Configure through provideMockData({ stallCollections: [...] }) or mutate\n * db.stallCollections before the next read/subscription to exercise loading UI.\n */\n stallCollections: string[] = [];\n failWriteCollections: string[] = [];\n constructor(protected injector: Injector) {}\n createId(): string {\n const bytes = crypto.getRandomValues(new Uint8Array(20));\n const chars = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789';\n return Array.from(bytes, byte => chars[byte % chars.length]).join('');\n }\n private collection(name: string): MockCollection {\n const store = this.DB[name];\n if (!store) throw new Error(`No mock collection registered for \"${name}\". Register app-owned seeds with provideMockData().`);\n return store;\n }\n private async read(name: string): Promise<MockCollection> {\n const store = this.collection(name);\n if (this.stallCollections.includes(name)) return new Promise(() => {});\n if (this.failCollections.includes(name)) throw new Error(`Simulated read error for collection: ${name}`);\n await wait(this.GET_LATENCY_SIMULATION_DELAY);\n return store;\n }\n /** Give each subscriber its own effect and release it when that subscription ends. */\n private observe<T>(name: string, read: (store: MockCollection) => T): Observable<T> {\n return defer(() => {\n const store = this.collection(name);\n if (this.stallCollections.includes(name)) return NEVER;\n if (this.failCollections.includes(name)) return throwError(() => new Error(`Simulated read error for collection: ${name}`));\n return new Observable<T>(subscriber => {\n const watcher = effect(() => {\n try { const value = read(store); untracked(() => subscriber.next(value)); }\n catch (error) { subscriber.error(error); }\n }, { injector: this.injector, manualCleanup: true });\n return () => watcher.destroy();\n }).pipe(delay(this.GET_LATENCY_SIMULATION_DELAY));\n });\n }\n streamEntity<T>(name: string, id: string): Observable<T | null> {\n return this.observe(name, store => store.entityMap()[id] as T ?? null);\n }\n streamEntities<T>(name: string, params: QueryParams = [], options?: QueryOptions): Observable<T[]> {\n return this.observe(name, store => queryEntities(store.entityMap(), params, options) as T[]);\n }\n streamEntitiesChanges<T>(name: string, params: QueryParams = [], options?: QueryOptions): Observable<{ type: string; docData: T }[]> {\n // Keep the original snapshot -> pairwise -> changes flow. Capture the full\n // map too, so a record that leaves the query can carry its deletion marker.\n return this.observe(name, store => {\n const entityMap = store.entityMap();\n const entities = queryEntities(entityMap, params, options);\n const matchingEntities: Record<string, DataEntity> = Object.create(null);\n for (const entity of entities) {\n matchingEntities[entity.__id] = entity;\n }\n return { matchingEntities, entityMap };\n }).pipe(\n // pairwise keeps separate prior state for each subscriber. Starting empty\n // makes the first snapshot report every matching record as added.\n startWith({ matchingEntities: {}, entityMap: {} }),\n pairwise(),\n map(([previous, current]) => {\n const prevEntities = previous.matchingEntities;\n const currEntities = current.matchingEntities;\n const changes: { type: string; docData: T }[] = [];\n for (const key in currEntities) {\n if (!Object.hasOwn(prevEntities, key)) {\n changes.push({ type: 'added', docData: currEntities[key] as T });\n } else if (currEntities[key] !== prevEntities[key]) {\n // Immutable record replacements detect changes even within one clock tick.\n changes.push({ type: 'modified', docData: currEntities[key] as T });\n }\n }\n // The original loop only inspected current matches and missed records\n // that stopped matching. Report those removals using this snapshot's data.\n for (const key in prevEntities) {\n if (!Object.hasOwn(currEntities, key)) {\n changes.push({ type: 'removed', docData: (current.entityMap[key] ?? prevEntities[key]) as T });\n }\n }\n return changes;\n }),\n // Do not discard an empty initial snapshot: the multiplexer needs it to\n // know a replacement listener is ready even when it has no matching records.\n );\n }\n async getEntity<T>(name: string, id: string): Promise<T | null> {\n return (await this.read(name)).entityMap()[id] as T ?? null;\n }\n async getEntities<T>(name: string, params: QueryParams = [], options?: QueryOptions): Promise<T[]> {\n // Match the supplied filters, as the Firestore adapter does. The loader asks\n // for _deleted == true separately so it can remove previously cached records.\n // A frontend selectEntities call would hide those records and break that load.\n return queryEntities((await this.read(name)).entityMap(), params, options) as T[];\n }\n async count(name: string, params: QueryParams = [], options?: QueryOptions): Promise<number> {\n return (await this.getEntities(name, params, options)).length;\n }\n async aggregate<S extends Record<string, number>>(name: string, params: QueryParams, options: QueryOptions,\n spec: { [K in keyof S]: [string] | [string, string] }): Promise<{ [K in keyof S]: number | null }> {\n const entities = await this.getEntities(name, params, options);\n const result = {};\n for (const [alias, [operator, field]] of Object.entries(spec)) {\n const values = entities.map(entity => fieldValue(entity, field ?? '')).filter(value => typeof value === 'number');\n if (operator === 'count') result[alias] = entities.length;\n else if (operator === 'sum' && field) result[alias] = values.reduce((sum, value) => sum + value, 0);\n else if (operator === 'average' && field) result[alias] = values.length ? values.reduce((sum, value) => sum + value, 0) / values.length : null;\n else throw new Error(`Invalid aggregate ${alias}: ${operator}`);\n }\n return result as { [K in keyof S]: number };\n }\n async addEntity<T extends NewDataEntity & { __id: string }>(collectionName: string, entity: T, batch?: WriteBatchI) {\n const entityFinal = Object.assign({}, entity, {\n _createdAt: entity._createdAt ?? dataTimestampNow(),\n _updatedAt: dataTimestampNow(),\n _deleted: false,\n });\n const docRef = { path: `${collectionName}/${entity.__id}` };\n if (batch) {\n return batch.set(docRef, entityFinal);\n } else {\n // A single write uses the collection's add method. Only batches need to\n // stage a complete collection before replacing it atomically.\n await wait(this.PUT_LATENCY_SIMULATION_DELAY);\n const store = this.collection(collectionName);\n if (!entity.__id) throw new Error(`Invalid mock document path: ${docRef.path}`);\n if (this.failWriteCollections.includes(collectionName)) throw new Error(`Simulated write error for collection: ${collectionName}`);\n return store.add(entityFinal);\n }\n }\n async updateEntity<T extends object>(collectionName: string, id: string, changes: Partial<T>, batch?: WriteBatchI) {\n const changesFinal = Object.assign({}, changes, { __id: id, _updatedAt: dataTimestampNow() });\n const docRef = { path: `${collectionName}/${id}` };\n if (batch) {\n return batch.update(docRef, changesFinal);\n } else {\n await wait(this.PUT_LATENCY_SIMULATION_DELAY);\n const store = this.collection(collectionName);\n if (!store.entityMap()[id]) throw new Error(`Missing mock entity: ${docRef.path}`);\n if (this.failWriteCollections.includes(collectionName)) throw new Error(`Simulated write error for collection: ${collectionName}`);\n return store.update(id, changesFinal);\n }\n }\n async removeEntity(collectionName: string, id: string, batch?: WriteBatchI) {\n const changes = { _updatedAt: dataTimestampNow(), _deleted: true };\n const docRef = { path: `${collectionName}/${id}` };\n if (batch) {\n return batch.update(docRef, changes);\n } else {\n await wait(this.PUT_LATENCY_SIMULATION_DELAY);\n const store = this.collection(collectionName);\n if (!store.entityMap()[id]) throw new Error(`Missing mock entity: ${docRef.path}`);\n if (this.failWriteCollections.includes(collectionName)) throw new Error(`Simulated write error for collection: ${collectionName}`);\n return store.update(id, changes);\n }\n }\n async incrementEntityField(name: string, id: string, field: string, delta: number): Promise<void> {\n await wait(this.PUT_LATENCY_SIMULATION_DELAY);\n const store = this.collection(name);\n if (this.failWriteCollections.includes(name)) throw new Error(`Simulated write error for collection: ${name}`);\n const entity = store.entityMap()[id];\n if (!entity) throw new Error(`Missing mock entity: ${name}/${id}`);\n const before = fieldValue(entity, field);\n store.update(id, { [field]: (typeof before === 'number' ? before : 0) + delta, _updatedAt: dataTimestampNow() });\n }\n /** Stage all operations, validate, then install synchronously. No partial batch on failure. */\n async commitOperations(operations: MockOperation[]): Promise<void> {\n await wait(this.PUT_LATENCY_SIMULATION_DELAY);\n const staged = new Map<string, Record<string, DataEntity>>();\n for (const operation of operations) {\n const split = operation.path.lastIndexOf('/');\n const name = operation.path.slice(0, split);\n const id = operation.path.slice(split + 1);\n if (split < 1 || !id) throw new Error(`Invalid mock document path: ${operation.path}`);\n const store = this.collection(name);\n if (this.failWriteCollections.includes(name)) throw new Error(`Simulated write error for collection: ${name}`);\n if (!staged.has(name)) staged.set(name, { ...store.entityMap() });\n const values = staged.get(name);\n if (operation.kind === 'update') {\n if (!values[id]) throw new Error(`Missing mock entity: ${operation.path}`);\n values[id] = { ...values[id], ...operation.value, __id: id };\n } else if (operation.kind === 'set') values[id] = { ...operation.value, __id: id };\n else delete values[id];\n }\n for (const [name, values] of staged) this.collection(name).replaceAll(Object.values(values));\n }\n}\n\n/** One-use batch that defers mutations until commitOperations validates the whole batch. */\nexport class WriteBatchMock implements WriteBatchI {\n private operations: MockOperation[] = [];\n private committed = false;\n constructor(private readonly db: MockDataService) {}\n private append(kind: MockOperation['kind'], ref: { path: string }, value?: any): this {\n if (this.committed) throw new Error('This mock batch has already been committed.');\n this.operations.push({ kind, path: ref.path, value });\n return this;\n }\n set(ref: { path: string }, value: any): this { return this.append('set', ref, value); }\n update(ref: { path: string }, value: any): this { return this.append('update', ref, value); }\n delete(ref: { path: string }): this { return this.append('delete', ref); }\n async commit(): Promise<void> {\n if (this.committed) throw new Error('This mock batch has already been committed.');\n this.committed = true;\n return this.db.commitOperations(this.operations);\n }\n}\n/** Pair forward and inverse mock batches with the same feedback/rollback flow as Firestore. */\n@Injectable({ providedIn: 'root' })\nexport class MockBatchWriteService implements BatchWriteService {\n private readonly feedback = inject(DATA_FEEDBACK);\n private readonly db = inject(DATA_ACCESS) as MockDataService;\n batchWrite(fn: (config: BatchConfig) => void | Promise<unknown>, options?: WriteOptions): Promise<void> {\n return processBatchWrite(fn, options, new WriteBatchMock(this.db), new WriteBatchMock(this.db), this.feedback);\n }\n}\nexport { MockBatchWriteService as BatchWriteMockService };\n/** Per-provider fixture configuration and controls for simulated failures/delays. */\nexport interface MockDataOptions<TCollections extends Record<string, DataEntity[]> = Record<string, DataEntity[]>> {\n /** Raw seeds, or a factory that injects/initializes app-owned mock stores. */\n collections?: TCollections | (() => MockCollections);\n /**\n * Set GET/PUT latency simulation delays to 0ms in tests instead of using an\n * APP_INITIALIZER just to assign those properties. Stream delivery still\n * follows Angular/RxJS scheduling; disabling latency does not make it synchronous.\n */\n disableLatency?: boolean;\n /** Reads and subscriptions fail for these collections. */\n failCollections?: string[];\n /** Reads stay pending and subscriptions emit nothing for these collections. */\n stallCollections?: string[];\n /** Reject writes, including entire batches that touch these collections. */\n failWriteCollections?: string[];\n /** Used by withEntitiesForMockDB stores; raw in-memory seed collections do not persist. */\n persistence?: MockPersistenceOptions;\n}\n/**\n * Install the mock data adapter and matching batch service in an Angular injector.\n * This is sufficient for data-only consumers; generated apps layer their local\n * authentication/profile facade over the same mock infrastructure.\n *\n * @example\n * providers: [provideMockData({ collections: { problems: [] }, disableLatency: true })]\n */\nexport function provideMockData<TCollections extends Record<string, DataEntity[]> = Record<string, DataEntity[]>>(options: MockDataOptions<TCollections> = {}): Provider[] {\n return [\n { provide: MOCK_COLLECTIONS, useFactory: () => typeof options.collections === 'function' ? options.collections() :\n Object.fromEntries(Object.entries(options.collections ?? {}).map(([name, seed]) => [name, createMockCollection(seed)])) },\n { provide: MOCK_PERSISTENCE, useValue: options.persistence ?? {} },\n { provide: MockDataService, useFactory: () => {\n const db = new MockDataService(inject(Injector));\n if (options.disableLatency) { db.GET_LATENCY_SIMULATION_DELAY = 0; db.PUT_LATENCY_SIMULATION_DELAY = 0; }\n db.failCollections = [...(options.failCollections ?? [])];\n db.stallCollections = [...(options.stallCollections ?? [])];\n db.failWriteCollections = [...(options.failWriteCollections ?? [])];\n return db;\n } },\n { provide: DATA_ACCESS, useExisting: MockDataService },\n { provide: BATCH_WRITE_SERVICE, useExisting: MockBatchWriteService },\n ];\n}\n","import { inject, InjectionToken, ProviderToken } from '@angular/core';\nimport { DataEntity, EntityDefinition } from '@tech4good/platform-data';\nimport { createMockCollection, MockCollection } from './mock-data';\n\n/** Mock-only wiring for one entity. Import this from development/test providers. */\nexport interface EntityMock<T extends DataEntity, S extends MockCollection<T>> {\n readonly entity: EntityDefinition<T>;\n /** Inject the same store instance that app tests may inject directly. */\n readonly store: ProviderToken<S>;\n /** Defaults for initialization; a factory runs when the registry is created. */\n readonly seeds: readonly T[] | (() => readonly T[]);\n}\n\n/**\n * Declare mock wiring as an exported const in *.mock.ts. Import the definition\n * directly from its relative *.model file so the generator can associate them.\n * Providing a store retains its custom selectors/methods in the registry type.\n * No store is instantiated and no seeds are installed at declaration time.\n *\n * @example\n * export const problemMock = defineEntityMock(problemEntity, {\n * store: ProblemMockDB, seeds: PROBLEM_DB,\n * });\n */\nexport function defineEntityMock<T extends DataEntity, S extends MockCollection<NoInfer<T>>>(\n entity: EntityDefinition<T>,\n options: { store: ProviderToken<S>; seeds: readonly NoInfer<T>[] | (() => readonly NoInfer<T>[]) },\n): EntityMock<T, S>;\n/** Without a custom store, create an in-memory collection scoped to its Angular injector. */\nexport function defineEntityMock<T extends DataEntity>(\n entity: EntityDefinition<T>, options: { seeds: readonly NoInfer<T>[] | (() => readonly NoInfer<T>[]) },\n): EntityMock<T, MockCollection<T>>;\nexport function defineEntityMock<T extends DataEntity>(\n entity: EntityDefinition<T>,\n options: { store?: ProviderToken<MockCollection<T>>; seeds: readonly T[] | (() => readonly T[]) },\n): EntityMock<T, MockCollection<T>> {\n const store = options.store ?? new InjectionToken<MockCollection<T>>(`MockCollection:${entity.collection}`, {\n providedIn: 'root', factory: () => createMockCollection<T>(),\n });\n return Object.freeze({ entity, ...options, store });\n}\n\n// Infer records from their entity definitions, not from potentially incomplete seeds.\n// The public overloads use NoInfer to enforce that direction of inference.\ntype Definitions = Record<string, EntityMock<any, any>>;\n/** Collection-name map retaining each definition's concrete injected store type. */\nexport type MockRegistry<D extends Definitions> = {\n [K in keyof D]: D[K] extends EntityMock<any, infer S> ? S : never;\n};\n/** Optional collection replacements; both collection names and seed records are type-checked. */\nexport type MockSeedOverrides<D extends Definitions> = {\n [K in keyof D]?: D[K] extends EntityMock<infer T, any> ? readonly T[] : never;\n};\n\n/**\n * Inject and initialize every generated mock definition in the current injection\n * context (for example, a service field initializer). Call once per mock facade.\n * Custom stores may restore persisted data during init; seeds are their fallback.\n * Unrelated injectors do not share a global mutable registry.\n */\nexport function createMockRegistry<D extends Definitions>(definitions: D): MockRegistry<D> {\n const registry = Object.create(null);\n for (const [name, definition] of Object.entries(definitions)) {\n if (name !== definition.entity.collection) throw new Error(`Mock registry key does not match collection: ${name}`);\n const store = inject(definition.store) as MockCollection;\n const seeds = typeof definition.seeds === 'function' ? definition.seeds() : definition.seeds;\n store.init([...seeds]);\n registry[name] = store;\n }\n return registry;\n}\n\n/**\n * Replace only the named collections after registry initialization. Unlike init,\n * replaceAll bypasses persistence restoration, so explicit test seeds win even\n * when they are an empty array. Omitted collections retain their initial data.\n * Persistence-enabled custom stores may save these replacements to storage.\n */\nexport function seedMockRegistry<D extends Definitions>(\n registry: MockRegistry<D>, overrides: MockSeedOverrides<D>,\n): void {\n for (const [name, seeds] of Object.entries(overrides)) {\n if (!Object.prototype.hasOwnProperty.call(registry, name)) throw new Error(`Unknown mock collection: ${name}`);\n if (seeds !== undefined) (registry[name] as MockCollection).replaceAll([...seeds]);\n }\n}\n","/**\n * Development/testing entry point for mock adapters, stores and entity seeds.\n * Import through development/test provider composition to keep mocks out of\n * production entry points; generated apps use a provider-file replacement.\n */\nexport * from './mock-data';\nexport * from './entity-mocks';\nexport * from './mock-entities';\n","/**\n * Generated bundle index. Do not edit.\n */\n\nexport * from './public-api';\n"],"names":[],"mappings":";;;;;;;;MAaa,gBAAgB,GAAG,IAAI,cAAc,CAAyB,yBAAyB,EAAE;AACpG,IAAA,UAAU,EAAE,MAAM,EAAE,OAAO,EAAE,OAAO,EAAE,OAAO,EAAE,KAAK,EAAE,SAAS,EAAE,SAAS,EAAE,CAAC;AAC9E,CAAA;AACD,SAAS,SAAS,CAAC,KAAc,EAAA,EAAY,OAAO,IAAI,CAAC,SAAS,CAAC,KAAK,CAAC,CAAC,CAAC;AAC3E,SAAS,WAAW,CAAuB,IAAY,EAAA;AACrD,IAAA,MAAM,KAAK,GAAG,IAAI,CAAC,KAAK,CAAC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