@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.
@@ -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 filesNeedingComponentsPackage = [];
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
- filesNeedingComponentsPackage.push(filePath);
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 (filesNeedingComponentsPackage.length > 0) {
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 `@ethlete/components`.
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/components for the query devtools',
43
- summary: '`QueryDevtoolsComponent` now lives in `@ethlete/components`. The imports were rewritten, but the package may not be a dependency of these projects yet.',
44
- action: 'Run `yarn add @ethlete/components` where needed, then `yarn install` and re-lint the affected libs so the `@nx/dependency-checks` rule sees the new dependency.',
45
- locations: filesNeedingComponentsPackage.map((filePath) => ({ filePath })),
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-components-dependency',
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/components',
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.44",
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.0.7",
9
- "@angular/core": "22.0.7",
10
- "@angular/forms": "22.0.7",
11
- "@angular/router": "22.0.7",
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
- /** Every message the client sent, newest last - room joins and leaves included. */
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
- /** Complete the handshake, so the client's `isConnected` turns true and queued rooms re-join. */
280
- serverConnect: () => void;
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 the join
295
- * was re-sent on connect" testable.
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