houdini 1.4.0 → 1.4.1
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/build/cmd-cjs/index.js +88 -8
- package/build/cmd-esm/index.js +88 -8
- package/build/codegen-cjs/index.js +86 -6
- package/build/codegen-esm/index.js +86 -6
- package/build/lib-cjs/index.js +48 -8
- package/build/lib-esm/index.js +48 -8
- package/build/runtime/cache/cache.d.ts +1 -1
- package/build/runtime/cache/lists.d.ts +3 -1
- package/build/runtime-cjs/cache/cache.d.ts +1 -1
- package/build/runtime-cjs/cache/cache.js +31 -5
- package/build/runtime-cjs/cache/lists.d.ts +3 -1
- package/build/runtime-cjs/cache/lists.js +15 -1
- package/build/runtime-cjs/client/plugins/fetch.js +1 -1
- package/build/runtime-cjs/router/match.js +1 -1
- package/build/runtime-esm/cache/cache.d.ts +1 -1
- package/build/runtime-esm/cache/cache.js +31 -5
- package/build/runtime-esm/cache/lists.d.ts +3 -1
- package/build/runtime-esm/cache/lists.js +15 -1
- package/build/runtime-esm/client/plugins/fetch.js +1 -1
- package/build/runtime-esm/router/match.js +1 -1
- package/build/test-cjs/index.js +86 -6
- package/build/test-esm/index.js +86 -6
- package/build/vite/ast.d.ts +8 -2
- package/build/vite-cjs/index.js +331 -246
- package/build/vite-esm/index.js +331 -246
- package/package.json +1 -1
package/build/lib-cjs/index.js
CHANGED
|
@@ -63985,7 +63985,18 @@ var ListManager = class {
|
|
|
63985
63985
|
}
|
|
63986
63986
|
lists = /* @__PURE__ */ new Map();
|
|
63987
63987
|
listsByField = /* @__PURE__ */ new Map();
|
|
63988
|
-
get(listName, id, allLists) {
|
|
63988
|
+
get(listName, id, allLists, skipMatches) {
|
|
63989
|
+
const lists = this.getLists(listName, id, allLists);
|
|
63990
|
+
if (!lists) {
|
|
63991
|
+
return null;
|
|
63992
|
+
}
|
|
63993
|
+
if (skipMatches) {
|
|
63994
|
+
return new ListCollection(lists.lists.filter((list) => !skipMatches.has(list.fieldRef)));
|
|
63995
|
+
} else {
|
|
63996
|
+
return lists;
|
|
63997
|
+
}
|
|
63998
|
+
}
|
|
63999
|
+
getLists(listName, id, allLists) {
|
|
63989
64000
|
const matches = this.lists.get(listName);
|
|
63990
64001
|
if (!matches || matches.size === 0) {
|
|
63991
64002
|
return null;
|
|
@@ -64107,6 +64118,9 @@ var List = class {
|
|
|
64107
64118
|
this.manager = manager;
|
|
64108
64119
|
this.abstract = abstract;
|
|
64109
64120
|
}
|
|
64121
|
+
get fieldRef() {
|
|
64122
|
+
return `${this.recordID}.${this.key}`;
|
|
64123
|
+
}
|
|
64110
64124
|
when(when) {
|
|
64111
64125
|
return this.manager.lists.get(this.name).get(this.recordID).when(when);
|
|
64112
64126
|
}
|
|
@@ -65259,8 +65273,8 @@ var Cache = class {
|
|
|
65259
65273
|
variables
|
|
65260
65274
|
);
|
|
65261
65275
|
}
|
|
65262
|
-
list(name, parentID, allLists) {
|
|
65263
|
-
const handler = this._internal_unstable.lists.get(name, parentID, allLists);
|
|
65276
|
+
list(name, parentID, allLists, skipMatches) {
|
|
65277
|
+
const handler = this._internal_unstable.lists.get(name, parentID, allLists, skipMatches);
|
|
65264
65278
|
if (!handler) {
|
|
65265
65279
|
throw new Error(
|
|
65266
65280
|
`Cannot find list with name: ${name}${parentID ? " under parent " + parentID : ""}. Is it possible that the query is not mounted?`
|
|
@@ -65675,6 +65689,7 @@ var CacheInternal = class {
|
|
|
65675
65689
|
});
|
|
65676
65690
|
}
|
|
65677
65691
|
}
|
|
65692
|
+
const processedOperations = /* @__PURE__ */ new Set();
|
|
65678
65693
|
for (const operation of operations || []) {
|
|
65679
65694
|
let parentID;
|
|
65680
65695
|
if (operation.parentID) {
|
|
@@ -65694,7 +65709,12 @@ var CacheInternal = class {
|
|
|
65694
65709
|
const targets = Array.isArray(value) ? value : [value];
|
|
65695
65710
|
for (const target of targets) {
|
|
65696
65711
|
if (operation.action === "insert" && target instanceof Object && fieldSelection && operation.list) {
|
|
65697
|
-
this.cache.list(
|
|
65712
|
+
this.cache.list(
|
|
65713
|
+
operation.list,
|
|
65714
|
+
parentID,
|
|
65715
|
+
operation.target === "all",
|
|
65716
|
+
processedOperations
|
|
65717
|
+
).when(operation.when).addToList(
|
|
65698
65718
|
fieldSelection,
|
|
65699
65719
|
target,
|
|
65700
65720
|
variables,
|
|
@@ -65702,7 +65722,12 @@ var CacheInternal = class {
|
|
|
65702
65722
|
layer
|
|
65703
65723
|
);
|
|
65704
65724
|
} else if (operation.action === "toggle" && target instanceof Object && fieldSelection && operation.list) {
|
|
65705
|
-
this.cache.list(
|
|
65725
|
+
this.cache.list(
|
|
65726
|
+
operation.list,
|
|
65727
|
+
parentID,
|
|
65728
|
+
operation.target === "all",
|
|
65729
|
+
processedOperations
|
|
65730
|
+
).when(operation.when).toggleElement({
|
|
65706
65731
|
selection: fieldSelection,
|
|
65707
65732
|
data: target,
|
|
65708
65733
|
variables,
|
|
@@ -65710,7 +65735,12 @@ var CacheInternal = class {
|
|
|
65710
65735
|
layer
|
|
65711
65736
|
});
|
|
65712
65737
|
} else if (operation.action === "remove" && target instanceof Object && fieldSelection && operation.list) {
|
|
65713
|
-
this.cache.list(
|
|
65738
|
+
this.cache.list(
|
|
65739
|
+
operation.list,
|
|
65740
|
+
parentID,
|
|
65741
|
+
operation.target === "all",
|
|
65742
|
+
processedOperations
|
|
65743
|
+
).when(operation.when).remove(target, variables, layer);
|
|
65714
65744
|
} else if (operation.action === "delete" && operation.type && target) {
|
|
65715
65745
|
const targetID = this.id(operation.type, target);
|
|
65716
65746
|
if (!targetID) {
|
|
@@ -65722,6 +65752,16 @@ var CacheInternal = class {
|
|
|
65722
65752
|
this.cache.delete(targetID, layer);
|
|
65723
65753
|
}
|
|
65724
65754
|
}
|
|
65755
|
+
if (operation.list) {
|
|
65756
|
+
const matchingLists = this.cache.list(
|
|
65757
|
+
operation.list,
|
|
65758
|
+
parentID,
|
|
65759
|
+
operation.target === "all"
|
|
65760
|
+
);
|
|
65761
|
+
for (const list of matchingLists.lists) {
|
|
65762
|
+
processedOperations.add(list.fieldRef);
|
|
65763
|
+
}
|
|
65764
|
+
}
|
|
65725
65765
|
}
|
|
65726
65766
|
}
|
|
65727
65767
|
return toNotify;
|
|
@@ -66238,7 +66278,7 @@ var defaultFetch = (url, params) => {
|
|
|
66238
66278
|
...params?.headers
|
|
66239
66279
|
}
|
|
66240
66280
|
});
|
|
66241
|
-
if (!result.ok && result.headers.get("content-type")
|
|
66281
|
+
if (!result.ok && !result.headers.get("content-type")?.startsWith("application/json") && !result.headers.get("content-type")?.startsWith("application/graphql+json")) {
|
|
66242
66282
|
throw new Error(
|
|
66243
66283
|
`Failed to fetch: server returned invalid response with error ${result.status}: ${result.statusText}`
|
|
66244
66284
|
);
|
|
@@ -69324,7 +69364,7 @@ function exec(match, params) {
|
|
|
69324
69364
|
if (param.rest)
|
|
69325
69365
|
result[param.name] = "";
|
|
69326
69366
|
} else {
|
|
69327
|
-
result[param.name] = value;
|
|
69367
|
+
result[param.name] = decodeURIComponent(value);
|
|
69328
69368
|
}
|
|
69329
69369
|
}
|
|
69330
69370
|
if (buffered)
|
package/build/lib-esm/index.js
CHANGED
|
@@ -63899,7 +63899,18 @@ var ListManager = class {
|
|
|
63899
63899
|
}
|
|
63900
63900
|
lists = /* @__PURE__ */ new Map();
|
|
63901
63901
|
listsByField = /* @__PURE__ */ new Map();
|
|
63902
|
-
get(listName, id, allLists) {
|
|
63902
|
+
get(listName, id, allLists, skipMatches) {
|
|
63903
|
+
const lists = this.getLists(listName, id, allLists);
|
|
63904
|
+
if (!lists) {
|
|
63905
|
+
return null;
|
|
63906
|
+
}
|
|
63907
|
+
if (skipMatches) {
|
|
63908
|
+
return new ListCollection(lists.lists.filter((list) => !skipMatches.has(list.fieldRef)));
|
|
63909
|
+
} else {
|
|
63910
|
+
return lists;
|
|
63911
|
+
}
|
|
63912
|
+
}
|
|
63913
|
+
getLists(listName, id, allLists) {
|
|
63903
63914
|
const matches = this.lists.get(listName);
|
|
63904
63915
|
if (!matches || matches.size === 0) {
|
|
63905
63916
|
return null;
|
|
@@ -64021,6 +64032,9 @@ var List = class {
|
|
|
64021
64032
|
this.manager = manager;
|
|
64022
64033
|
this.abstract = abstract;
|
|
64023
64034
|
}
|
|
64035
|
+
get fieldRef() {
|
|
64036
|
+
return `${this.recordID}.${this.key}`;
|
|
64037
|
+
}
|
|
64024
64038
|
when(when) {
|
|
64025
64039
|
return this.manager.lists.get(this.name).get(this.recordID).when(when);
|
|
64026
64040
|
}
|
|
@@ -65173,8 +65187,8 @@ var Cache = class {
|
|
|
65173
65187
|
variables
|
|
65174
65188
|
);
|
|
65175
65189
|
}
|
|
65176
|
-
list(name, parentID, allLists) {
|
|
65177
|
-
const handler = this._internal_unstable.lists.get(name, parentID, allLists);
|
|
65190
|
+
list(name, parentID, allLists, skipMatches) {
|
|
65191
|
+
const handler = this._internal_unstable.lists.get(name, parentID, allLists, skipMatches);
|
|
65178
65192
|
if (!handler) {
|
|
65179
65193
|
throw new Error(
|
|
65180
65194
|
`Cannot find list with name: ${name}${parentID ? " under parent " + parentID : ""}. Is it possible that the query is not mounted?`
|
|
@@ -65589,6 +65603,7 @@ var CacheInternal = class {
|
|
|
65589
65603
|
});
|
|
65590
65604
|
}
|
|
65591
65605
|
}
|
|
65606
|
+
const processedOperations = /* @__PURE__ */ new Set();
|
|
65592
65607
|
for (const operation of operations || []) {
|
|
65593
65608
|
let parentID;
|
|
65594
65609
|
if (operation.parentID) {
|
|
@@ -65608,7 +65623,12 @@ var CacheInternal = class {
|
|
|
65608
65623
|
const targets = Array.isArray(value) ? value : [value];
|
|
65609
65624
|
for (const target of targets) {
|
|
65610
65625
|
if (operation.action === "insert" && target instanceof Object && fieldSelection && operation.list) {
|
|
65611
|
-
this.cache.list(
|
|
65626
|
+
this.cache.list(
|
|
65627
|
+
operation.list,
|
|
65628
|
+
parentID,
|
|
65629
|
+
operation.target === "all",
|
|
65630
|
+
processedOperations
|
|
65631
|
+
).when(operation.when).addToList(
|
|
65612
65632
|
fieldSelection,
|
|
65613
65633
|
target,
|
|
65614
65634
|
variables,
|
|
@@ -65616,7 +65636,12 @@ var CacheInternal = class {
|
|
|
65616
65636
|
layer
|
|
65617
65637
|
);
|
|
65618
65638
|
} else if (operation.action === "toggle" && target instanceof Object && fieldSelection && operation.list) {
|
|
65619
|
-
this.cache.list(
|
|
65639
|
+
this.cache.list(
|
|
65640
|
+
operation.list,
|
|
65641
|
+
parentID,
|
|
65642
|
+
operation.target === "all",
|
|
65643
|
+
processedOperations
|
|
65644
|
+
).when(operation.when).toggleElement({
|
|
65620
65645
|
selection: fieldSelection,
|
|
65621
65646
|
data: target,
|
|
65622
65647
|
variables,
|
|
@@ -65624,7 +65649,12 @@ var CacheInternal = class {
|
|
|
65624
65649
|
layer
|
|
65625
65650
|
});
|
|
65626
65651
|
} else if (operation.action === "remove" && target instanceof Object && fieldSelection && operation.list) {
|
|
65627
|
-
this.cache.list(
|
|
65652
|
+
this.cache.list(
|
|
65653
|
+
operation.list,
|
|
65654
|
+
parentID,
|
|
65655
|
+
operation.target === "all",
|
|
65656
|
+
processedOperations
|
|
65657
|
+
).when(operation.when).remove(target, variables, layer);
|
|
65628
65658
|
} else if (operation.action === "delete" && operation.type && target) {
|
|
65629
65659
|
const targetID = this.id(operation.type, target);
|
|
65630
65660
|
if (!targetID) {
|
|
@@ -65636,6 +65666,16 @@ var CacheInternal = class {
|
|
|
65636
65666
|
this.cache.delete(targetID, layer);
|
|
65637
65667
|
}
|
|
65638
65668
|
}
|
|
65669
|
+
if (operation.list) {
|
|
65670
|
+
const matchingLists = this.cache.list(
|
|
65671
|
+
operation.list,
|
|
65672
|
+
parentID,
|
|
65673
|
+
operation.target === "all"
|
|
65674
|
+
);
|
|
65675
|
+
for (const list of matchingLists.lists) {
|
|
65676
|
+
processedOperations.add(list.fieldRef);
|
|
65677
|
+
}
|
|
65678
|
+
}
|
|
65639
65679
|
}
|
|
65640
65680
|
}
|
|
65641
65681
|
return toNotify;
|
|
@@ -66152,7 +66192,7 @@ var defaultFetch = (url, params) => {
|
|
|
66152
66192
|
...params?.headers
|
|
66153
66193
|
}
|
|
66154
66194
|
});
|
|
66155
|
-
if (!result.ok && result.headers.get("content-type")
|
|
66195
|
+
if (!result.ok && !result.headers.get("content-type")?.startsWith("application/json") && !result.headers.get("content-type")?.startsWith("application/graphql+json")) {
|
|
66156
66196
|
throw new Error(
|
|
66157
66197
|
`Failed to fetch: server returned invalid response with error ${result.status}: ${result.statusText}`
|
|
66158
66198
|
);
|
|
@@ -69237,7 +69277,7 @@ function exec(match, params) {
|
|
|
69237
69277
|
if (param.rest)
|
|
69238
69278
|
result[param.name] = "";
|
|
69239
69279
|
} else {
|
|
69240
|
-
result[param.name] = value;
|
|
69280
|
+
result[param.name] = decodeURIComponent(value);
|
|
69241
69281
|
}
|
|
69242
69282
|
}
|
|
69243
69283
|
if (buffered)
|
|
@@ -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
|
|
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;
|
|
@@ -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(
|
|
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(
|
|
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(
|
|
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
|
|
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")
|
|
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
|
);
|
|
@@ -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(
|
|
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(
|
|
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(
|
|
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
|
|
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")
|
|
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
|
);
|