@fluidframework/local-driver 2.0.0-dev.2.3.0.115467 → 2.0.0-dev.4.1.0.148229
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/.eslintrc.js +19 -22
- package/.mocharc.js +2 -2
- package/api-extractor.json +4 -0
- package/dist/auth.d.ts.map +1 -1
- package/dist/auth.js +2 -2
- package/dist/auth.js.map +1 -1
- package/dist/localCreateDocument.d.ts +8 -0
- package/dist/localCreateDocument.d.ts.map +1 -0
- package/dist/localCreateDocument.js +29 -0
- package/dist/localCreateDocument.js.map +1 -0
- package/dist/localDeltaStorageService.d.ts.map +1 -1
- package/dist/localDeltaStorageService.js.map +1 -1
- package/dist/localDocumentDeltaConnection.d.ts.map +1 -1
- package/dist/localDocumentDeltaConnection.js.map +1 -1
- package/dist/localDocumentService.d.ts.map +1 -1
- package/dist/localDocumentService.js +4 -1
- package/dist/localDocumentService.js.map +1 -1
- package/dist/localDocumentServiceFactory.d.ts +0 -1
- package/dist/localDocumentServiceFactory.d.ts.map +1 -1
- package/dist/localDocumentServiceFactory.js +4 -20
- package/dist/localDocumentServiceFactory.js.map +1 -1
- package/dist/localDocumentStorageService.d.ts +5 -2
- package/dist/localDocumentStorageService.d.ts.map +1 -1
- package/dist/localDocumentStorageService.js +18 -4
- package/dist/localDocumentStorageService.js.map +1 -1
- package/dist/localResolver.d.ts.map +1 -1
- package/dist/localResolver.js.map +1 -1
- package/dist/localSessionStorageDb.d.ts.map +1 -1
- package/dist/localSessionStorageDb.js +3 -2
- package/dist/localSessionStorageDb.js.map +1 -1
- package/dist/packageVersion.d.ts +1 -1
- package/dist/packageVersion.js +1 -1
- package/dist/packageVersion.js.map +1 -1
- package/lib/auth.d.ts +12 -0
- package/lib/auth.d.ts.map +1 -0
- package/lib/auth.js +38 -0
- package/lib/auth.js.map +1 -0
- package/lib/index.d.ts +12 -0
- package/lib/index.d.ts.map +1 -0
- package/lib/index.js +12 -0
- package/lib/index.js.map +1 -0
- package/lib/localCreateDocument.d.ts +8 -0
- package/lib/localCreateDocument.d.ts.map +1 -0
- package/lib/localCreateDocument.js +25 -0
- package/lib/localCreateDocument.js.map +1 -0
- package/lib/localDeltaStorageService.d.ts +19 -0
- package/lib/localDeltaStorageService.d.ts.map +1 -0
- package/lib/localDeltaStorageService.js +31 -0
- package/lib/localDeltaStorageService.js.map +1 -0
- package/lib/localDocumentDeltaConnection.d.ts +47 -0
- package/lib/localDocumentDeltaConnection.d.ts.map +1 -0
- package/lib/localDocumentDeltaConnection.js +88 -0
- package/lib/localDocumentDeltaConnection.js.map +1 -0
- package/lib/localDocumentService.d.ts +52 -0
- package/lib/localDocumentService.d.ts.map +1 -0
- package/lib/localDocumentService.js +80 -0
- package/lib/localDocumentService.js.map +1 -0
- package/lib/localDocumentServiceFactory.d.ts +43 -0
- package/lib/localDocumentServiceFactory.d.ts.map +1 -0
- package/lib/localDocumentServiceFactory.js +81 -0
- package/lib/localDocumentServiceFactory.js.map +1 -0
- package/lib/localDocumentStorageService.d.ts +27 -0
- package/lib/localDocumentStorageService.d.ts.map +1 -0
- package/lib/localDocumentStorageService.js +85 -0
- package/lib/localDocumentStorageService.js.map +1 -0
- package/lib/localResolver.d.ts +26 -0
- package/lib/localResolver.d.ts.map +1 -0
- package/lib/localResolver.js +70 -0
- package/lib/localResolver.js.map +1 -0
- package/lib/localSessionStorageDb.d.ts +10 -0
- package/lib/localSessionStorageDb.d.ts.map +1 -0
- package/lib/localSessionStorageDb.js +295 -0
- package/lib/localSessionStorageDb.js.map +1 -0
- package/lib/packageVersion.d.ts +9 -0
- package/lib/packageVersion.d.ts.map +1 -0
- package/lib/packageVersion.js +9 -0
- package/lib/packageVersion.js.map +1 -0
- package/package.json +59 -49
- package/prettier.config.cjs +1 -1
- package/src/auth.ts +35 -29
- package/src/localCreateDocument.ts +48 -0
- package/src/localDeltaStorageService.ts +26 -29
- package/src/localDocumentDeltaConnection.ts +89 -85
- package/src/localDocumentService.ts +108 -95
- package/src/localDocumentServiceFactory.ts +94 -122
- package/src/localDocumentStorageService.ts +35 -11
- package/src/localResolver.ts +55 -55
- package/src/localSessionStorageDb.ts +270 -263
- package/src/packageVersion.ts +1 -1
- package/tsconfig.esnext.json +7 -0
- package/tsconfig.json +9 -13
|
@@ -12,301 +12,308 @@ import { v4 as uuid } from "uuid";
|
|
|
12
12
|
* Functions include database operations such as queries, insertion and update.
|
|
13
13
|
*/
|
|
14
14
|
class LocalSessionStorageCollection<T> implements ICollection<T> {
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
15
|
+
/**
|
|
16
|
+
* @param collectionName - data type of the collection, e.g. blobs, deltas, trees, etc.
|
|
17
|
+
*/
|
|
18
|
+
constructor(private readonly collectionName: string) {}
|
|
19
19
|
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
20
|
+
public aggregate(pipeline: any, options?: any): any {
|
|
21
|
+
throw new Error("Method Not Implemented");
|
|
22
|
+
}
|
|
23
23
|
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
24
|
+
public async updateMany(filter: any, set: any, addToSet: any): Promise<void> {
|
|
25
|
+
throw new Error("Method Not Implemented");
|
|
26
|
+
}
|
|
27
|
+
public async distinct(key: any, query: any): Promise<any> {
|
|
28
|
+
throw new Error("Method Not Implemented");
|
|
29
|
+
}
|
|
30
|
+
public async findAndUpdate(query: any, value: T): Promise<{ value: T; existing: boolean }> {
|
|
31
|
+
throw new Error("Method not implemented.");
|
|
32
|
+
}
|
|
30
33
|
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
34
|
+
/**
|
|
35
|
+
* {@inheritDoc @fluidframework/server-services-core#ICollection.find}
|
|
36
|
+
*/
|
|
37
|
+
/*
|
|
38
|
+
* Each query key consists of several keys separated by '.' e.g: "operation.sequenceNumber".
|
|
39
|
+
* The hierarchical syntax allows finding nested key patterns.
|
|
40
|
+
*/
|
|
41
|
+
public async find(query: any, sort: any): Promise<any[]> {
|
|
42
|
+
// split the keys and get the corresponding value
|
|
43
|
+
function getValueByKey(propertyBag, key: string) {
|
|
44
|
+
const keys = key.split(".");
|
|
45
|
+
let value = propertyBag;
|
|
46
|
+
keys.forEach((splitKey) => {
|
|
47
|
+
value = value[splitKey];
|
|
48
|
+
});
|
|
49
|
+
// eslint-disable-next-line @typescript-eslint/no-unsafe-return
|
|
50
|
+
return value;
|
|
51
|
+
}
|
|
49
52
|
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
53
|
+
// getting keys of the query we are trying to find
|
|
54
|
+
const queryKeys = Object.keys(query);
|
|
55
|
+
let filteredCollection = this.getAllInternal();
|
|
56
|
+
queryKeys.forEach((key) => {
|
|
57
|
+
if (!query[key]) {
|
|
58
|
+
return;
|
|
59
|
+
}
|
|
60
|
+
if (query[key].$gt > 0 || query[key].$lt > 0) {
|
|
61
|
+
if (query[key].$gt > 0) {
|
|
62
|
+
filteredCollection = filteredCollection.filter(
|
|
63
|
+
(value) => getValueByKey(value, key) > query[key].$gt,
|
|
64
|
+
);
|
|
65
|
+
}
|
|
66
|
+
if (query[key].$lt > 0) {
|
|
67
|
+
filteredCollection = filteredCollection.filter(
|
|
68
|
+
(value) => getValueByKey(value, key) < query[key].$lt,
|
|
69
|
+
);
|
|
70
|
+
}
|
|
71
|
+
} else {
|
|
72
|
+
filteredCollection = filteredCollection.filter(
|
|
73
|
+
(value) => getValueByKey(value, key) === query[key],
|
|
74
|
+
);
|
|
75
|
+
}
|
|
76
|
+
});
|
|
71
77
|
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
78
|
+
if (sort && Object.keys(sort).length === 1) {
|
|
79
|
+
// eslint-disable-next-line no-inner-declarations
|
|
80
|
+
function compare(a, b) {
|
|
81
|
+
const sortKey = Object.keys(sort)[0];
|
|
82
|
+
return sort[sortKey] === 1
|
|
83
|
+
? getValueByKey(a, sortKey) - getValueByKey(b, sortKey)
|
|
84
|
+
: getValueByKey(b, sortKey) - getValueByKey(a, sortKey);
|
|
85
|
+
}
|
|
80
86
|
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
87
|
+
filteredCollection = filteredCollection.sort(compare);
|
|
88
|
+
}
|
|
89
|
+
// eslint-disable-next-line @typescript-eslint/no-unsafe-return
|
|
90
|
+
return filteredCollection;
|
|
91
|
+
}
|
|
86
92
|
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
93
|
+
/**
|
|
94
|
+
* {@inheritDoc @fluidframework/server-services-core#ICollection.findAll}
|
|
95
|
+
*/
|
|
96
|
+
public async findAll(): Promise<any[]> {
|
|
97
|
+
// eslint-disable-next-line @typescript-eslint/no-unsafe-return
|
|
98
|
+
return this.getAllInternal();
|
|
99
|
+
}
|
|
94
100
|
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
101
|
+
/**
|
|
102
|
+
* {@inheritDoc @fluidframework/server-services-core#ICollection.findOne}
|
|
103
|
+
*/
|
|
104
|
+
/*
|
|
105
|
+
* Query is expected to have a member "_id" which is a string used to find value in the database.
|
|
106
|
+
*/
|
|
107
|
+
public async findOne(query: any): Promise<any> {
|
|
108
|
+
// eslint-disable-next-line @typescript-eslint/no-unsafe-return
|
|
109
|
+
return this.findOneInternal(query);
|
|
110
|
+
}
|
|
105
111
|
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
112
|
+
/**
|
|
113
|
+
* {@inheritDoc @fluidframework/server-services-core#ICollection.update}
|
|
114
|
+
*/
|
|
115
|
+
/*
|
|
116
|
+
* Query is expected to have a member "_id" which is a string used to find value in the database.
|
|
117
|
+
*/
|
|
118
|
+
public async update(query: any, set: any, addToSet: any): Promise<void> {
|
|
119
|
+
const value = this.findOneInternal(query);
|
|
120
|
+
if (!value) {
|
|
121
|
+
throw new Error("Not found");
|
|
122
|
+
} else {
|
|
123
|
+
for (const key of Object.keys(set)) {
|
|
124
|
+
value[key] = set[key];
|
|
125
|
+
}
|
|
126
|
+
this.insertInternal(value);
|
|
127
|
+
}
|
|
128
|
+
}
|
|
123
129
|
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
130
|
+
/**
|
|
131
|
+
* {@inheritDoc @fluidframework/server-services-core#ICollection.upsert}
|
|
132
|
+
*/
|
|
133
|
+
/*
|
|
134
|
+
* Query is expected to have a member "_id" which is a string used to find value in the database.
|
|
135
|
+
*/
|
|
136
|
+
public async upsert(query: any, set: any, addToSet: any): Promise<void> {
|
|
137
|
+
const value = this.findOneInternal(query);
|
|
138
|
+
if (!value) {
|
|
139
|
+
this.insertInternal(set);
|
|
140
|
+
} else {
|
|
141
|
+
for (const key of Object.keys(set)) {
|
|
142
|
+
value[key] = set[key];
|
|
143
|
+
}
|
|
144
|
+
this.insertInternal(value);
|
|
145
|
+
}
|
|
146
|
+
}
|
|
141
147
|
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
148
|
+
/**
|
|
149
|
+
* {@inheritDoc @fluidframework/server-services-core#ICollection.insertOne}
|
|
150
|
+
*/
|
|
151
|
+
/*
|
|
152
|
+
* Value is expected to have a member "_id" which is a string used to search in the database.
|
|
153
|
+
*/
|
|
154
|
+
public async insertOne(value: any): Promise<any> {
|
|
155
|
+
const presentVal = this.findOneInternal(value);
|
|
156
|
+
// Only raise error when the object is present and the value is not equal.
|
|
157
|
+
if (presentVal) {
|
|
158
|
+
if (JSON.stringify(presentVal) === JSON.stringify(value)) {
|
|
159
|
+
return;
|
|
160
|
+
}
|
|
161
|
+
throw new Error("Existing Object!!");
|
|
162
|
+
}
|
|
157
163
|
|
|
158
|
-
|
|
159
|
-
|
|
164
|
+
return this.insertInternal(value);
|
|
165
|
+
}
|
|
160
166
|
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
167
|
+
/**
|
|
168
|
+
* {@inheritDoc @fluidframework/server-services-core#ICollection.findOrCreate}
|
|
169
|
+
*/
|
|
170
|
+
/*
|
|
171
|
+
* Value and query are expected to have a member "_id" which is a string used to search or insert in the database.
|
|
172
|
+
*/
|
|
173
|
+
public async findOrCreate(query: any, value: any): Promise<{ value: any; existing: boolean }> {
|
|
174
|
+
const existing = this.findOneInternal(query);
|
|
175
|
+
if (existing) {
|
|
176
|
+
return { value: existing, existing: true };
|
|
177
|
+
}
|
|
178
|
+
this.insertInternal(value);
|
|
179
|
+
return { value, existing: false };
|
|
180
|
+
}
|
|
175
181
|
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
182
|
+
/**
|
|
183
|
+
* {@inheritDoc @fluidframework/server-services-core#ICollection.insertMany}
|
|
184
|
+
*/
|
|
185
|
+
/*
|
|
186
|
+
* Each element in values is expected to have a member "_id" which is a string used to insert in the database.
|
|
187
|
+
*/
|
|
188
|
+
public async insertMany(values: any[], ordered: boolean): Promise<void> {
|
|
189
|
+
this.insertInternal(...values);
|
|
190
|
+
}
|
|
185
191
|
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
+
/**
|
|
193
|
+
* {@inheritDoc @fluidframework/server-services-core#ICollection.deleteOne}
|
|
194
|
+
*/
|
|
195
|
+
public async deleteOne(query: any): Promise<any> {
|
|
196
|
+
throw new Error("Method not implemented.");
|
|
197
|
+
}
|
|
192
198
|
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
+
/**
|
|
200
|
+
* {@inheritDoc @fluidframework/server-services-core#ICollection.deleteMany}
|
|
201
|
+
*/
|
|
202
|
+
public async deleteMany(query: any): Promise<any> {
|
|
203
|
+
throw new Error("Method not implemented.");
|
|
204
|
+
}
|
|
199
205
|
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
+
/**
|
|
207
|
+
* {@inheritDoc @fluidframework/server-services-core#ICollection.createIndex}
|
|
208
|
+
*/
|
|
209
|
+
public async createIndex(index: any, unique: boolean): Promise<void> {
|
|
210
|
+
throw new Error("Method not implemented.");
|
|
211
|
+
}
|
|
206
212
|
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
213
|
+
/**
|
|
214
|
+
* Return all values in the database
|
|
215
|
+
*/
|
|
216
|
+
private getAllInternal(): any[] {
|
|
217
|
+
const values: string[] = [];
|
|
218
|
+
for (let i = 0; i < sessionStorage.length; i++) {
|
|
219
|
+
const key = sessionStorage.key(i);
|
|
220
|
+
// eslint-disable-next-line @typescript-eslint/no-non-null-assertion
|
|
221
|
+
if (key!.startsWith(this.collectionName)) {
|
|
222
|
+
// eslint-disable-next-line @typescript-eslint/no-non-null-assertion
|
|
223
|
+
values.push(JSON.parse(sessionStorage.getItem(key!)!));
|
|
224
|
+
}
|
|
225
|
+
}
|
|
226
|
+
return values;
|
|
227
|
+
}
|
|
222
228
|
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
229
|
+
/**
|
|
230
|
+
* Inserts values into the session storge.
|
|
231
|
+
* Values are expected to have a member "_id" which is a unique id, otherwise will be assigned one
|
|
232
|
+
*
|
|
233
|
+
* @param values - data to insert to the database
|
|
234
|
+
*/
|
|
235
|
+
private insertInternal(...values: any[]) {
|
|
236
|
+
for (const value of values) {
|
|
237
|
+
if (value) {
|
|
238
|
+
if (!value._id) {
|
|
239
|
+
value._id = uuid();
|
|
240
|
+
}
|
|
241
|
+
sessionStorage.setItem(
|
|
242
|
+
`${this.collectionName}-${value._id}`,
|
|
243
|
+
JSON.stringify(value),
|
|
244
|
+
);
|
|
245
|
+
}
|
|
246
|
+
}
|
|
247
|
+
}
|
|
239
248
|
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
}
|
|
249
|
+
/**
|
|
250
|
+
* Finds the query in session storage and returns its value.
|
|
251
|
+
* Returns null if query is not found.
|
|
252
|
+
* Query is expected to have a member "_id" which is a unique id.
|
|
253
|
+
*
|
|
254
|
+
* @param query - what to find in the database
|
|
255
|
+
*/
|
|
256
|
+
private findOneInternal(query: any): any {
|
|
257
|
+
if (query._id) {
|
|
258
|
+
const json = sessionStorage.getItem(`${this.collectionName}-${query._id}`);
|
|
259
|
+
if (json) {
|
|
260
|
+
return JSON.parse(json);
|
|
261
|
+
}
|
|
262
|
+
} else {
|
|
263
|
+
const queryKeys = Object.keys(query);
|
|
264
|
+
for (let i = 0; i < sessionStorage.length; i++) {
|
|
265
|
+
const ssKey = sessionStorage.key(i);
|
|
266
|
+
// eslint-disable-next-line @typescript-eslint/no-non-null-assertion
|
|
267
|
+
if (!ssKey!.startsWith(this.collectionName)) {
|
|
268
|
+
continue;
|
|
269
|
+
}
|
|
270
|
+
// eslint-disable-next-line @typescript-eslint/no-non-null-assertion
|
|
271
|
+
const value = JSON.parse(sessionStorage.getItem(ssKey!)!);
|
|
272
|
+
let foundMismatch = false;
|
|
273
|
+
for (const qk of queryKeys) {
|
|
274
|
+
if (value[qk] !== query[qk]) {
|
|
275
|
+
foundMismatch = true;
|
|
276
|
+
break;
|
|
277
|
+
}
|
|
278
|
+
}
|
|
271
279
|
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
}
|
|
280
|
+
if (!foundMismatch) {
|
|
281
|
+
return value;
|
|
282
|
+
}
|
|
283
|
+
}
|
|
284
|
+
}
|
|
285
|
+
return null;
|
|
286
|
+
}
|
|
280
287
|
}
|
|
281
288
|
|
|
282
289
|
/**
|
|
283
290
|
* A database for testing that stores data in the browsers session storage
|
|
284
291
|
*/
|
|
285
292
|
class LocalSessionStorageDb extends EventEmitter implements IDb {
|
|
286
|
-
|
|
287
|
-
|
|
288
|
-
|
|
289
|
-
|
|
290
|
-
|
|
291
|
-
|
|
292
|
-
|
|
293
|
-
|
|
293
|
+
private readonly collections = new Map<string, LocalSessionStorageCollection<any>>();
|
|
294
|
+
public async close(): Promise<void> {}
|
|
295
|
+
public collection<T>(name: string): ICollection<T> {
|
|
296
|
+
if (!this.collections.has(name)) {
|
|
297
|
+
this.collections.set(name, new LocalSessionStorageCollection<T>(name));
|
|
298
|
+
}
|
|
299
|
+
return this.collections.get(name) as LocalSessionStorageCollection<T>;
|
|
300
|
+
}
|
|
294
301
|
|
|
295
|
-
|
|
296
|
-
|
|
297
|
-
|
|
298
|
-
|
|
299
|
-
|
|
300
|
-
|
|
301
|
-
|
|
302
|
+
public async dropCollection(name: string): Promise<boolean> {
|
|
303
|
+
if (!this.collections.has(name)) {
|
|
304
|
+
return true;
|
|
305
|
+
}
|
|
306
|
+
this.collections.delete(name);
|
|
307
|
+
return true;
|
|
308
|
+
}
|
|
302
309
|
}
|
|
303
310
|
|
|
304
311
|
/**
|
|
305
312
|
* A database factory for testing that stores data in the browsers session storage
|
|
306
313
|
*/
|
|
307
314
|
export class LocalSessionStorageDbFactory implements ITestDbFactory {
|
|
308
|
-
|
|
309
|
-
|
|
310
|
-
|
|
311
|
-
|
|
315
|
+
public readonly testDatabase: IDb = new LocalSessionStorageDb();
|
|
316
|
+
public async connect(): Promise<IDb> {
|
|
317
|
+
return this.testDatabase;
|
|
318
|
+
}
|
|
312
319
|
}
|
package/src/packageVersion.ts
CHANGED
package/tsconfig.json
CHANGED
|
@@ -1,14 +1,10 @@
|
|
|
1
1
|
{
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
"include": [
|
|
12
|
-
"src/**/*"
|
|
13
|
-
]
|
|
14
|
-
}
|
|
2
|
+
"extends": "@fluidframework/build-common/ts-common-config.json",
|
|
3
|
+
"exclude": ["src/test/**/*"],
|
|
4
|
+
"compilerOptions": {
|
|
5
|
+
"rootDir": "./src",
|
|
6
|
+
"outDir": "./dist",
|
|
7
|
+
"composite": true,
|
|
8
|
+
},
|
|
9
|
+
"include": ["src/**/*"],
|
|
10
|
+
}
|