@ethlete/query 6.0.0-next.44 → 6.0.0-next.46
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/CHANGELOG.md +91 -0
- package/fesm2022/ethlete-query-testing.mjs +138 -52
- package/fesm2022/ethlete-query-testing.mjs.map +1 -1
- package/fesm2022/ethlete-query.mjs +1978 -957
- package/fesm2022/ethlete-query.mjs.map +1 -1
- package/generators/migrate-to-query-v3/cleanup-migration.js +11 -10
- package/package.json +5 -5
- package/types/ethlete-query-testing.d.ts +37 -5
- package/types/ethlete-query.d.ts +312 -118
|
@@ -10,7 +10,7 @@ import { createSourceFile, ensureImportFromQuery, ensureNamedImports, getLineNum
|
|
|
10
10
|
*/
|
|
11
11
|
export const migrateDevtoolsUsage = (tree, scope, report) => {
|
|
12
12
|
const updatedFiles = [];
|
|
13
|
-
const
|
|
13
|
+
const filesNeedingDevtoolsPackage = [];
|
|
14
14
|
scope.visit(tree, (filePath) => {
|
|
15
15
|
if (!filePath.endsWith('.ts')) {
|
|
16
16
|
return;
|
|
@@ -27,7 +27,7 @@ export const migrateDevtoolsUsage = (tree, scope, report) => {
|
|
|
27
27
|
tree.write(filePath, nextContent);
|
|
28
28
|
updatedFiles.push(filePath);
|
|
29
29
|
if (importsComponent) {
|
|
30
|
-
|
|
30
|
+
filesNeedingDevtoolsPackage.push(filePath);
|
|
31
31
|
}
|
|
32
32
|
});
|
|
33
33
|
if (updatedFiles.length === 0) {
|
|
@@ -35,16 +35,17 @@ export const migrateDevtoolsUsage = (tree, scope, report) => {
|
|
|
35
35
|
}
|
|
36
36
|
console.log('\n✅ Migrated query devtools usage to v3 in:');
|
|
37
37
|
updatedFiles.forEach((filePath) => console.log(` - ${filePath}`));
|
|
38
|
-
if (
|
|
38
|
+
if (filesNeedingDevtoolsPackage.length > 0) {
|
|
39
39
|
// The component moved packages, which is the one part of this rewrite that can fail outside the
|
|
40
|
-
// file being edited: an app that only ever depended on `@ethlete/query` now needs
|
|
40
|
+
// file being edited: an app that only ever depended on `@ethlete/query` now needs
|
|
41
|
+
// `@ethlete/query-devtools`.
|
|
41
42
|
report.addManualReview({
|
|
42
|
-
title: 'Add @ethlete/
|
|
43
|
-
summary: '`QueryDevtoolsComponent` now lives in `@ethlete/
|
|
44
|
-
action: 'Run `yarn add @ethlete/
|
|
45
|
-
locations:
|
|
43
|
+
title: 'Add @ethlete/query-devtools for the query devtools',
|
|
44
|
+
summary: '`QueryDevtoolsComponent` now lives in `@ethlete/query-devtools`. The imports were rewritten, but the package may not be a dependency of these projects yet.',
|
|
45
|
+
action: 'Run `yarn add @ethlete/query-devtools` where needed, then `yarn install` and re-lint the affected libs so the `@nx/dependency-checks` rule sees the new dependency.',
|
|
46
|
+
locations: filesNeedingDevtoolsPackage.map((filePath) => ({ filePath })),
|
|
46
47
|
source: 'cleanup-migration',
|
|
47
|
-
dedupeKey: 'devtools-
|
|
48
|
+
dedupeKey: 'devtools-package-dependency',
|
|
48
49
|
});
|
|
49
50
|
}
|
|
50
51
|
};
|
|
@@ -100,7 +101,7 @@ const migrateDevtoolsInFile = (content) => {
|
|
|
100
101
|
result = ensureNamedImports({
|
|
101
102
|
content: result,
|
|
102
103
|
importsNeeded: ['QueryDevtoolsComponent'],
|
|
103
|
-
moduleSpecifier: '@ethlete/
|
|
104
|
+
moduleSpecifier: '@ethlete/query-devtools',
|
|
104
105
|
});
|
|
105
106
|
}
|
|
106
107
|
return { content: result, importsComponent };
|
package/package.json
CHANGED
|
@@ -1,14 +1,14 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@ethlete/query",
|
|
3
|
-
"version": "6.0.0-next.
|
|
3
|
+
"version": "6.0.0-next.46",
|
|
4
4
|
"license": "MIT",
|
|
5
5
|
"sideEffects": false,
|
|
6
6
|
"peerDependencies": {
|
|
7
7
|
"@analogjs/vite-plugin-angular": "2.6.3",
|
|
8
|
-
"@angular/common": "22.
|
|
9
|
-
"@angular/core": "22.
|
|
10
|
-
"@angular/forms": "22.
|
|
11
|
-
"@angular/router": "22.
|
|
8
|
+
"@angular/common": "22.1.6",
|
|
9
|
+
"@angular/core": "22.1.6",
|
|
10
|
+
"@angular/forms": "22.1.6",
|
|
11
|
+
"@angular/router": "22.1.6",
|
|
12
12
|
"@ethlete/core": "^5.0.0-beta.11",
|
|
13
13
|
"@ethlete/types": "^2.0.0-beta.4",
|
|
14
14
|
"@nx/devkit": "23.1.0",
|
|
@@ -15,6 +15,11 @@ type QueryTestSetup = {
|
|
|
15
15
|
createPut: ReturnType<typeof createPutQuery>;
|
|
16
16
|
createPatch: ReturnType<typeof createPatchQuery>;
|
|
17
17
|
createDelete: ReturnType<typeof createDeleteQuery>;
|
|
18
|
+
/**
|
|
19
|
+
* Puts back the `console.warn` / `console.error` that were installed before the first
|
|
20
|
+
* {@link setupQueryTest} call. Idempotent, and safe to call from any of the setups a file created.
|
|
21
|
+
*/
|
|
22
|
+
restoreConsole: () => void;
|
|
18
23
|
};
|
|
19
24
|
type QueryTestSetupConfig = {
|
|
20
25
|
baseUrl?: string;
|
|
@@ -235,6 +240,8 @@ type FakeQueryPersistenceStoreHandle = {
|
|
|
235
240
|
calls: () => Record<'loadIndex' | 'read' | 'write' | 'remove' | 'clear', number>;
|
|
236
241
|
/** Makes the next `count` writes reject - a full disk, by default. */
|
|
237
242
|
failNextWrites: (count: number, error?: unknown) => void;
|
|
243
|
+
/** Makes the next `count` removals reject. */
|
|
244
|
+
failNextRemoves: (count: number, error?: unknown) => void;
|
|
238
245
|
/** Makes the next `loadIndex` reject. */
|
|
239
246
|
failNextLoadIndex: (error?: unknown) => void;
|
|
240
247
|
/**
|
|
@@ -245,6 +252,14 @@ type FakeQueryPersistenceStoreHandle = {
|
|
|
245
252
|
deferReads: () => void;
|
|
246
253
|
/** Settles the reads held by {@link deferReads} and stops deferring. */
|
|
247
254
|
flushReads: () => Promise<void>;
|
|
255
|
+
/**
|
|
256
|
+
* Holds every subsequent `loadIndex` pending until {@link flushLoadIndex} is called, for testing
|
|
257
|
+
* what happens to the store while a client's startup is still reading its index (a real disk takes
|
|
258
|
+
* milliseconds). The snapshot each held load returns is the one it would have read when it started.
|
|
259
|
+
*/
|
|
260
|
+
deferLoadIndex: () => void;
|
|
261
|
+
/** Settles the index loads held by {@link deferLoadIndex} and stops deferring. */
|
|
262
|
+
flushLoadIndex: () => Promise<void>;
|
|
248
263
|
};
|
|
249
264
|
declare const createFakeQueryPersistenceStore: () => FakeQueryPersistenceStoreHandle;
|
|
250
265
|
|
|
@@ -266,20 +281,37 @@ type WebSocketTestDouble = {
|
|
|
266
281
|
url: string;
|
|
267
282
|
transports: string[] | undefined;
|
|
268
283
|
} | null;
|
|
269
|
-
/**
|
|
284
|
+
/** The `withCredentials` the client asked the factory for, or `null` until it called it. */
|
|
285
|
+
withCredentials: () => boolean | null;
|
|
286
|
+
/** Every message the client emitted, newest last - room joins and leaves included, buffered ones too. */
|
|
270
287
|
sent: () => {
|
|
271
288
|
event: string;
|
|
272
289
|
data: unknown;
|
|
273
290
|
}[];
|
|
291
|
+
/** Every message that reached the server, newest last. An emit buffered while offline lands here on the next connect. */
|
|
292
|
+
delivered: () => {
|
|
293
|
+
event: string;
|
|
294
|
+
data: unknown;
|
|
295
|
+
}[];
|
|
274
296
|
/** Whether the client asked the socket to connect, and whether it has since disconnected it. */
|
|
275
297
|
state: () => {
|
|
276
298
|
connectRequested: boolean;
|
|
277
299
|
disconnected: boolean;
|
|
278
300
|
};
|
|
279
|
-
/**
|
|
280
|
-
|
|
301
|
+
/**
|
|
302
|
+
* Complete the handshake: flush every buffered emit, then turn the client's `isConnected` true. Pass
|
|
303
|
+
* `recovered: true` for a connection-state-recovered reconnect, in which the server kept the rooms.
|
|
304
|
+
*/
|
|
305
|
+
serverConnect: (options?: {
|
|
306
|
+
recovered?: boolean;
|
|
307
|
+
}) => void;
|
|
281
308
|
/** Drop the connection, so `isConnected` turns false. */
|
|
282
309
|
serverDisconnect: () => void;
|
|
310
|
+
/**
|
|
311
|
+
* Let the ping expire: the socket still reports itself connected, but buffers every emit like socket.io
|
|
312
|
+
* does until it notices and closes. Follow it with {@link serverDisconnect}.
|
|
313
|
+
*/
|
|
314
|
+
serverPingExpire: () => void;
|
|
283
315
|
/** Deliver a message the way the server would. */
|
|
284
316
|
serverSend: (message: SocketMessageView) => void;
|
|
285
317
|
/** Deliver a raw frame, for the malformed-payload path. */
|
|
@@ -291,8 +323,8 @@ type WebSocketTestDouble = {
|
|
|
291
323
|
*
|
|
292
324
|
* Nothing here connects on its own: the client's own `connect()` only flips
|
|
293
325
|
* {@link WebSocketTestDouble.state}, and it is {@link WebSocketTestDouble.serverConnect} that fires
|
|
294
|
-
* the `connect` listener. That split is what makes "joined a room while disconnected, and
|
|
295
|
-
*
|
|
326
|
+
* the `connect` listener. That split is what makes "joined a room while disconnected, and it was
|
|
327
|
+
* re-joined after a reconnect" testable.
|
|
296
328
|
*/
|
|
297
329
|
declare const createWebSocketTestDouble: () => WebSocketTestDouble;
|
|
298
330
|
|