houdini 1.4.0 → 1.4.2

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 (36) hide show
  1. package/build/cmd-cjs/index.js +19080 -15237
  2. package/build/cmd-esm/index.js +19122 -15279
  3. package/build/codegen/transforms/addFields.d.ts +2 -0
  4. package/build/codegen/transforms/index.d.ts +1 -1
  5. package/build/codegen/transforms/paginate.d.ts +1 -1
  6. package/build/codegen-cjs/index.js +13151 -9312
  7. package/build/codegen-esm/index.js +15779 -11940
  8. package/build/lib/fs.d.ts +1 -2
  9. package/build/lib/graphql.d.ts +2 -2
  10. package/build/lib/router/server.d.ts +1 -1
  11. package/build/lib-cjs/index.js +8497 -4665
  12. package/build/lib-esm/index.js +8490 -4658
  13. package/build/runtime/cache/cache.d.ts +1 -1
  14. package/build/runtime/cache/lists.d.ts +3 -1
  15. package/build/runtime/router/types.d.ts +1 -1
  16. package/build/runtime-cjs/cache/cache.d.ts +1 -1
  17. package/build/runtime-cjs/cache/cache.js +31 -5
  18. package/build/runtime-cjs/cache/lists.d.ts +3 -1
  19. package/build/runtime-cjs/cache/lists.js +15 -1
  20. package/build/runtime-cjs/client/plugins/fetch.js +1 -1
  21. package/build/runtime-cjs/router/match.js +1 -1
  22. package/build/runtime-cjs/router/types.d.ts +1 -1
  23. package/build/runtime-esm/cache/cache.d.ts +1 -1
  24. package/build/runtime-esm/cache/cache.js +31 -5
  25. package/build/runtime-esm/cache/lists.d.ts +3 -1
  26. package/build/runtime-esm/cache/lists.js +15 -1
  27. package/build/runtime-esm/client/plugins/fetch.js +1 -1
  28. package/build/runtime-esm/router/match.js +1 -1
  29. package/build/runtime-esm/router/types.d.ts +1 -1
  30. package/build/test-cjs/index.js +12552 -8713
  31. package/build/test-esm/index.js +17371 -13532
  32. package/build/vite/ast.d.ts +8 -2
  33. package/build/vite-cjs/index.js +16944 -13090
  34. package/build/vite-esm/index.js +20040 -16186
  35. package/package.json +7 -4
  36. package/build/codegen/transforms/addID.d.ts +0 -2
@@ -35,7 +35,7 @@ export declare class Cache {
35
35
  };
36
36
  subscribe(spec: SubscriptionSpec, variables?: {}): void;
37
37
  unsubscribe(spec: SubscriptionSpec, variables?: {}): void;
38
- list(name: string, parentID?: string, allLists?: boolean): ListCollection;
38
+ list(name: string, parentID?: string, allLists?: boolean, skipMatches?: Set<string>): ListCollection;
39
39
  registerKeyMap(source: string, mapped: string): void;
40
40
  delete(id: string, layer?: Layer): void;
41
41
  setConfig(config: ConfigFile): void;
@@ -7,7 +7,8 @@ export declare class ListManager {
7
7
  constructor(cache: Cache, rootID: string);
8
8
  lists: Map<string, Map<string, ListCollection>>;
9
9
  private listsByField;
10
- get(listName: string, id?: string, allLists?: boolean): ListCollection | null | undefined;
10
+ get(listName: string, id?: string, allLists?: boolean, skipMatches?: Set<string>): ListCollection | null;
11
+ getLists(listName: string, id?: string, allLists?: boolean): ListCollection | null | undefined;
11
12
  remove(listName: string, id: string): void;
12
13
  add(list: {
13
14
  name: string;
@@ -41,6 +42,7 @@ export declare class List {
41
42
  constructor({ name, recordID, recordType, key, listType, selection, when, filters, connection, manager, abstract, }: Parameters<ListManager['add']>[0] & {
42
43
  manager: ListManager;
43
44
  });
45
+ get fieldRef(): string;
44
46
  when(when?: ListWhen): ListCollection;
45
47
  append({ selection, data, variables, layer, }: {
46
48
  selection: SubscriptionSelection;
@@ -21,6 +21,6 @@ export type RouterPageManifest<_ComponentType> = {
21
21
  }>;
22
22
  }>;
23
23
  component: () => Promise<{
24
- default: (props: any) => _ComponentType;
24
+ default: _ComponentType;
25
25
  }>;
26
26
  };
@@ -35,7 +35,7 @@ export declare class Cache {
35
35
  };
36
36
  subscribe(spec: SubscriptionSpec, variables?: {}): void;
37
37
  unsubscribe(spec: SubscriptionSpec, variables?: {}): void;
38
- list(name: string, parentID?: string, allLists?: boolean): ListCollection;
38
+ list(name: string, parentID?: string, allLists?: boolean, skipMatches?: Set<string>): ListCollection;
39
39
  registerKeyMap(source: string, mapped: string): void;
40
40
  delete(id: string, layer?: Layer): void;
41
41
  setConfig(config: ConfigFile): void;
@@ -100,8 +100,8 @@ class Cache {
100
100
  variables
101
101
  );
102
102
  }
103
- list(name, parentID, allLists) {
104
- const handler = this._internal_unstable.lists.get(name, parentID, allLists);
103
+ list(name, parentID, allLists, skipMatches) {
104
+ const handler = this._internal_unstable.lists.get(name, parentID, allLists, skipMatches);
105
105
  if (!handler) {
106
106
  throw new Error(
107
107
  `Cannot find list with name: ${name}${parentID ? " under parent " + parentID : ""}. Is it possible that the query is not mounted?`
@@ -516,6 +516,7 @@ class CacheInternal {
516
516
  });
517
517
  }
518
518
  }
519
+ const processedOperations = /* @__PURE__ */ new Set();
519
520
  for (const operation of operations || []) {
520
521
  let parentID;
521
522
  if (operation.parentID) {
@@ -535,7 +536,12 @@ class CacheInternal {
535
536
  const targets = Array.isArray(value) ? value : [value];
536
537
  for (const target of targets) {
537
538
  if (operation.action === "insert" && target instanceof Object && fieldSelection && operation.list) {
538
- this.cache.list(operation.list, parentID, operation.target === "all").when(operation.when).addToList(
539
+ this.cache.list(
540
+ operation.list,
541
+ parentID,
542
+ operation.target === "all",
543
+ processedOperations
544
+ ).when(operation.when).addToList(
539
545
  fieldSelection,
540
546
  target,
541
547
  variables,
@@ -543,7 +549,12 @@ class CacheInternal {
543
549
  layer
544
550
  );
545
551
  } else if (operation.action === "toggle" && target instanceof Object && fieldSelection && operation.list) {
546
- this.cache.list(operation.list, parentID, operation.target === "all").when(operation.when).toggleElement({
552
+ this.cache.list(
553
+ operation.list,
554
+ parentID,
555
+ operation.target === "all",
556
+ processedOperations
557
+ ).when(operation.when).toggleElement({
547
558
  selection: fieldSelection,
548
559
  data: target,
549
560
  variables,
@@ -551,7 +562,12 @@ class CacheInternal {
551
562
  layer
552
563
  });
553
564
  } else if (operation.action === "remove" && target instanceof Object && fieldSelection && operation.list) {
554
- this.cache.list(operation.list, parentID, operation.target === "all").when(operation.when).remove(target, variables, layer);
565
+ this.cache.list(
566
+ operation.list,
567
+ parentID,
568
+ operation.target === "all",
569
+ processedOperations
570
+ ).when(operation.when).remove(target, variables, layer);
555
571
  } else if (operation.action === "delete" && operation.type && target) {
556
572
  const targetID = this.id(operation.type, target);
557
573
  if (!targetID) {
@@ -563,6 +579,16 @@ class CacheInternal {
563
579
  this.cache.delete(targetID, layer);
564
580
  }
565
581
  }
582
+ if (operation.list) {
583
+ const matchingLists = this.cache.list(
584
+ operation.list,
585
+ parentID,
586
+ operation.target === "all"
587
+ );
588
+ for (const list of matchingLists.lists) {
589
+ processedOperations.add(list.fieldRef);
590
+ }
591
+ }
566
592
  }
567
593
  }
568
594
  return toNotify;
@@ -7,7 +7,8 @@ export declare class ListManager {
7
7
  constructor(cache: Cache, rootID: string);
8
8
  lists: Map<string, Map<string, ListCollection>>;
9
9
  private listsByField;
10
- get(listName: string, id?: string, allLists?: boolean): ListCollection | null | undefined;
10
+ get(listName: string, id?: string, allLists?: boolean, skipMatches?: Set<string>): ListCollection | null;
11
+ getLists(listName: string, id?: string, allLists?: boolean): ListCollection | null | undefined;
11
12
  remove(listName: string, id: string): void;
12
13
  add(list: {
13
14
  name: string;
@@ -41,6 +42,7 @@ export declare class List {
41
42
  constructor({ name, recordID, recordType, key, listType, selection, when, filters, connection, manager, abstract, }: Parameters<ListManager['add']>[0] & {
42
43
  manager: ListManager;
43
44
  });
45
+ get fieldRef(): string;
44
46
  when(when?: ListWhen): ListCollection;
45
47
  append({ selection, data, variables, layer, }: {
46
48
  selection: SubscriptionSelection;
@@ -34,7 +34,18 @@ class ListManager {
34
34
  }
35
35
  lists = /* @__PURE__ */ new Map();
36
36
  listsByField = /* @__PURE__ */ new Map();
37
- get(listName, id, allLists) {
37
+ get(listName, id, allLists, skipMatches) {
38
+ const lists = this.getLists(listName, id, allLists);
39
+ if (!lists) {
40
+ return null;
41
+ }
42
+ if (skipMatches) {
43
+ return new ListCollection(lists.lists.filter((list) => !skipMatches.has(list.fieldRef)));
44
+ } else {
45
+ return lists;
46
+ }
47
+ }
48
+ getLists(listName, id, allLists) {
38
49
  const matches = this.lists.get(listName);
39
50
  if (!matches || matches.size === 0) {
40
51
  return null;
@@ -156,6 +167,9 @@ class List {
156
167
  this.manager = manager;
157
168
  this.abstract = abstract;
158
169
  }
170
+ get fieldRef() {
171
+ return `${this.recordID}.${this.key}`;
172
+ }
159
173
  when(when) {
160
174
  return this.manager.lists.get(this.name).get(this.recordID).when(when);
161
175
  }
@@ -91,7 +91,7 @@ const defaultFetch = (url, params) => {
91
91
  ...params?.headers
92
92
  }
93
93
  });
94
- if (!result.ok && result.headers.get("content-type") !== "application/json" && result.headers.get("content-type") !== "application/graphql+json") {
94
+ if (!result.ok && !result.headers.get("content-type")?.startsWith("application/json") && !result.headers.get("content-type")?.startsWith("application/graphql+json")) {
95
95
  throw new Error(
96
96
  `Failed to fetch: server returned invalid response with error ${result.status}: ${result.statusText}`
97
97
  );
@@ -141,7 +141,7 @@ function exec(match, params) {
141
141
  if (param.rest)
142
142
  result[param.name] = "";
143
143
  } else {
144
- result[param.name] = value;
144
+ result[param.name] = decodeURIComponent(value);
145
145
  }
146
146
  }
147
147
  if (buffered)
@@ -21,6 +21,6 @@ export type RouterPageManifest<_ComponentType> = {
21
21
  }>;
22
22
  }>;
23
23
  component: () => Promise<{
24
- default: (props: any) => _ComponentType;
24
+ default: _ComponentType;
25
25
  }>;
26
26
  };
@@ -35,7 +35,7 @@ export declare class Cache {
35
35
  };
36
36
  subscribe(spec: SubscriptionSpec, variables?: {}): void;
37
37
  unsubscribe(spec: SubscriptionSpec, variables?: {}): void;
38
- list(name: string, parentID?: string, allLists?: boolean): ListCollection;
38
+ list(name: string, parentID?: string, allLists?: boolean, skipMatches?: Set<string>): ListCollection;
39
39
  registerKeyMap(source: string, mapped: string): void;
40
40
  delete(id: string, layer?: Layer): void;
41
41
  setConfig(config: ConfigFile): void;
@@ -73,8 +73,8 @@ class Cache {
73
73
  variables
74
74
  );
75
75
  }
76
- list(name, parentID, allLists) {
77
- const handler = this._internal_unstable.lists.get(name, parentID, allLists);
76
+ list(name, parentID, allLists, skipMatches) {
77
+ const handler = this._internal_unstable.lists.get(name, parentID, allLists, skipMatches);
78
78
  if (!handler) {
79
79
  throw new Error(
80
80
  `Cannot find list with name: ${name}${parentID ? " under parent " + parentID : ""}. Is it possible that the query is not mounted?`
@@ -489,6 +489,7 @@ class CacheInternal {
489
489
  });
490
490
  }
491
491
  }
492
+ const processedOperations = /* @__PURE__ */ new Set();
492
493
  for (const operation of operations || []) {
493
494
  let parentID;
494
495
  if (operation.parentID) {
@@ -508,7 +509,12 @@ class CacheInternal {
508
509
  const targets = Array.isArray(value) ? value : [value];
509
510
  for (const target of targets) {
510
511
  if (operation.action === "insert" && target instanceof Object && fieldSelection && operation.list) {
511
- this.cache.list(operation.list, parentID, operation.target === "all").when(operation.when).addToList(
512
+ this.cache.list(
513
+ operation.list,
514
+ parentID,
515
+ operation.target === "all",
516
+ processedOperations
517
+ ).when(operation.when).addToList(
512
518
  fieldSelection,
513
519
  target,
514
520
  variables,
@@ -516,7 +522,12 @@ class CacheInternal {
516
522
  layer
517
523
  );
518
524
  } else if (operation.action === "toggle" && target instanceof Object && fieldSelection && operation.list) {
519
- this.cache.list(operation.list, parentID, operation.target === "all").when(operation.when).toggleElement({
525
+ this.cache.list(
526
+ operation.list,
527
+ parentID,
528
+ operation.target === "all",
529
+ processedOperations
530
+ ).when(operation.when).toggleElement({
520
531
  selection: fieldSelection,
521
532
  data: target,
522
533
  variables,
@@ -524,7 +535,12 @@ class CacheInternal {
524
535
  layer
525
536
  });
526
537
  } else if (operation.action === "remove" && target instanceof Object && fieldSelection && operation.list) {
527
- this.cache.list(operation.list, parentID, operation.target === "all").when(operation.when).remove(target, variables, layer);
538
+ this.cache.list(
539
+ operation.list,
540
+ parentID,
541
+ operation.target === "all",
542
+ processedOperations
543
+ ).when(operation.when).remove(target, variables, layer);
528
544
  } else if (operation.action === "delete" && operation.type && target) {
529
545
  const targetID = this.id(operation.type, target);
530
546
  if (!targetID) {
@@ -536,6 +552,16 @@ class CacheInternal {
536
552
  this.cache.delete(targetID, layer);
537
553
  }
538
554
  }
555
+ if (operation.list) {
556
+ const matchingLists = this.cache.list(
557
+ operation.list,
558
+ parentID,
559
+ operation.target === "all"
560
+ );
561
+ for (const list of matchingLists.lists) {
562
+ processedOperations.add(list.fieldRef);
563
+ }
564
+ }
539
565
  }
540
566
  }
541
567
  return toNotify;
@@ -7,7 +7,8 @@ export declare class ListManager {
7
7
  constructor(cache: Cache, rootID: string);
8
8
  lists: Map<string, Map<string, ListCollection>>;
9
9
  private listsByField;
10
- get(listName: string, id?: string, allLists?: boolean): ListCollection | null | undefined;
10
+ get(listName: string, id?: string, allLists?: boolean, skipMatches?: Set<string>): ListCollection | null;
11
+ getLists(listName: string, id?: string, allLists?: boolean): ListCollection | null | undefined;
11
12
  remove(listName: string, id: string): void;
12
13
  add(list: {
13
14
  name: string;
@@ -41,6 +42,7 @@ export declare class List {
41
42
  constructor({ name, recordID, recordType, key, listType, selection, when, filters, connection, manager, abstract, }: Parameters<ListManager['add']>[0] & {
42
43
  manager: ListManager;
43
44
  });
45
+ get fieldRef(): string;
44
46
  when(when?: ListWhen): ListCollection;
45
47
  append({ selection, data, variables, layer, }: {
46
48
  selection: SubscriptionSelection;
@@ -9,7 +9,18 @@ class ListManager {
9
9
  }
10
10
  lists = /* @__PURE__ */ new Map();
11
11
  listsByField = /* @__PURE__ */ new Map();
12
- get(listName, id, allLists) {
12
+ get(listName, id, allLists, skipMatches) {
13
+ const lists = this.getLists(listName, id, allLists);
14
+ if (!lists) {
15
+ return null;
16
+ }
17
+ if (skipMatches) {
18
+ return new ListCollection(lists.lists.filter((list) => !skipMatches.has(list.fieldRef)));
19
+ } else {
20
+ return lists;
21
+ }
22
+ }
23
+ getLists(listName, id, allLists) {
13
24
  const matches = this.lists.get(listName);
14
25
  if (!matches || matches.size === 0) {
15
26
  return null;
@@ -131,6 +142,9 @@ class List {
131
142
  this.manager = manager;
132
143
  this.abstract = abstract;
133
144
  }
145
+ get fieldRef() {
146
+ return `${this.recordID}.${this.key}`;
147
+ }
134
148
  when(when) {
135
149
  return this.manager.lists.get(this.name).get(this.recordID).when(when);
136
150
  }
@@ -66,7 +66,7 @@ const defaultFetch = (url, params) => {
66
66
  ...params?.headers
67
67
  }
68
68
  });
69
- if (!result.ok && result.headers.get("content-type") !== "application/json" && result.headers.get("content-type") !== "application/graphql+json") {
69
+ if (!result.ok && !result.headers.get("content-type")?.startsWith("application/json") && !result.headers.get("content-type")?.startsWith("application/graphql+json")) {
70
70
  throw new Error(
71
71
  `Failed to fetch: server returned invalid response with error ${result.status}: ${result.statusText}`
72
72
  );
@@ -115,7 +115,7 @@ function exec(match, params) {
115
115
  if (param.rest)
116
116
  result[param.name] = "";
117
117
  } else {
118
- result[param.name] = value;
118
+ result[param.name] = decodeURIComponent(value);
119
119
  }
120
120
  }
121
121
  if (buffered)
@@ -21,6 +21,6 @@ export type RouterPageManifest<_ComponentType> = {
21
21
  }>;
22
22
  }>;
23
23
  component: () => Promise<{
24
- default: (props: any) => _ComponentType;
24
+ default: _ComponentType;
25
25
  }>;
26
26
  };