houdini 1.2.5 → 1.2.6

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.
Files changed (47) hide show
  1. package/build/cmd-cjs/index.js +613 -562
  2. package/build/cmd-esm/index.js +613 -562
  3. package/build/codegen/generators/artifacts/selection.d.ts +1 -3
  4. package/build/codegen-cjs/index.js +600 -549
  5. package/build/codegen-esm/index.js +600 -549
  6. package/build/lib-cjs/index.js +41 -10
  7. package/build/lib-esm/index.js +41 -10
  8. package/build/runtime/cache/cache.d.ts +2 -0
  9. package/build/runtime/cache/gc.d.ts +1 -0
  10. package/build/runtime/cache/lists.d.ts +1 -0
  11. package/build/runtime/cache/staleManager.d.ts +1 -0
  12. package/build/runtime/cache/storage.d.ts +1 -0
  13. package/build/runtime/cache/subscription.d.ts +2 -1
  14. package/build/runtime/public/cache.d.ts +4 -0
  15. package/build/runtime-cjs/cache/cache.d.ts +2 -0
  16. package/build/runtime-cjs/cache/cache.js +16 -10
  17. package/build/runtime-cjs/cache/gc.d.ts +1 -0
  18. package/build/runtime-cjs/cache/gc.js +3 -0
  19. package/build/runtime-cjs/cache/lists.d.ts +1 -0
  20. package/build/runtime-cjs/cache/lists.js +4 -0
  21. package/build/runtime-cjs/cache/staleManager.d.ts +1 -0
  22. package/build/runtime-cjs/cache/staleManager.js +3 -0
  23. package/build/runtime-cjs/cache/storage.d.ts +1 -0
  24. package/build/runtime-cjs/cache/storage.js +3 -0
  25. package/build/runtime-cjs/cache/subscription.d.ts +2 -1
  26. package/build/runtime-cjs/cache/subscription.js +13 -0
  27. package/build/runtime-cjs/public/cache.d.ts +4 -0
  28. package/build/runtime-cjs/public/cache.js +3 -0
  29. package/build/runtime-esm/cache/cache.d.ts +2 -0
  30. package/build/runtime-esm/cache/cache.js +16 -10
  31. package/build/runtime-esm/cache/gc.d.ts +1 -0
  32. package/build/runtime-esm/cache/gc.js +3 -0
  33. package/build/runtime-esm/cache/lists.d.ts +1 -0
  34. package/build/runtime-esm/cache/lists.js +4 -0
  35. package/build/runtime-esm/cache/staleManager.d.ts +1 -0
  36. package/build/runtime-esm/cache/staleManager.js +3 -0
  37. package/build/runtime-esm/cache/storage.d.ts +1 -0
  38. package/build/runtime-esm/cache/storage.js +3 -0
  39. package/build/runtime-esm/cache/subscription.d.ts +2 -1
  40. package/build/runtime-esm/cache/subscription.js +13 -0
  41. package/build/runtime-esm/public/cache.d.ts +4 -0
  42. package/build/runtime-esm/public/cache.js +3 -0
  43. package/build/test-cjs/index.js +603 -552
  44. package/build/test-esm/index.js +603 -552
  45. package/build/vite-cjs/index.js +618 -567
  46. package/build/vite-esm/index.js +618 -567
  47. package/package.json +1 -1
@@ -4,6 +4,7 @@ export declare class GarbageCollector {
4
4
  private lifetimes;
5
5
  get cacheBufferSize(): number;
6
6
  constructor(cache: Cache);
7
+ reset(): void;
7
8
  resetLifetime(id: string, field: string): void;
8
9
  tick(): void;
9
10
  }
@@ -7,6 +7,9 @@ class GarbageCollector {
7
7
  constructor(cache) {
8
8
  this.cache = cache;
9
9
  }
10
+ reset() {
11
+ this.lifetimes.clear();
12
+ }
10
13
  resetLifetime(id, field) {
11
14
  if (!this.lifetimes.get(id)) {
12
15
  this.lifetimes.set(id, /* @__PURE__ */ new Map());
@@ -23,6 +23,7 @@ export declare class ListManager {
23
23
  }): void;
24
24
  removeIDFromAllLists(id: string, layer?: Layer): void;
25
25
  deleteField(parentID: string, field: string): void;
26
+ reset(): void;
26
27
  }
27
28
  export declare class List {
28
29
  readonly recordID: string;
@@ -83,6 +83,10 @@ class ListManager {
83
83
  }
84
84
  this.listsByField.get(parentID).delete(field);
85
85
  }
86
+ reset() {
87
+ this.lists.clear();
88
+ this.listsByField.clear();
89
+ }
86
90
  }
87
91
  class List {
88
92
  recordID;
@@ -27,4 +27,5 @@ export declare class StaleManager {
27
27
  markTypeStale(type: string): void;
28
28
  markTypeFieldStale(type: string, field: string, when?: {}): void;
29
29
  delete(id: string, field: string): void;
30
+ reset(): void;
30
31
  }
@@ -65,6 +65,9 @@ class StaleManager {
65
65
  }
66
66
  }
67
67
  }
68
+ reset() {
69
+ this.fieldsTime.clear();
70
+ }
68
71
  }
69
72
  export {
70
73
  StaleManager
@@ -31,6 +31,7 @@ export declare class InMemoryStorage {
31
31
  fields: EntityFieldMap;
32
32
  links: LinkMap;
33
33
  }, layer?: Layer): void;
34
+ reset(): void;
34
35
  }
35
36
  export declare class Layer {
36
37
  readonly id: LayerID;
@@ -176,6 +176,9 @@ class InMemoryStorage {
176
176
  layer.fields = fields;
177
177
  layer.links = links;
178
178
  }
179
+ reset() {
180
+ this.data = [];
181
+ }
179
182
  }
180
183
  class Layer {
181
184
  id;
@@ -1,5 +1,5 @@
1
1
  import type { GraphQLValue, SubscriptionSelection, SubscriptionSpec } from '../lib/types';
2
- import type { Cache } from './cache';
2
+ import { type Cache } from './cache';
3
3
  export type FieldSelection = [
4
4
  SubscriptionSpec,
5
5
  Required<SubscriptionSelection>['fields'] | undefined
@@ -43,6 +43,7 @@ export declare class InMemorySubscriptions {
43
43
  }): void;
44
44
  get(id: string, field: string): FieldSelection[];
45
45
  remove(id: string, selection: SubscriptionSelection, targets: SubscriptionSpec[], variables: {}, visited?: string[]): void;
46
+ reset(): SubscriptionSpec[];
46
47
  private removeSubscribers;
47
48
  removeAllSubscribers(id: string, targets?: SubscriptionSpec[], visited?: string[]): void;
48
49
  }
@@ -1,5 +1,6 @@
1
1
  import { flatten } from "../lib/flatten";
2
2
  import { getFieldsForType } from "../lib/selection";
3
+ import { rootID } from "./cache";
3
4
  import { evaluateKey } from "./stuff";
4
5
  class InMemorySubscriptions {
5
6
  cache;
@@ -216,6 +217,18 @@ class InMemorySubscriptions {
216
217
  this.remove(linkedRecordID, linkFields, targets, visited);
217
218
  }
218
219
  }
220
+ reset() {
221
+ const subscribers = Object.entries(this.subscribers).filter(
222
+ ([id]) => !id.startsWith(rootID)
223
+ );
224
+ for (const [id, _fields] of subscribers) {
225
+ delete this.subscribers[id];
226
+ }
227
+ const subscriptionSpecs = subscribers.flatMap(
228
+ ([_id, fields]) => Object.values(fields).flatMap((field) => field.map(([spec]) => spec))
229
+ );
230
+ return subscriptionSpecs;
231
+ }
219
232
  removeSubscribers(id, fieldName, specs) {
220
233
  let targets = [];
221
234
  for (const spec of specs) {
@@ -36,4 +36,8 @@ export declare class Cache<Def extends CacheTypeDef> {
36
36
  field?: _Field;
37
37
  when?: ArgType<Def, _Type, _Field>;
38
38
  }): void;
39
+ /**
40
+ * Reset the entire cache by clearing all records and lists
41
+ */
42
+ reset(): void;
39
43
  }
@@ -67,6 +67,9 @@ Please acknowledge this by setting acceptImperativeInstability to true in your c
67
67
  markStale(type, options) {
68
68
  return this._internal_unstable.markTypeStale(type ? { ...options, type } : void 0);
69
69
  }
70
+ reset() {
71
+ return this._internal_unstable.reset();
72
+ }
70
73
  }
71
74
  export {
72
75
  Cache