@dereekb/firebase 13.2.2 → 13.3.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/index.cjs.js +12893 -4062
- package/index.esm.js +12872 -4065
- package/package.json +5 -5
- package/src/lib/client/error/error.d.ts +18 -3
- package/src/lib/client/firestore/array.d.ts +16 -3
- package/src/lib/client/firestore/driver.accessor.batch.d.ts +35 -4
- package/src/lib/client/firestore/driver.accessor.create.d.ts +15 -0
- package/src/lib/client/firestore/driver.accessor.d.ts +15 -0
- package/src/lib/client/firestore/driver.accessor.default.d.ts +32 -0
- package/src/lib/client/firestore/driver.accessor.transaction.d.ts +35 -4
- package/src/lib/client/firestore/driver.d.ts +16 -0
- package/src/lib/client/firestore/driver.query.d.ts +36 -0
- package/src/lib/client/firestore/firestore.d.ts +11 -1
- package/src/lib/client/firestore/increment.d.ts +12 -3
- package/src/lib/client/function/development.function.factory.d.ts +27 -2
- package/src/lib/client/function/error.d.ts +27 -0
- package/src/lib/client/function/function.callable.d.ts +50 -5
- package/src/lib/client/function/function.factory.d.ts +70 -4
- package/src/lib/client/function/model.function.factory.d.ts +64 -9
- package/src/lib/client/storage/driver.accessor.d.ts +93 -0
- package/src/lib/client/storage/driver.d.ts +15 -0
- package/src/lib/client/storage/storage.d.ts +10 -1
- package/src/lib/common/auth/auth.context.d.ts +17 -2
- package/src/lib/common/auth/auth.d.ts +38 -9
- package/src/lib/common/auth/auth.error.d.ts +25 -0
- package/src/lib/common/auth/auth.server.error.d.ts +6 -2
- package/src/lib/common/development/function.d.ts +17 -6
- package/src/lib/common/development/function.schedule.d.ts +30 -1
- package/src/lib/common/firestore/accessor/accessor.wrap.modify.d.ts +36 -12
- package/src/lib/common/firestore/accessor/array.d.ts +14 -4
- package/src/lib/common/firestore/accessor/document.d.ts +77 -2
- package/src/lib/common/firestore/accessor/increment.d.ts +15 -3
- package/src/lib/common/firestore/collection/collection.d.ts +22 -4
- package/src/lib/common/firestore/collection/collection.util.d.ts +12 -2
- package/src/lib/common/firestore/driver/accessor.d.ts +28 -1
- package/src/lib/common/firestore/driver/batch.d.ts +6 -4
- package/src/lib/common/firestore/driver/driver.d.ts +18 -1
- package/src/lib/common/firestore/driver/query.d.ts +20 -1
- package/src/lib/common/firestore/driver/query.handler.d.ts +23 -0
- package/src/lib/common/firestore/driver/transaction.d.ts +18 -6
- package/src/lib/common/firestore/error.d.ts +16 -4
- package/src/lib/common/firestore/query/iterator.d.ts +11 -0
- package/src/lib/common/firestore/reference.d.ts +11 -6
- package/src/lib/common/firestore/snapshot/snapshot.d.ts +4 -0
- package/src/lib/common/firestore/snapshot/snapshot.field.d.ts +263 -63
- package/src/lib/common/firestore/types.d.ts +39 -1
- package/src/lib/common/firestore/util/id.batch.d.ts +55 -3
- package/src/lib/common/function/action.d.ts +35 -0
- package/src/lib/common/model/context.d.ts +11 -1
- package/src/lib/common/model/function.d.ts +45 -9
- package/src/lib/common/model/model/model.loader.d.ts +37 -0
- package/src/lib/common/model/model/model.param.d.ts +24 -2
- package/src/lib/common/model/model.service.d.ts +126 -4
- package/src/lib/common/model/permission/permission.context.d.ts +15 -0
- package/src/lib/common/model/permission/permission.d.ts +16 -0
- package/src/lib/common/model/permission/permission.service.d.ts +24 -1
- package/src/lib/common/model/permission/permission.service.grant.d.ts +72 -28
- package/src/lib/common/model/permission/permission.service.role.d.ts +15 -0
- package/src/lib/common/storage/accessor/path.model.d.ts +25 -8
- package/src/lib/common/storage/context.d.ts +23 -6
- package/src/lib/common/storage/driver/accessor.d.ts +15 -4
- package/src/lib/common/storage/driver/accessor.iterate.d.ts +31 -8
- package/src/lib/common/storage/driver/accessor.util.d.ts +13 -6
- package/src/lib/common/storage/driver/driver.d.ts +10 -1
- package/src/lib/common/storage/driver/error.d.ts +16 -0
- package/src/lib/common/storage/driver/list.d.ts +30 -0
- package/src/lib/common/storage/storage.d.ts +76 -19
- package/src/lib/common/storage/types.d.ts +23 -5
- package/src/lib/model/index.d.ts +1 -0
- package/src/lib/model/notification/notification.action.d.ts +8 -0
- package/src/lib/model/notification/notification.api.d.ts +26 -0
- package/src/lib/model/notification/notification.api.error.d.ts +15 -0
- package/src/lib/model/notification/notification.api.util.d.ts +27 -12
- package/src/lib/model/notification/notification.config.d.ts +193 -64
- package/src/lib/model/notification/notification.create.d.ts +62 -13
- package/src/lib/model/notification/notification.create.task.d.ts +25 -4
- package/src/lib/model/notification/notification.d.ts +258 -99
- package/src/lib/model/notification/notification.details.d.ts +66 -18
- package/src/lib/model/notification/notification.id.d.ts +90 -12
- package/src/lib/model/notification/notification.item.d.ts +57 -16
- package/src/lib/model/notification/notification.message.d.ts +84 -18
- package/src/lib/model/notification/notification.query.d.ts +21 -24
- package/src/lib/model/notification/notification.send.d.ts +38 -5
- package/src/lib/model/notification/notification.task.d.ts +87 -16
- package/src/lib/model/notification/notification.task.subtask.d.ts +42 -13
- package/src/lib/model/notification/notification.util.d.ts +68 -18
- package/src/lib/model/oidcmodel/index.d.ts +8 -0
- package/src/lib/model/oidcmodel/oidcmodel.action.d.ts +37 -0
- package/src/lib/model/oidcmodel/oidcmodel.api.d.ts +131 -0
- package/src/lib/model/oidcmodel/oidcmodel.d.ts +114 -0
- package/src/lib/model/oidcmodel/oidcmodel.data.d.ts +17 -0
- package/src/lib/model/oidcmodel/oidcmodel.id.d.ts +18 -0
- package/src/lib/model/oidcmodel/oidcmodel.interaction.d.ts +40 -0
- package/src/lib/model/oidcmodel/oidcmodel.interaction.oauth.d.ts +73 -0
- package/src/lib/model/oidcmodel/oidcmodel.query.d.ts +21 -0
- package/src/lib/model/storagefile/storagefile.action.d.ts +47 -0
- package/src/lib/model/storagefile/storagefile.api.d.ts +54 -4
- package/src/lib/model/storagefile/storagefile.create.d.ts +40 -3
- package/src/lib/model/storagefile/storagefile.d.ts +153 -16
- package/src/lib/model/storagefile/storagefile.file.d.ts +22 -7
- package/src/lib/model/storagefile/storagefile.group.d.ts +30 -1
- package/src/lib/model/storagefile/storagefile.group.processing.d.ts +20 -2
- package/src/lib/model/storagefile/storagefile.id.d.ts +44 -5
- package/src/lib/model/storagefile/storagefile.permission.d.ts +23 -4
- package/src/lib/model/storagefile/storagefile.query.d.ts +63 -11
- package/src/lib/model/storagefile/storagefile.task.d.ts +47 -4
- package/src/lib/model/storagefile/storagefile.upload.claims.d.ts +21 -4
- package/src/lib/model/storagefile/storagefile.upload.d.ts +41 -9
- package/src/lib/model/storagefile/storagefile.upload.determiner.d.ts +112 -20
- package/src/lib/model/storagefile/storagefile.util.d.ts +66 -3
- package/src/lib/model/system/system.action.d.ts +25 -0
- package/src/lib/model/system/system.d.ts +80 -4
- package/src/lib/model/user.d.ts +8 -2
- package/test/index.cjs.js +11168 -3295
- package/test/index.esm.js +11176 -3303
- package/test/package.json +6 -6
- package/test/src/lib/client/firebase.authorized.d.ts +18 -0
- package/test/src/lib/client/firebase.d.ts +60 -0
- package/test/src/lib/common/firebase.instance.d.ts +21 -0
- package/test/src/lib/common/firestore/firestore.d.ts +40 -0
- package/test/src/lib/common/firestore/firestore.instance.d.ts +16 -0
- package/test/src/lib/common/firestore/test.driver.accessor.d.ts +39 -2
- package/test/src/lib/common/firestore/test.driver.utility.d.ts +8 -2
- package/test/src/lib/common/firestore/test.iterator.d.ts +7 -2
- package/test/src/lib/common/mock/mock.item.collection.fixture.d.ts +29 -1
- package/test/src/lib/common/mock/mock.item.d.ts +219 -5
- package/test/src/lib/common/mock/mock.item.id.d.ts +6 -0
- package/test/src/lib/common/mock/mock.item.query.d.ts +12 -0
- package/test/src/lib/common/mock/mock.item.service.d.ts +60 -0
- package/test/src/lib/common/mock/mock.item.storage.fixture.d.ts +28 -1
- package/test/src/lib/common/storage/storage.d.ts +30 -0
- package/test/src/lib/common/storage/storage.instance.d.ts +22 -0
- package/test/src/lib/common/storage/test.driver.accessor.d.ts +7 -2
- package/index.cjs.js.map +0 -1
- package/index.esm.js.map +0 -1
|
@@ -1,10 +1,22 @@
|
|
|
1
1
|
import { type Maybe } from '@dereekb/util';
|
|
2
2
|
import { type CollectionReference, type FirestoreCollection, type FirestoreContext, AbstractFirestoreDocument, type SingleItemFirestoreCollection, type FirestoreCollectionWithParent, AbstractFirestoreDocumentWithParent, type ExpectedFirestoreModelData, type FirestoreModelData, type CollectionGroup, type FirestoreCollectionGroup, type UserRelated, type UserRelatedById, type SystemStateStoredData, type SystemStateStoredDataConverterMap, type SystemStateStoredDataFieldConverterConfig } from '@dereekb/firebase';
|
|
3
3
|
import { type GrantedReadRole } from '@dereekb/model';
|
|
4
|
+
/**
|
|
5
|
+
* Union of all mock model identity types used in the test suite.
|
|
6
|
+
*
|
|
7
|
+
* Each member corresponds to one of the mock Firestore models defined in this file.
|
|
8
|
+
* Useful for generic constraints that need to accept any mock model identity.
|
|
9
|
+
*/
|
|
4
10
|
export type MockItemTypes = typeof mockItemIdentity | typeof mockItemPrivateIdentity | typeof mockItemUserIdentity | typeof mockItemSubItemIdentity | typeof mockItemSubItemDeepIdentity;
|
|
11
|
+
/**
|
|
12
|
+
* {@link firestoreModelIdentity} for the root-level mock item collection (`mockItem` / `mi`).
|
|
13
|
+
*/
|
|
5
14
|
export declare const mockItemIdentity: import("@dereekb/firebase").RootFirestoreModelIdentity<"mockItem", "mi">;
|
|
6
15
|
/**
|
|
7
|
-
*
|
|
16
|
+
* Application-level data for the root mock Firestore model.
|
|
17
|
+
*
|
|
18
|
+
* This is the converted (in-memory) representation. For the raw database representation,
|
|
19
|
+
* see {@link MockItemData}.
|
|
8
20
|
*/
|
|
9
21
|
export interface MockItem {
|
|
10
22
|
value?: Maybe<string>;
|
|
@@ -25,7 +37,15 @@ export interface MockItem {
|
|
|
25
37
|
*/
|
|
26
38
|
test: boolean;
|
|
27
39
|
}
|
|
40
|
+
/**
|
|
41
|
+
* Possible granted roles for {@link MockItem}. Includes the standard read role plus an admin role.
|
|
42
|
+
*/
|
|
28
43
|
export type MockItemRoles = GrantedReadRole | 'admin';
|
|
44
|
+
/**
|
|
45
|
+
* {@link AbstractFirestoreDocument} implementation for {@link MockItem}.
|
|
46
|
+
*
|
|
47
|
+
* Provides document-level access to a single MockItem in Firestore.
|
|
48
|
+
*/
|
|
29
49
|
export declare class MockItemDocument extends AbstractFirestoreDocument<MockItem, MockItemDocument, typeof mockItemIdentity> {
|
|
30
50
|
get modelIdentity(): import("@dereekb/firebase").RootFirestoreModelIdentity<"mockItem", "mi">;
|
|
31
51
|
}
|
|
@@ -56,22 +76,61 @@ export declare const mockItemConverter: import("@dereekb/firebase").SnapshotConv
|
|
|
56
76
|
* @returns
|
|
57
77
|
*/
|
|
58
78
|
export declare function mockItemCollectionReference(context: FirestoreContext): CollectionReference<MockItem>;
|
|
79
|
+
/**
|
|
80
|
+
* Typed {@link FirestoreCollection} for {@link MockItem} documents.
|
|
81
|
+
*/
|
|
59
82
|
export type MockItemFirestoreCollection = FirestoreCollection<MockItem, MockItemDocument>;
|
|
83
|
+
/**
|
|
84
|
+
* Creates a {@link MockItemFirestoreCollection} bound to the given {@link FirestoreContext}.
|
|
85
|
+
*
|
|
86
|
+
* @example
|
|
87
|
+
* ```ts
|
|
88
|
+
* const collection = mockItemFirestoreCollection(firestoreContext);
|
|
89
|
+
* const doc = collection.documentAccessor().newDocument();
|
|
90
|
+
* ```
|
|
91
|
+
*/
|
|
60
92
|
export declare function mockItemFirestoreCollection(firestoreContext: FirestoreContext): MockItemFirestoreCollection;
|
|
93
|
+
/**
|
|
94
|
+
* {@link firestoreModelIdentity} for the MockItemPrivate subcollection (`mockItemPrivate` / `mip`).
|
|
95
|
+
*
|
|
96
|
+
* This is a child identity of {@link mockItemIdentity}, meaning MockItemPrivate documents
|
|
97
|
+
* live as subcollections under MockItem documents.
|
|
98
|
+
*/
|
|
61
99
|
export declare const mockItemPrivateIdentity: import("@dereekb/firebase").FirestoreModelIdentityWithParent<import("@dereekb/firebase").RootFirestoreModelIdentity<"mockItem", "mi">, "mockItemPrivate", "mip">;
|
|
100
|
+
/**
|
|
101
|
+
* Bitwise-encoded settings object representing cardinal directions.
|
|
102
|
+
*
|
|
103
|
+
* Used in conjunction with {@link mockItemSettingsItemDencoder} to test
|
|
104
|
+
* {@link firestoreBitwiseObjectMap} encoding/decoding in Firestore.
|
|
105
|
+
*/
|
|
62
106
|
export interface MockItemSettingsItem {
|
|
63
107
|
north?: boolean;
|
|
64
108
|
south?: boolean;
|
|
65
109
|
east?: boolean;
|
|
66
110
|
west?: boolean;
|
|
67
111
|
}
|
|
112
|
+
/**
|
|
113
|
+
* Enum indices for {@link MockItemSettingsItem} cardinal directions, used by the bitwise dencoder.
|
|
114
|
+
*/
|
|
68
115
|
export declare enum MockItemSettingsItemEnum {
|
|
69
116
|
NORTH = 0,
|
|
70
117
|
SOUTH = 1,
|
|
71
118
|
EAST = 2,
|
|
72
119
|
WEST = 3
|
|
73
120
|
}
|
|
121
|
+
/**
|
|
122
|
+
* Bitwise dencoder (encoder/decoder) for {@link MockItemSettingsItem}.
|
|
123
|
+
*
|
|
124
|
+
* Converts between a boolean-keyed object and a compact bitwise integer
|
|
125
|
+
* representation for efficient Firestore storage.
|
|
126
|
+
*/
|
|
74
127
|
export declare const mockItemSettingsItemDencoder: import("@dereekb/util").BitwiseObjectDencoder<MockItemSettingsItem>;
|
|
128
|
+
/**
|
|
129
|
+
* Map of string keys to {@link MockItemSettingsItem} values.
|
|
130
|
+
*
|
|
131
|
+
* Stored in Firestore using {@link firestoreBitwiseObjectMap}, where each entry
|
|
132
|
+
* is encoded as a compact bitwise integer.
|
|
133
|
+
*/
|
|
75
134
|
export type MockItemSettingsMap = Record<string, MockItemSettingsItem>;
|
|
76
135
|
/**
|
|
77
136
|
* Private data for each MockItem.
|
|
@@ -85,13 +144,19 @@ export interface MockItemPrivate {
|
|
|
85
144
|
settings: MockItemSettingsMap;
|
|
86
145
|
createdAt: Date;
|
|
87
146
|
}
|
|
147
|
+
/**
|
|
148
|
+
* Possible granted roles for {@link MockItemPrivate}.
|
|
149
|
+
*/
|
|
88
150
|
export type MockItemPrivateRoles = GrantedReadRole | 'admin';
|
|
89
151
|
/**
|
|
90
|
-
*
|
|
152
|
+
* {@link AbstractFirestoreDocument} implementation for {@link MockItemPrivate}.
|
|
91
153
|
*/
|
|
92
154
|
export declare class MockItemPrivateDocument extends AbstractFirestoreDocument<MockItemPrivate, MockItemPrivateDocument, typeof mockItemPrivateIdentity> {
|
|
93
155
|
get modelIdentity(): import("@dereekb/firebase").FirestoreModelIdentityWithParent<import("@dereekb/firebase").RootFirestoreModelIdentity<"mockItem", "mi">, "mockItemPrivate", "mip">;
|
|
94
156
|
}
|
|
157
|
+
/**
|
|
158
|
+
* Raw Firestore storage type for {@link MockItemPrivate}.
|
|
159
|
+
*/
|
|
95
160
|
export type MockItemPrivateData = FirestoreModelData<MockItemPrivate, {}>;
|
|
96
161
|
/**
|
|
97
162
|
* Used to build a FirestoreDataConverter. Fields are configured via configuration. See the SnapshotConverterFunctions for more info.
|
|
@@ -115,13 +180,40 @@ export declare const mockItemPrivateConverter: import("@dereekb/firebase").Snaps
|
|
|
115
180
|
* @param firestore
|
|
116
181
|
* @returns
|
|
117
182
|
*/
|
|
183
|
+
/**
|
|
184
|
+
* Creates a factory that produces {@link CollectionReference} instances for {@link MockItemPrivate}
|
|
185
|
+
* subcollections under a given {@link MockItemDocument} parent.
|
|
186
|
+
*/
|
|
118
187
|
export declare function mockItemPrivateCollectionReferenceFactory(context: FirestoreContext): (parent: MockItemDocument) => CollectionReference<MockItemPrivate>;
|
|
188
|
+
/**
|
|
189
|
+
* Typed {@link SingleItemFirestoreCollection} for {@link MockItemPrivate}, constrained to one document per parent.
|
|
190
|
+
*/
|
|
119
191
|
export type MockItemPrivateFirestoreCollection = SingleItemFirestoreCollection<MockItemPrivate, MockItem, MockItemPrivateDocument>;
|
|
192
|
+
/**
|
|
193
|
+
* Factory function type that creates a {@link MockItemPrivateFirestoreCollection} for a given parent.
|
|
194
|
+
*/
|
|
120
195
|
export type MockItemPrivateFirestoreCollectionFactory = (parent: MockItemDocument) => MockItemPrivateFirestoreCollection;
|
|
196
|
+
/**
|
|
197
|
+
* Creates a factory for producing {@link MockItemPrivateFirestoreCollection} instances bound to a parent {@link MockItemDocument}.
|
|
198
|
+
*/
|
|
121
199
|
export declare function mockItemPrivateFirestoreCollection(firestoreContext: FirestoreContext): MockItemPrivateFirestoreCollectionFactory;
|
|
200
|
+
/**
|
|
201
|
+
* Creates a {@link CollectionGroup} reference for querying all {@link MockItemPrivate} documents across parents.
|
|
202
|
+
*/
|
|
122
203
|
export declare function mockItemPrivateCollectionReference(context: FirestoreContext): CollectionGroup<MockItemPrivate>;
|
|
204
|
+
/**
|
|
205
|
+
* Typed {@link FirestoreCollectionGroup} for querying {@link MockItemPrivate} across all parent documents.
|
|
206
|
+
*/
|
|
123
207
|
export type MockItemPrivateFirestoreCollectionGroup = FirestoreCollectionGroup<MockItemPrivate, MockItemPrivateDocument>;
|
|
208
|
+
/**
|
|
209
|
+
* Creates a {@link MockItemPrivateFirestoreCollectionGroup} for cross-parent queries on {@link MockItemPrivate}.
|
|
210
|
+
*/
|
|
124
211
|
export declare function mockItemPrivateFirestoreCollectionGroup(firestoreContext: FirestoreContext): MockItemPrivateFirestoreCollectionGroup;
|
|
212
|
+
/**
|
|
213
|
+
* {@link firestoreModelIdentity} for the MockItemUser subcollection (`mockItemUser` / `miu`).
|
|
214
|
+
*
|
|
215
|
+
* Child of {@link mockItemIdentity}. Represents per-user data associated with a {@link MockItem}.
|
|
216
|
+
*/
|
|
125
217
|
export declare const mockItemUserIdentity: import("@dereekb/firebase").FirestoreModelIdentityWithParent<import("@dereekb/firebase").RootFirestoreModelIdentity<"mockItem", "mi">, "mockItemUser", "miu">;
|
|
126
218
|
/**
|
|
127
219
|
* An item associated per user to this item.
|
|
@@ -129,18 +221,27 @@ export declare const mockItemUserIdentity: import("@dereekb/firebase").Firestore
|
|
|
129
221
|
export interface MockItemUser extends UserRelated, UserRelatedById {
|
|
130
222
|
name: string;
|
|
131
223
|
}
|
|
224
|
+
/**
|
|
225
|
+
* Possible granted roles for {@link MockItemUser}.
|
|
226
|
+
*/
|
|
132
227
|
export type MockItemUserRoles = GrantedReadRole | 'admin';
|
|
133
228
|
/**
|
|
134
|
-
*
|
|
229
|
+
* {@link AbstractFirestoreDocument} implementation for {@link MockItemUser}.
|
|
135
230
|
*/
|
|
136
231
|
export declare class MockItemUserDocument extends AbstractFirestoreDocument<MockItemUser, MockItemUserDocument, typeof mockItemUserIdentity> {
|
|
137
232
|
get modelIdentity(): import("@dereekb/firebase").FirestoreModelIdentityWithParent<import("@dereekb/firebase").RootFirestoreModelIdentity<"mockItem", "mi">, "mockItemUser", "miu">;
|
|
138
233
|
}
|
|
234
|
+
/**
|
|
235
|
+
* Raw Firestore storage type for {@link MockItemUser}.
|
|
236
|
+
*/
|
|
139
237
|
export type MockItemUserData = FirestoreModelData<MockItemUser, {}>;
|
|
140
238
|
/**
|
|
141
239
|
* Firestore collection path name.
|
|
142
240
|
*/
|
|
143
241
|
export declare const mockItemUserCollectionName = "mockItemUser";
|
|
242
|
+
/**
|
|
243
|
+
* Default document identifier used for MockItemUser in tests.
|
|
244
|
+
*/
|
|
144
245
|
export declare const mockItemUserIdentifier = "0";
|
|
145
246
|
/**
|
|
146
247
|
* Used to build a FirestoreDataConverter. Fields are configured via configuration. See the SnapshotConverterFunctions for more info.
|
|
@@ -159,13 +260,40 @@ export declare const mockItemUserConverter: import("@dereekb/firebase").Snapshot
|
|
|
159
260
|
* @returns
|
|
160
261
|
*/
|
|
161
262
|
export declare function mockItemUserCollectionReferenceFactory(context: FirestoreContext): (parent: MockItemDocument) => CollectionReference<MockItemUser>;
|
|
263
|
+
/**
|
|
264
|
+
* Accessor factory for {@link MockItemUser} that copies user-related fields (uid) when creating documents.
|
|
265
|
+
*/
|
|
162
266
|
export declare const mockItemUserAccessorFactory: import("@dereekb/firebase").InterceptAccessorFactoryFunction<MockItemUser, import("@dereekb/firebase").DocumentData>;
|
|
267
|
+
/**
|
|
268
|
+
* Typed {@link FirestoreCollectionWithParent} for {@link MockItemUser} documents under a {@link MockItem}.
|
|
269
|
+
*/
|
|
163
270
|
export type MockItemUserFirestoreCollection = FirestoreCollectionWithParent<MockItemUser, MockItem, MockItemUserDocument>;
|
|
271
|
+
/**
|
|
272
|
+
* Factory function type that creates a {@link MockItemUserFirestoreCollection} for a given parent.
|
|
273
|
+
*/
|
|
164
274
|
export type MockItemUserFirestoreCollectionFactory = (parent: MockItemDocument) => MockItemUserFirestoreCollection;
|
|
275
|
+
/**
|
|
276
|
+
* Creates a factory for producing {@link MockItemUserFirestoreCollection} instances bound to a parent {@link MockItemDocument}.
|
|
277
|
+
*/
|
|
165
278
|
export declare function mockItemUserFirestoreCollection(firestoreContext: FirestoreContext): MockItemUserFirestoreCollectionFactory;
|
|
279
|
+
/**
|
|
280
|
+
* Creates a {@link CollectionGroup} reference for querying all {@link MockItemUser} documents across parents.
|
|
281
|
+
*/
|
|
166
282
|
export declare function mockItemUserCollectionReference(context: FirestoreContext): CollectionGroup<MockItemUser>;
|
|
283
|
+
/**
|
|
284
|
+
* Typed {@link FirestoreCollectionGroup} for querying {@link MockItemUser} across all parent documents.
|
|
285
|
+
*/
|
|
167
286
|
export type MockItemUserFirestoreCollectionGroup = FirestoreCollectionGroup<MockItemUser, MockItemUserDocument>;
|
|
287
|
+
/**
|
|
288
|
+
* Creates a {@link MockItemUserFirestoreCollectionGroup} for cross-parent queries on {@link MockItemUser}.
|
|
289
|
+
*/
|
|
168
290
|
export declare function mockItemUserFirestoreCollectionGroup(firestoreContext: FirestoreContext): MockItemUserFirestoreCollectionGroup;
|
|
291
|
+
/**
|
|
292
|
+
* {@link firestoreModelIdentity} for the MockItemSubItem subcollection (`mockItemSub` / `misi`).
|
|
293
|
+
*
|
|
294
|
+
* Child of {@link mockItemIdentity}. Unlike {@link MockItemPrivate} (single item) or {@link MockItemUser} (per-user),
|
|
295
|
+
* there can be an unlimited number of sub-items per parent MockItem.
|
|
296
|
+
*/
|
|
169
297
|
export declare const mockItemSubItemIdentity: import("@dereekb/firebase").FirestoreModelIdentityWithParent<import("@dereekb/firebase").RootFirestoreModelIdentity<"mockItem", "mi">, "mockItemSub", "misi">;
|
|
170
298
|
/**
|
|
171
299
|
* Data for a sub item in our firestore collection.
|
|
@@ -175,25 +303,61 @@ export declare const mockItemSubItemIdentity: import("@dereekb/firebase").Firest
|
|
|
175
303
|
export interface MockItemSubItem {
|
|
176
304
|
value?: Maybe<number>;
|
|
177
305
|
}
|
|
306
|
+
/**
|
|
307
|
+
* Possible granted roles for {@link MockItemSubItem}.
|
|
308
|
+
*/
|
|
178
309
|
export type MockItemSubItemRoles = GrantedReadRole | 'admin';
|
|
179
310
|
/**
|
|
180
|
-
*
|
|
311
|
+
* {@link AbstractFirestoreDocumentWithParent} implementation for {@link MockItemSubItem}.
|
|
312
|
+
*
|
|
313
|
+
* Maintains a reference to its parent {@link MockItem} document.
|
|
181
314
|
*/
|
|
182
315
|
export declare class MockItemSubItemDocument extends AbstractFirestoreDocumentWithParent<MockItem, MockItemSubItem, MockItemSubItemDocument, typeof mockItemSubItemIdentity> {
|
|
183
316
|
get modelIdentity(): import("@dereekb/firebase").FirestoreModelIdentityWithParent<import("@dereekb/firebase").RootFirestoreModelIdentity<"mockItem", "mi">, "mockItemSub", "misi">;
|
|
184
317
|
}
|
|
318
|
+
/**
|
|
319
|
+
* Raw Firestore storage type for {@link MockItemSubItem}. All fields match the application type exactly.
|
|
320
|
+
*/
|
|
185
321
|
export type MockItemSubItemData = ExpectedFirestoreModelData<MockItemSubItem>;
|
|
186
322
|
/**
|
|
187
323
|
* Used to build a FirestoreDataConverter. Fields are configured via configuration. See the SnapshotConverterFunctions for more info.
|
|
188
324
|
*/
|
|
189
325
|
export declare const mockItemSubItemConverter: import("@dereekb/firebase").SnapshotConverterFunctions<MockItemSubItem, import("@dereekb/util").ReplaceType<MockItemSubItem, object, any>>;
|
|
326
|
+
/**
|
|
327
|
+
* Creates a factory that produces {@link CollectionReference} instances for {@link MockItemSubItem}
|
|
328
|
+
* subcollections under a given {@link MockItemDocument} parent.
|
|
329
|
+
*/
|
|
190
330
|
export declare function mockItemSubItemCollectionReferenceFactory(context: FirestoreContext): (parent: MockItemDocument) => CollectionReference<MockItemSubItem>;
|
|
331
|
+
/**
|
|
332
|
+
* Typed {@link FirestoreCollectionWithParent} for {@link MockItemSubItem} documents under a {@link MockItem}.
|
|
333
|
+
*/
|
|
191
334
|
export type MockItemSubItemFirestoreCollection = FirestoreCollectionWithParent<MockItemSubItem, MockItem, MockItemSubItemDocument, MockItemDocument>;
|
|
335
|
+
/**
|
|
336
|
+
* Factory function type that creates a {@link MockItemSubItemFirestoreCollection} for a given parent.
|
|
337
|
+
*/
|
|
192
338
|
export type MockItemSubItemFirestoreCollectionFactory = (parent: MockItemDocument) => MockItemSubItemFirestoreCollection;
|
|
339
|
+
/**
|
|
340
|
+
* Creates a factory for producing {@link MockItemSubItemFirestoreCollection} instances bound to a parent {@link MockItemDocument}.
|
|
341
|
+
*/
|
|
193
342
|
export declare function mockItemSubItemFirestoreCollection(firestoreContext: FirestoreContext): MockItemSubItemFirestoreCollectionFactory;
|
|
343
|
+
/**
|
|
344
|
+
* Creates a {@link CollectionGroup} reference for querying all {@link MockItemSubItem} documents across parents.
|
|
345
|
+
*/
|
|
194
346
|
export declare function mockItemSubItemCollectionReference(context: FirestoreContext): CollectionGroup<MockItemSubItem>;
|
|
347
|
+
/**
|
|
348
|
+
* Typed {@link FirestoreCollectionGroup} for querying {@link MockItemSubItem} across all parent documents.
|
|
349
|
+
*/
|
|
195
350
|
export type MockItemSubItemFirestoreCollectionGroup = FirestoreCollectionGroup<MockItemSubItem, MockItemSubItemDocument>;
|
|
351
|
+
/**
|
|
352
|
+
* Creates a {@link MockItemSubItemFirestoreCollectionGroup} for cross-parent queries on {@link MockItemSubItem}.
|
|
353
|
+
*/
|
|
196
354
|
export declare function mockItemSubItemFirestoreCollectionGroup(firestoreContext: FirestoreContext): MockItemSubItemFirestoreCollectionGroup;
|
|
355
|
+
/**
|
|
356
|
+
* {@link firestoreModelIdentity} for the MockItemSubItemDeep subcollection (`mockItemSubItemDeep` / `misid`).
|
|
357
|
+
*
|
|
358
|
+
* Child of {@link mockItemSubItemIdentity}, making this a three-level-deep nested collection
|
|
359
|
+
* (MockItem -> MockItemSubItem -> MockItemSubItemDeep). Useful for testing deeply nested document access patterns.
|
|
360
|
+
*/
|
|
197
361
|
export declare const mockItemSubItemDeepIdentity: import("@dereekb/firebase").FirestoreModelIdentityWithParent<import("@dereekb/firebase").FirestoreModelIdentityWithParent<import("@dereekb/firebase").RootFirestoreModelIdentity<"mockItem", "mi">, "mockItemSub", "misi">, "mockItemSubItemDeep", "misid">;
|
|
198
362
|
/**
|
|
199
363
|
* Data for a sub item in our firestore collection.
|
|
@@ -203,31 +367,81 @@ export declare const mockItemSubItemDeepIdentity: import("@dereekb/firebase").Fi
|
|
|
203
367
|
export interface MockItemSubItemDeep {
|
|
204
368
|
value?: Maybe<number>;
|
|
205
369
|
}
|
|
370
|
+
/**
|
|
371
|
+
* Possible granted roles for {@link MockItemSubItemDeep}.
|
|
372
|
+
*/
|
|
206
373
|
export type MockItemSubItemDeepRoles = GrantedReadRole | 'admin';
|
|
207
374
|
/**
|
|
208
|
-
*
|
|
375
|
+
* {@link AbstractFirestoreDocumentWithParent} implementation for {@link MockItemSubItemDeep}.
|
|
376
|
+
*
|
|
377
|
+
* Maintains a reference to its parent {@link MockItemSubItem} document.
|
|
209
378
|
*/
|
|
210
379
|
export declare class MockItemSubItemDeepDocument extends AbstractFirestoreDocumentWithParent<MockItemSubItem, MockItemSubItemDeep, MockItemSubItemDeepDocument, typeof mockItemSubItemDeepIdentity> {
|
|
211
380
|
get modelIdentity(): import("@dereekb/firebase").FirestoreModelIdentityWithParent<import("@dereekb/firebase").FirestoreModelIdentityWithParent<import("@dereekb/firebase").RootFirestoreModelIdentity<"mockItem", "mi">, "mockItemSub", "misi">, "mockItemSubItemDeep", "misid">;
|
|
212
381
|
}
|
|
382
|
+
/**
|
|
383
|
+
* Raw Firestore storage type for {@link MockItemSubItemDeep}. All fields match the application type exactly.
|
|
384
|
+
*/
|
|
213
385
|
export type MockItemSubItemDeepData = ExpectedFirestoreModelData<MockItemSubItemDeep>;
|
|
214
386
|
/**
|
|
215
387
|
* Used to build a FirestoreDataConverter. Fields are configured via configuration. See the SnapshotConverterFunctions for more info.
|
|
216
388
|
*/
|
|
217
389
|
export declare const mockItemSubItemDeepConverter: import("@dereekb/firebase").SnapshotConverterFunctions<MockItemSubItemDeep, import("@dereekb/util").ReplaceType<MockItemSubItemDeep, object, any>>;
|
|
390
|
+
/**
|
|
391
|
+
* Creates a factory that produces {@link CollectionReference} instances for {@link MockItemSubItemDeep}
|
|
392
|
+
* subcollections under a given {@link MockItemSubItemDocument} parent.
|
|
393
|
+
*/
|
|
218
394
|
export declare function mockItemSubItemDeepCollectionReferenceFactory(context: FirestoreContext): (parent: MockItemSubItemDocument) => CollectionReference<MockItemSubItemDeep>;
|
|
395
|
+
/**
|
|
396
|
+
* Typed {@link FirestoreCollectionWithParent} for {@link MockItemSubItemDeep} documents under a {@link MockItemSubItem}.
|
|
397
|
+
*/
|
|
219
398
|
export type MockItemSubItemDeepFirestoreCollection = FirestoreCollectionWithParent<MockItemSubItemDeep, MockItemSubItem, MockItemSubItemDeepDocument, MockItemSubItemDocument>;
|
|
399
|
+
/**
|
|
400
|
+
* Factory function type that creates a {@link MockItemSubItemDeepFirestoreCollection} for a given parent.
|
|
401
|
+
*/
|
|
220
402
|
export type MockItemSubItemDeepFirestoreCollectionFactory = (parent: MockItemSubItemDocument) => MockItemSubItemDeepFirestoreCollection;
|
|
403
|
+
/**
|
|
404
|
+
* Creates a factory for producing {@link MockItemSubItemDeepFirestoreCollection} instances bound to a parent {@link MockItemSubItemDocument}.
|
|
405
|
+
*/
|
|
221
406
|
export declare function mockItemSubItemDeepFirestoreCollection(firestoreContext: FirestoreContext): MockItemSubItemDeepFirestoreCollectionFactory;
|
|
407
|
+
/**
|
|
408
|
+
* Creates a {@link CollectionGroup} reference for querying all {@link MockItemSubItemDeep} documents across parents.
|
|
409
|
+
*/
|
|
222
410
|
export declare function mockItemSubItemDeepCollectionReference(context: FirestoreContext): CollectionGroup<MockItemSubItemDeep>;
|
|
411
|
+
/**
|
|
412
|
+
* Typed {@link FirestoreCollectionGroup} for querying {@link MockItemSubItemDeep} across all parent documents.
|
|
413
|
+
*/
|
|
223
414
|
export type MockItemSubItemDeepFirestoreCollectionGroup = FirestoreCollectionGroup<MockItemSubItemDeep, MockItemSubItemDeepDocument>;
|
|
415
|
+
/**
|
|
416
|
+
* Creates a {@link MockItemSubItemDeepFirestoreCollectionGroup} for cross-parent queries on {@link MockItemSubItemDeep}.
|
|
417
|
+
*/
|
|
224
418
|
export declare function mockItemSubItemDeepFirestoreCollectionGroup(firestoreContext: FirestoreContext): MockItemSubItemDeepFirestoreCollectionGroup;
|
|
419
|
+
/**
|
|
420
|
+
* System state type identifier for mock system state data.
|
|
421
|
+
*
|
|
422
|
+
* Used as the key in {@link mockItemSystemStateStoredDataConverterMap}.
|
|
423
|
+
*/
|
|
225
424
|
export declare const MOCK_SYSTEM_STATE_TYPE = "mockitemsystemstate";
|
|
425
|
+
/**
|
|
426
|
+
* Custom data stored within a mock system state document.
|
|
427
|
+
*
|
|
428
|
+
* Extends {@link SystemStateStoredData} with a `lat` (last-updated-at) timestamp field
|
|
429
|
+
* to test sub-object field conversion in system state documents.
|
|
430
|
+
*/
|
|
226
431
|
export interface MockSystemData extends SystemStateStoredData {
|
|
227
432
|
/**
|
|
228
433
|
* Last updated at
|
|
229
434
|
*/
|
|
230
435
|
lat: Date;
|
|
231
436
|
}
|
|
437
|
+
/**
|
|
438
|
+
* Field converter config for {@link MockSystemData}, handling the `lat` date field conversion.
|
|
439
|
+
*/
|
|
232
440
|
export declare const mockItemSystemDataConverter: SystemStateStoredDataFieldConverterConfig<MockSystemData>;
|
|
441
|
+
/**
|
|
442
|
+
* Maps system state type identifiers to their corresponding field converter configs.
|
|
443
|
+
*
|
|
444
|
+
* Used when creating the mock system state Firestore collection to register
|
|
445
|
+
* the {@link MockSystemData} converter under the {@link MOCK_SYSTEM_STATE_TYPE} key.
|
|
446
|
+
*/
|
|
233
447
|
export declare const mockItemSystemStateStoredDataConverterMap: SystemStateStoredDataConverterMap;
|
|
@@ -1,2 +1,8 @@
|
|
|
1
1
|
import { type FirestoreModelKey } from '@dereekb/firebase';
|
|
2
|
+
/**
|
|
3
|
+
* Type alias for a {@link FirestoreModelKey} identifying a {@link MockItemUser} document.
|
|
4
|
+
*
|
|
5
|
+
* Provides semantic clarity when a function parameter specifically expects a MockItemUser key
|
|
6
|
+
* rather than a generic model key.
|
|
7
|
+
*/
|
|
2
8
|
export type MockItemUserKey = FirestoreModelKey;
|
|
@@ -1,6 +1,18 @@
|
|
|
1
1
|
import { type MockItem } from './mock.item';
|
|
2
2
|
import { type FirestoreQueryConstraint, type DocumentReference } from '@dereekb/firebase';
|
|
3
|
+
/**
|
|
4
|
+
* Creates a Firestore query constraint that filters {@link MockItem} documents by their `value` field.
|
|
5
|
+
*
|
|
6
|
+
* @example
|
|
7
|
+
* ```ts
|
|
8
|
+
* const constraint = mockItemWithValue('hello');
|
|
9
|
+
* const results = await collection.query(constraint);
|
|
10
|
+
* ```
|
|
11
|
+
*/
|
|
3
12
|
export declare function mockItemWithValue(value: string): FirestoreQueryConstraint;
|
|
13
|
+
/**
|
|
14
|
+
* Creates a Firestore query constraint that filters {@link MockItem} documents by their `test` boolean field.
|
|
15
|
+
*/
|
|
4
16
|
export declare function mockItemWithTestValue(test: boolean): FirestoreQueryConstraint;
|
|
5
17
|
/**
|
|
6
18
|
* This sorts all fields by their document ID, then filters in between two specific document id paths in order to only return values between a specific path.
|
|
@@ -1,6 +1,13 @@
|
|
|
1
1
|
import { type MockItem, type MockItemSubItemDeep, type MockItemSubItemDeepDocument, type MockItemSubItemDeepFirestoreCollectionFactory, type MockItemSubItemDeepFirestoreCollectionGroup, type MockItemSubItemDeepRoles, type MockItemDocument, type MockItemFirestoreCollection, type MockItemPrivate, type MockItemPrivateDocument, type MockItemPrivateFirestoreCollectionFactory, type MockItemPrivateFirestoreCollectionGroup, type MockItemPrivateRoles, type MockItemRoles, type MockItemSubItem, type MockItemSubItemDocument, type MockItemSubItemFirestoreCollectionFactory, type MockItemSubItemFirestoreCollectionGroup, type MockItemSubItemRoles, type MockItemTypes, type MockItemUser, type MockItemUserDocument, type MockItemUserFirestoreCollectionFactory, type MockItemUserFirestoreCollectionGroup, type MockItemUserRoles } from './mock.item';
|
|
2
2
|
import { type FirebaseAppModelContext, type FirestoreContext, type SystemStateFirestoreCollection, type SystemState, type SystemStateDocument, type SystemStateTypes } from '@dereekb/firebase';
|
|
3
3
|
import { type GrantedRoleMap } from '@dereekb/model';
|
|
4
|
+
/**
|
|
5
|
+
* Abstract class defining the shape of all mock item Firestore collections.
|
|
6
|
+
*
|
|
7
|
+
* Implementations provide concrete collection instances for each mock model type,
|
|
8
|
+
* including root collections, subcollection factories, and collection groups.
|
|
9
|
+
* Use {@link makeMockItemCollections} to create a concrete instance from a {@link FirestoreContext}.
|
|
10
|
+
*/
|
|
4
11
|
export declare abstract class MockItemCollections {
|
|
5
12
|
abstract readonly mockItemCollection: MockItemFirestoreCollection;
|
|
6
13
|
abstract readonly mockItemPrivateCollectionFactory: MockItemPrivateFirestoreCollectionFactory;
|
|
@@ -13,21 +20,63 @@ export declare abstract class MockItemCollections {
|
|
|
13
20
|
abstract readonly mockItemSubItemDeepCollectionGroup: MockItemSubItemDeepFirestoreCollectionGroup;
|
|
14
21
|
abstract readonly mockItemSystemStateCollection: SystemStateFirestoreCollection;
|
|
15
22
|
}
|
|
23
|
+
/**
|
|
24
|
+
* Creates a concrete {@link MockItemCollections} instance with all collections bound to the given {@link FirestoreContext}.
|
|
25
|
+
*
|
|
26
|
+
* This is the primary way to instantiate the full set of mock collections for a test run.
|
|
27
|
+
*/
|
|
16
28
|
export declare function makeMockItemCollections(firestoreContext: FirestoreContext): MockItemCollections;
|
|
29
|
+
/**
|
|
30
|
+
* Model service factory for {@link MockItem}. Returns configurable roles from `context.rolesToReturn`, defaulting to `{ read: true }`.
|
|
31
|
+
*/
|
|
17
32
|
export declare const mockItemFirebaseModelServiceFactory: import("@dereekb/firebase").FirebaseModelServiceFactory<MockFirebaseContext, MockItem, MockItemDocument, MockItemRoles>;
|
|
33
|
+
/**
|
|
34
|
+
* Model service factory for {@link MockItemPrivate}. Returns configurable roles from `context.rolesToReturn`, defaulting to `{ read: true }`.
|
|
35
|
+
*/
|
|
18
36
|
export declare const mockItemPrivateFirebaseModelServiceFactory: import("@dereekb/firebase").FirebaseModelServiceFactory<MockFirebaseContext, MockItemPrivate, MockItemPrivateDocument, MockItemPrivateRoles>;
|
|
37
|
+
/**
|
|
38
|
+
* Model service factory for {@link MockItemUser}. Grants read access if the authenticated user owns the document;
|
|
39
|
+
* otherwise uses `context.rolesToReturn`.
|
|
40
|
+
*/
|
|
19
41
|
export declare const mockItemUserFirebaseModelServiceFactory: import("@dereekb/firebase").FirebaseModelServiceFactory<MockFirebaseContext, MockItemUser, MockItemUserDocument, MockItemUserRoles>;
|
|
42
|
+
/**
|
|
43
|
+
* Model service factory for {@link MockItemSubItem}. Returns configurable roles from `context.rolesToReturn`, defaulting to `{ read: true }`.
|
|
44
|
+
*/
|
|
20
45
|
export declare const mockItemSubItemFirebaseModelServiceFactory: import("@dereekb/firebase").FirebaseModelServiceFactory<MockFirebaseContext, MockItemSubItem, MockItemSubItemDocument, MockItemSubItemRoles>;
|
|
46
|
+
/**
|
|
47
|
+
* Model service factory for {@link MockItemSubItemDeep}. Returns configurable roles from `context.rolesToReturn`, defaulting to `{ read: true }`.
|
|
48
|
+
*/
|
|
21
49
|
export declare const mockItemSubItemDeepFirebaseModelServiceFactory: import("@dereekb/firebase").FirebaseModelServiceFactory<MockFirebaseContext, MockItemSubItemDeep, MockItemSubItemDeepDocument, MockItemSubItemDeepRoles>;
|
|
50
|
+
/**
|
|
51
|
+
* Model service factory for {@link SystemState}. Only grants access to system admins via {@link grantFullAccessIfAdmin}.
|
|
52
|
+
*/
|
|
22
53
|
export declare const mockItemSystemStateFirebaseModelServiceFactory: import("@dereekb/firebase").FirebaseModelServiceFactory<MockFirebaseContext, SystemState<import("@dereekb/firebase").SystemStateStoredData>, SystemStateDocument<import("@dereekb/firebase").SystemStateStoredData>, "sysadmin">;
|
|
54
|
+
/**
|
|
55
|
+
* Union of all model identity types used in the mock Firebase service layer, including system state.
|
|
56
|
+
*/
|
|
23
57
|
export type MockModelTypes = SystemStateTypes | MockItemTypes;
|
|
58
|
+
/**
|
|
59
|
+
* The application context type for mock Firebase models. Provides access to all mock collections.
|
|
60
|
+
*/
|
|
24
61
|
export type MockFirebaseContextAppContext = MockItemCollections;
|
|
62
|
+
/**
|
|
63
|
+
* Base context for mock Firebase model operations.
|
|
64
|
+
*
|
|
65
|
+
* Combines the standard {@link FirebaseAppModelContext} (which provides `app` and `auth`)
|
|
66
|
+
* with an optional `rolesToReturn` override used by mock role-map functions to return
|
|
67
|
+
* predetermined roles in tests.
|
|
68
|
+
*/
|
|
25
69
|
export type MockFirebaseBaseContext = FirebaseAppModelContext<MockFirebaseContextAppContext> & {
|
|
26
70
|
/**
|
|
27
71
|
* Configured in the context and in mockItem role map functions to return this value if provided.
|
|
28
72
|
*/
|
|
29
73
|
rolesToReturn?: GrantedRoleMap<any>;
|
|
30
74
|
};
|
|
75
|
+
/**
|
|
76
|
+
* Registry of all mock model service factories, keyed by model name.
|
|
77
|
+
*
|
|
78
|
+
* Passed to {@link firebaseModelsService} to create the composite {@link mockFirebaseModelServices}.
|
|
79
|
+
*/
|
|
31
80
|
export declare const MOCK_FIREBASE_MODEL_SERVICE_FACTORIES: {
|
|
32
81
|
systemState: import("@dereekb/firebase").FirebaseModelServiceFactory<MockFirebaseContext, SystemState<import("@dereekb/firebase").SystemStateStoredData>, SystemStateDocument<import("@dereekb/firebase").SystemStateStoredData>, "sysadmin">;
|
|
33
82
|
mockItem: import("@dereekb/firebase").FirebaseModelServiceFactory<MockFirebaseContext, MockItem, MockItemDocument, MockItemRoles>;
|
|
@@ -36,6 +85,11 @@ export declare const MOCK_FIREBASE_MODEL_SERVICE_FACTORIES: {
|
|
|
36
85
|
mockItemSub: import("@dereekb/firebase").FirebaseModelServiceFactory<MockFirebaseContext, MockItemSubItem, MockItemSubItemDocument, MockItemSubItemRoles>;
|
|
37
86
|
mockItemSubItemDeep: import("@dereekb/firebase").FirebaseModelServiceFactory<MockFirebaseContext, MockItemSubItemDeep, MockItemSubItemDeepDocument, MockItemSubItemDeepRoles>;
|
|
38
87
|
};
|
|
88
|
+
/**
|
|
89
|
+
* Composite model service built from {@link MOCK_FIREBASE_MODEL_SERVICE_FACTORIES}.
|
|
90
|
+
*
|
|
91
|
+
* Provides permission checking and collection access for all mock models in a unified API.
|
|
92
|
+
*/
|
|
39
93
|
export declare const mockFirebaseModelServices: import("@dereekb/firebase").FirebaseModelsService<{
|
|
40
94
|
systemState: import("@dereekb/firebase").FirebaseModelServiceFactory<MockFirebaseContext, SystemState<import("@dereekb/firebase").SystemStateStoredData>, SystemStateDocument<import("@dereekb/firebase").SystemStateStoredData>, "sysadmin">;
|
|
41
95
|
mockItem: import("@dereekb/firebase").FirebaseModelServiceFactory<MockFirebaseContext, MockItem, MockItemDocument, MockItemRoles>;
|
|
@@ -44,6 +98,12 @@ export declare const mockFirebaseModelServices: import("@dereekb/firebase").Fire
|
|
|
44
98
|
mockItemSub: import("@dereekb/firebase").FirebaseModelServiceFactory<MockFirebaseContext, MockItemSubItem, MockItemSubItemDocument, MockItemSubItemRoles>;
|
|
45
99
|
mockItemSubItemDeep: import("@dereekb/firebase").FirebaseModelServiceFactory<MockFirebaseContext, MockItemSubItemDeep, MockItemSubItemDeepDocument, MockItemSubItemDeepRoles>;
|
|
46
100
|
}, MockFirebaseContext>;
|
|
101
|
+
/**
|
|
102
|
+
* Full mock Firebase context type used throughout the test suite.
|
|
103
|
+
*
|
|
104
|
+
* Extends {@link MockFirebaseBaseContext} with an optional reference to the composite
|
|
105
|
+
* {@link mockFirebaseModelServices} instance.
|
|
106
|
+
*/
|
|
47
107
|
export type MockFirebaseContext = MockFirebaseBaseContext & {
|
|
48
108
|
service?: typeof mockFirebaseModelServices;
|
|
49
109
|
};
|
|
@@ -1,5 +1,10 @@
|
|
|
1
1
|
import { AbstractWrappedFixtureWithInstance, type TestWrappedContextFactoryBuilder } from '@dereekb/util/test';
|
|
2
2
|
import { type TestFirebaseStorage, type TestFirebaseStorageContextFixture, type TestFirebaseStorageInstance } from '../storage/storage.instance';
|
|
3
|
+
/**
|
|
4
|
+
* Provides access to Firebase Storage for a single test run within a mock item context.
|
|
5
|
+
*
|
|
6
|
+
* Created by {@link MockItemStorageFixture} and exposes the parent fixture's storage and storage context.
|
|
7
|
+
*/
|
|
3
8
|
export declare class MockItemStorageFixtureInstance implements TestFirebaseStorageInstance {
|
|
4
9
|
readonly fixture: MockItemStorageFixture;
|
|
5
10
|
constructor(fixture: MockItemStorageFixture);
|
|
@@ -7,12 +12,34 @@ export declare class MockItemStorageFixtureInstance implements TestFirebaseStora
|
|
|
7
12
|
get storageContext(): import("..").TestFirebaseStorageContext;
|
|
8
13
|
}
|
|
9
14
|
/**
|
|
10
|
-
*
|
|
15
|
+
* Test fixture that wraps a {@link TestFirebaseStorageContextFixture} and provides access to
|
|
16
|
+
* Firebase Storage via {@link MockItemStorageFixtureInstance}.
|
|
17
|
+
*
|
|
18
|
+
* Use {@link testWithMockItemStorageFixture} to create a factory builder for this fixture.
|
|
11
19
|
*/
|
|
12
20
|
export declare class MockItemStorageFixture extends AbstractWrappedFixtureWithInstance<MockItemStorageFixtureInstance, TestFirebaseStorageContextFixture> implements TestFirebaseStorage {
|
|
13
21
|
get storage(): import("@dereekb/firebase").FirebaseStorage;
|
|
14
22
|
get storageContext(): import("..").TestFirebaseStorageContext;
|
|
15
23
|
}
|
|
24
|
+
/**
|
|
25
|
+
* Configuration options for {@link testWithMockItemStorageFixture}.
|
|
26
|
+
*
|
|
27
|
+
* Currently empty; reserved for future setup/teardown customization.
|
|
28
|
+
*/
|
|
16
29
|
export interface MockItemStorageFirebaseStorageContextConfig {
|
|
17
30
|
}
|
|
31
|
+
/**
|
|
32
|
+
* Creates a {@link TestWrappedContextFactoryBuilder} that sets up a {@link MockItemStorageFixture}
|
|
33
|
+
* around a parent {@link TestFirebaseStorageContextFixture}.
|
|
34
|
+
*
|
|
35
|
+
* Compose with a Firebase test context factory to get a fully wired storage test environment:
|
|
36
|
+
*
|
|
37
|
+
* @example
|
|
38
|
+
* ```ts
|
|
39
|
+
* const f = testWithMockItemStorageFixture()(authorizedFirebaseFactory);
|
|
40
|
+
* describe('storage test', () => f.with((instance) => {
|
|
41
|
+
* it('should upload', () => { ... });
|
|
42
|
+
* }));
|
|
43
|
+
* ```
|
|
44
|
+
*/
|
|
18
45
|
export declare function testWithMockItemStorageFixture(config?: MockItemStorageFirebaseStorageContextConfig): TestWrappedContextFactoryBuilder<MockItemStorageFixture, TestFirebaseStorageContextFixture>;
|
|
@@ -1,7 +1,27 @@
|
|
|
1
1
|
import { type FirebaseStorageAccessorDriver, type FirebaseStorageContext, type FirebaseStorageDrivers } from '@dereekb/firebase';
|
|
2
|
+
/**
|
|
3
|
+
* Configuration for {@link makeTestingFirebaseStorageAccesorDriver}.
|
|
4
|
+
*/
|
|
2
5
|
export interface MakeTestingFirebaseStorageAccessorDriverConfig {
|
|
6
|
+
/**
|
|
7
|
+
* Whether to generate a unique test bucket name as the default bucket.
|
|
8
|
+
*
|
|
9
|
+
* When `true`, a randomized bucket name is always generated. When `false`, the
|
|
10
|
+
* original driver's default bucket is preserved. When omitted, a test bucket is
|
|
11
|
+
* generated only if the base driver does not already define a default bucket.
|
|
12
|
+
*/
|
|
3
13
|
useTestDefaultBucket?: boolean;
|
|
4
14
|
}
|
|
15
|
+
/**
|
|
16
|
+
* Creates a {@link TestingFirebaseStorageAccessorDriver} that wraps the given driver,
|
|
17
|
+
* optionally replacing its default bucket with a unique test bucket name.
|
|
18
|
+
*
|
|
19
|
+
* The generated bucket name incorporates a timestamp and random component so that
|
|
20
|
+
* parallel test runs do not collide on the same bucket.
|
|
21
|
+
*
|
|
22
|
+
* @param driver - The base storage accessor driver to wrap.
|
|
23
|
+
* @param config - Optional configuration controlling test bucket behavior.
|
|
24
|
+
*/
|
|
5
25
|
export declare function makeTestingFirebaseStorageAccesorDriver(driver: FirebaseStorageAccessorDriver, config?: MakeTestingFirebaseStorageAccessorDriverConfig): TestingFirebaseStorageAccessorDriver;
|
|
6
26
|
/**
|
|
7
27
|
* Used to override/extend a FirebaseStorageAccessorDriver to provide better isolation between tests.
|
|
@@ -21,7 +41,17 @@ export interface TestingFirebaseStorageDrivers extends FirebaseStorageDrivers {
|
|
|
21
41
|
* @returns
|
|
22
42
|
*/
|
|
23
43
|
export declare function makeTestingFirebaseStorageDrivers(drivers: FirebaseStorageDrivers, config?: MakeTestingFirebaseStorageAccessorDriverConfig): TestingFirebaseStorageDrivers;
|
|
44
|
+
/**
|
|
45
|
+
* Extension applied to a {@link FirebaseStorageContext} to expose the testing-specific drivers.
|
|
46
|
+
*
|
|
47
|
+
* Mixed into the base context type via {@link TestFirebaseStorageContext} so that
|
|
48
|
+
* test code can access the isolated storage driver.
|
|
49
|
+
*/
|
|
24
50
|
export interface TestingFirebaseStorageContextExtension {
|
|
25
51
|
drivers: TestingFirebaseStorageDrivers;
|
|
26
52
|
}
|
|
53
|
+
/**
|
|
54
|
+
* A {@link FirebaseStorageContext} augmented with {@link TestingFirebaseStorageContextExtension},
|
|
55
|
+
* giving tests access to isolated storage drivers with unique bucket names.
|
|
56
|
+
*/
|
|
27
57
|
export type TestFirebaseStorageContext<C = FirebaseStorageContext> = C & TestingFirebaseStorageContextExtension;
|
|
@@ -1,19 +1,41 @@
|
|
|
1
1
|
import { AbstractTestContextFixture, type TestContextFactory } from '@dereekb/util/test';
|
|
2
2
|
import { type FirebaseStorage } from '@dereekb/firebase';
|
|
3
3
|
import { type TestFirebaseStorageContext } from './storage';
|
|
4
|
+
/**
|
|
5
|
+
* Interface describing the minimum shape of a Firebase Storage test instance.
|
|
6
|
+
*
|
|
7
|
+
* Provides access to both the raw {@link FirebaseStorage} reference and the
|
|
8
|
+
* {@link TestFirebaseStorageContext} that includes testing-specific drivers.
|
|
9
|
+
*/
|
|
4
10
|
export interface TestFirebaseStorage {
|
|
5
11
|
readonly storageContext: TestFirebaseStorageContext;
|
|
6
12
|
readonly storage: FirebaseStorage;
|
|
7
13
|
}
|
|
14
|
+
/**
|
|
15
|
+
* Test instance that wraps a {@link TestFirebaseStorageContext} and provides convenient
|
|
16
|
+
* access to the underlying Firebase Storage reference.
|
|
17
|
+
*
|
|
18
|
+
* The context includes a test-specific default bucket name to isolate storage operations
|
|
19
|
+
* between test runs.
|
|
20
|
+
*/
|
|
8
21
|
export declare class TestFirebaseStorageInstance implements TestFirebaseStorage {
|
|
9
22
|
readonly storageContext: TestFirebaseStorageContext;
|
|
10
23
|
constructor(storageContext: TestFirebaseStorageContext);
|
|
11
24
|
get storage(): FirebaseStorage;
|
|
12
25
|
}
|
|
26
|
+
/**
|
|
27
|
+
* Test fixture that manages the lifecycle of a {@link TestFirebaseStorageInstance}.
|
|
28
|
+
*
|
|
29
|
+
* Extends {@link AbstractTestContextFixture} to handle setup/teardown of the Firebase Storage
|
|
30
|
+
* test environment, including isolated bucket naming.
|
|
31
|
+
*/
|
|
13
32
|
export declare class TestFirebaseStorageContextFixture<F extends TestFirebaseStorageInstance = TestFirebaseStorageInstance> extends AbstractTestContextFixture<F> {
|
|
14
33
|
get storage(): FirebaseStorage;
|
|
15
34
|
get storageContext(): TestFirebaseStorageContext;
|
|
16
35
|
}
|
|
36
|
+
/**
|
|
37
|
+
* Factory type for creating {@link TestFirebaseStorageContextFixture} instances in test suites.
|
|
38
|
+
*/
|
|
17
39
|
export type TestFirebaseStorageContextFactory = TestContextFactory<TestFirebaseStorageContextFixture>;
|
|
18
40
|
/**
|
|
19
41
|
* @deprecated Use TestFirebaseStorageContextFactory instead.
|