houdini 1.0.0-next.9 → 1.0.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/README.md +4 -1
- package/build/cmd-cjs/index.js +2368 -151
- package/build/cmd-esm/index.js +2368 -151
- package/build/codegen/generators/runtime/runtimeConfig.d.ts +7 -0
- package/build/codegen/transforms/fragmentVariables.d.ts +2 -1
- package/build/codegen/utils/flattenSelections.d.ts +1 -1
- package/build/codegen/validators/typeCheck.d.ts +1 -0
- package/build/codegen-cjs/index.js +2962 -719
- package/build/codegen-esm/index.js +2962 -719
- package/build/lib/config.d.ts +4 -6
- package/build/lib/types.d.ts +18 -15
- package/build/lib-cjs/index.js +3159 -171
- package/build/lib-esm/index.js +3152 -171
- package/build/runtime/cache/storage.d.ts +18 -15
- package/build/runtime/client/documentStore.d.ts +15 -13
- package/build/runtime/client/utils/documentPlugins.d.ts +2 -2
- package/build/runtime/imports/pluginConfig.d.ts +3 -0
- package/build/runtime/lib/config.d.ts +2 -2
- package/build/runtime/lib/scalars.d.ts +1 -1
- package/build/runtime/lib/types.d.ts +41 -42
- package/build/runtime-cjs/cache/storage.d.ts +18 -15
- package/build/runtime-cjs/cache/storage.js +9 -11
- package/build/runtime-cjs/client/documentStore.d.ts +15 -13
- package/build/runtime-cjs/client/documentStore.js +10 -7
- package/build/runtime-cjs/client/index.js +3 -0
- package/build/runtime-cjs/client/plugins/cache.js +3 -3
- package/build/runtime-cjs/client/plugins/fetch.js +2 -2
- package/build/runtime-cjs/client/plugins/query.js +1 -1
- package/build/runtime-cjs/client/plugins/subscription.js +2 -2
- package/build/runtime-cjs/client/utils/documentPlugins.d.ts +2 -2
- package/build/runtime-cjs/imports/pluginConfig.d.ts +3 -0
- package/build/runtime-cjs/imports/pluginConfig.js +27 -0
- package/build/runtime-cjs/lib/config.d.ts +2 -2
- package/build/runtime-cjs/lib/config.js +11 -1
- package/build/runtime-cjs/lib/scalars.d.ts +1 -1
- package/build/runtime-cjs/lib/scalars.js +13 -2
- package/build/runtime-cjs/lib/types.d.ts +41 -42
- package/build/runtime-cjs/lib/types.js +26 -30
- package/build/runtime-esm/cache/storage.d.ts +18 -15
- package/build/runtime-esm/cache/storage.js +9 -11
- package/build/runtime-esm/client/documentStore.d.ts +15 -13
- package/build/runtime-esm/client/documentStore.js +10 -7
- package/build/runtime-esm/client/index.js +5 -2
- package/build/runtime-esm/client/plugins/cache.js +3 -3
- package/build/runtime-esm/client/plugins/fetch.js +2 -2
- package/build/runtime-esm/client/plugins/query.js +1 -1
- package/build/runtime-esm/client/plugins/subscription.js +2 -2
- package/build/runtime-esm/client/utils/documentPlugins.d.ts +2 -2
- package/build/runtime-esm/imports/pluginConfig.d.ts +3 -0
- package/build/runtime-esm/imports/pluginConfig.js +5 -0
- package/build/runtime-esm/lib/config.d.ts +2 -2
- package/build/runtime-esm/lib/config.js +11 -1
- package/build/runtime-esm/lib/scalars.d.ts +1 -1
- package/build/runtime-esm/lib/scalars.js +13 -2
- package/build/runtime-esm/lib/types.d.ts +41 -42
- package/build/runtime-esm/lib/types.js +26 -30
- package/build/test-cjs/index.js +2346 -128
- package/build/test-esm/index.js +2346 -128
- package/build/vite/houdini.d.ts +2 -0
- package/build/vite-cjs/index.js +2371 -152
- package/build/vite-esm/index.js +2371 -152
- package/package.json +2 -2
package/build/lib-cjs/index.js
CHANGED
|
@@ -16064,7 +16064,7 @@ var require_graceful_fs = __commonJS({
|
|
|
16064
16064
|
gracefulQueue = "___graceful-fs.queue";
|
|
16065
16065
|
previousSymbol = "___graceful-fs.previous";
|
|
16066
16066
|
}
|
|
16067
|
-
function
|
|
16067
|
+
function noop3() {
|
|
16068
16068
|
}
|
|
16069
16069
|
function publishQueue(context, queue2) {
|
|
16070
16070
|
Object.defineProperty(context, gracefulQueue, {
|
|
@@ -16073,7 +16073,7 @@ var require_graceful_fs = __commonJS({
|
|
|
16073
16073
|
}
|
|
16074
16074
|
});
|
|
16075
16075
|
}
|
|
16076
|
-
var debug =
|
|
16076
|
+
var debug = noop3;
|
|
16077
16077
|
if (util.debuglog)
|
|
16078
16078
|
debug = util.debuglog("gfs4");
|
|
16079
16079
|
else if (/\bgfs4\b/i.test(process.env.NODE_DEBUG || ""))
|
|
@@ -20420,8 +20420,8 @@ var require_node = __commonJS({
|
|
|
20420
20420
|
Node2.prototype.isSymlink = function() {
|
|
20421
20421
|
return (this.mode & S_IFMT) === S_IFLNK;
|
|
20422
20422
|
};
|
|
20423
|
-
Node2.prototype.makeSymlink = function(
|
|
20424
|
-
this.symlink =
|
|
20423
|
+
Node2.prototype.makeSymlink = function(steps2) {
|
|
20424
|
+
this.symlink = steps2;
|
|
20425
20425
|
this.setIsSymlink();
|
|
20426
20426
|
};
|
|
20427
20427
|
Node2.prototype.write = function(buf, off, len, pos) {
|
|
@@ -20638,22 +20638,22 @@ var require_node = __commonJS({
|
|
|
20638
20638
|
Link2.prototype.getName = function() {
|
|
20639
20639
|
return this.steps[this.steps.length - 1];
|
|
20640
20640
|
};
|
|
20641
|
-
Link2.prototype.walk = function(
|
|
20641
|
+
Link2.prototype.walk = function(steps2, stop, i2) {
|
|
20642
20642
|
if (stop === void 0) {
|
|
20643
|
-
stop =
|
|
20643
|
+
stop = steps2.length;
|
|
20644
20644
|
}
|
|
20645
20645
|
if (i2 === void 0) {
|
|
20646
20646
|
i2 = 0;
|
|
20647
20647
|
}
|
|
20648
|
-
if (i2 >=
|
|
20648
|
+
if (i2 >= steps2.length)
|
|
20649
20649
|
return this;
|
|
20650
20650
|
if (i2 >= stop)
|
|
20651
20651
|
return this;
|
|
20652
|
-
var step =
|
|
20652
|
+
var step = steps2[i2];
|
|
20653
20653
|
var link = this.getChild(step);
|
|
20654
20654
|
if (!link)
|
|
20655
20655
|
return null;
|
|
20656
|
-
return link.walk(
|
|
20656
|
+
return link.walk(steps2, stop, i2 + 1);
|
|
20657
20657
|
};
|
|
20658
20658
|
Link2.prototype.toJSON = function() {
|
|
20659
20659
|
return {
|
|
@@ -20668,42 +20668,42 @@ var require_node = __commonJS({
|
|
|
20668
20668
|
return Link2;
|
|
20669
20669
|
}(events_1.EventEmitter);
|
|
20670
20670
|
exports.Link = Link;
|
|
20671
|
-
var
|
|
20672
|
-
function
|
|
20671
|
+
var File4 = function() {
|
|
20672
|
+
function File5(link, node, flags, fd) {
|
|
20673
20673
|
this.position = 0;
|
|
20674
20674
|
this.link = link;
|
|
20675
20675
|
this.node = node;
|
|
20676
20676
|
this.flags = flags;
|
|
20677
20677
|
this.fd = fd;
|
|
20678
20678
|
}
|
|
20679
|
-
|
|
20679
|
+
File5.prototype.getString = function(encoding) {
|
|
20680
20680
|
if (encoding === void 0) {
|
|
20681
20681
|
encoding = "utf8";
|
|
20682
20682
|
}
|
|
20683
20683
|
return this.node.getString();
|
|
20684
20684
|
};
|
|
20685
|
-
|
|
20685
|
+
File5.prototype.setString = function(str) {
|
|
20686
20686
|
this.node.setString(str);
|
|
20687
20687
|
};
|
|
20688
|
-
|
|
20688
|
+
File5.prototype.getBuffer = function() {
|
|
20689
20689
|
return this.node.getBuffer();
|
|
20690
20690
|
};
|
|
20691
|
-
|
|
20691
|
+
File5.prototype.setBuffer = function(buf) {
|
|
20692
20692
|
this.node.setBuffer(buf);
|
|
20693
20693
|
};
|
|
20694
|
-
|
|
20694
|
+
File5.prototype.getSize = function() {
|
|
20695
20695
|
return this.node.getSize();
|
|
20696
20696
|
};
|
|
20697
|
-
|
|
20697
|
+
File5.prototype.truncate = function(len) {
|
|
20698
20698
|
this.node.truncate(len);
|
|
20699
20699
|
};
|
|
20700
|
-
|
|
20700
|
+
File5.prototype.seekTo = function(position) {
|
|
20701
20701
|
this.position = position;
|
|
20702
20702
|
};
|
|
20703
|
-
|
|
20703
|
+
File5.prototype.stats = function() {
|
|
20704
20704
|
return Stats_1.default.build(this.node);
|
|
20705
20705
|
};
|
|
20706
|
-
|
|
20706
|
+
File5.prototype.write = function(buf, offset, length, position) {
|
|
20707
20707
|
if (offset === void 0) {
|
|
20708
20708
|
offset = 0;
|
|
20709
20709
|
}
|
|
@@ -20718,7 +20718,7 @@ var require_node = __commonJS({
|
|
|
20718
20718
|
this.position = position + bytes;
|
|
20719
20719
|
return bytes;
|
|
20720
20720
|
};
|
|
20721
|
-
|
|
20721
|
+
File5.prototype.read = function(buf, offset, length, position) {
|
|
20722
20722
|
if (offset === void 0) {
|
|
20723
20723
|
offset = 0;
|
|
20724
20724
|
}
|
|
@@ -20731,15 +20731,15 @@ var require_node = __commonJS({
|
|
|
20731
20731
|
this.position = position + bytes;
|
|
20732
20732
|
return bytes;
|
|
20733
20733
|
};
|
|
20734
|
-
|
|
20734
|
+
File5.prototype.chmod = function(perm) {
|
|
20735
20735
|
this.node.chmod(perm);
|
|
20736
20736
|
};
|
|
20737
|
-
|
|
20737
|
+
File5.prototype.chown = function(uid, gid) {
|
|
20738
20738
|
this.node.chown(uid, gid);
|
|
20739
20739
|
};
|
|
20740
|
-
return
|
|
20740
|
+
return File5;
|
|
20741
20741
|
}();
|
|
20742
|
-
exports.File =
|
|
20742
|
+
exports.File = File4;
|
|
20743
20743
|
}
|
|
20744
20744
|
});
|
|
20745
20745
|
|
|
@@ -21425,20 +21425,20 @@ var require_volume = __commonJS({
|
|
|
21425
21425
|
}
|
|
21426
21426
|
function flattenJSON(nestedJSON) {
|
|
21427
21427
|
var flatJSON = {};
|
|
21428
|
-
function
|
|
21428
|
+
function flatten2(pathPrefix, node) {
|
|
21429
21429
|
for (var path2 in node) {
|
|
21430
21430
|
var contentOrNode = node[path2];
|
|
21431
21431
|
var joinedPath = join3(pathPrefix, path2);
|
|
21432
21432
|
if (typeof contentOrNode === "string") {
|
|
21433
21433
|
flatJSON[joinedPath] = contentOrNode;
|
|
21434
21434
|
} else if (typeof contentOrNode === "object" && contentOrNode !== null && Object.keys(contentOrNode).length > 0) {
|
|
21435
|
-
|
|
21435
|
+
flatten2(joinedPath, contentOrNode);
|
|
21436
21436
|
} else {
|
|
21437
21437
|
flatJSON[joinedPath] = null;
|
|
21438
21438
|
}
|
|
21439
21439
|
}
|
|
21440
21440
|
}
|
|
21441
|
-
|
|
21441
|
+
flatten2("", nestedJSON);
|
|
21442
21442
|
return flatJSON;
|
|
21443
21443
|
}
|
|
21444
21444
|
var Volume = function() {
|
|
@@ -21576,28 +21576,28 @@ var require_volume = __commonJS({
|
|
|
21576
21576
|
else
|
|
21577
21577
|
return this.genRndStr();
|
|
21578
21578
|
};
|
|
21579
|
-
Volume2.prototype.getLink = function(
|
|
21580
|
-
return this.root.walk(
|
|
21579
|
+
Volume2.prototype.getLink = function(steps2) {
|
|
21580
|
+
return this.root.walk(steps2);
|
|
21581
21581
|
};
|
|
21582
21582
|
Volume2.prototype.getLinkOrThrow = function(filename, funcName) {
|
|
21583
|
-
var
|
|
21584
|
-
var link = this.getLink(
|
|
21583
|
+
var steps2 = filenameToSteps(filename);
|
|
21584
|
+
var link = this.getLink(steps2);
|
|
21585
21585
|
if (!link)
|
|
21586
21586
|
throw createError(ENOENT, funcName, filename);
|
|
21587
21587
|
return link;
|
|
21588
21588
|
};
|
|
21589
21589
|
Volume2.prototype.getResolvedLink = function(filenameOrSteps) {
|
|
21590
|
-
var
|
|
21590
|
+
var steps2 = typeof filenameOrSteps === "string" ? filenameToSteps(filenameOrSteps) : filenameOrSteps;
|
|
21591
21591
|
var link = this.root;
|
|
21592
21592
|
var i2 = 0;
|
|
21593
|
-
while (i2 <
|
|
21594
|
-
var step =
|
|
21593
|
+
while (i2 < steps2.length) {
|
|
21594
|
+
var step = steps2[i2];
|
|
21595
21595
|
link = link.getChild(step);
|
|
21596
21596
|
if (!link)
|
|
21597
21597
|
return null;
|
|
21598
21598
|
var node = link.getNode();
|
|
21599
21599
|
if (node.isSymlink()) {
|
|
21600
|
-
|
|
21600
|
+
steps2 = node.symlink.concat(steps2.slice(i2 + 1));
|
|
21601
21601
|
link = this.root;
|
|
21602
21602
|
i2 = 0;
|
|
21603
21603
|
continue;
|
|
@@ -21621,16 +21621,16 @@ var require_volume = __commonJS({
|
|
|
21621
21621
|
throw createError(ENOTDIR, funcName, filename);
|
|
21622
21622
|
return link;
|
|
21623
21623
|
};
|
|
21624
|
-
Volume2.prototype.getLinkParent = function(
|
|
21625
|
-
return this.root.walk(
|
|
21624
|
+
Volume2.prototype.getLinkParent = function(steps2) {
|
|
21625
|
+
return this.root.walk(steps2, steps2.length - 1);
|
|
21626
21626
|
};
|
|
21627
21627
|
Volume2.prototype.getLinkParentAsDirOrThrow = function(filenameOrSteps, funcName) {
|
|
21628
|
-
var
|
|
21629
|
-
var link = this.getLinkParent(
|
|
21628
|
+
var steps2 = filenameOrSteps instanceof Array ? filenameOrSteps : filenameToSteps(filenameOrSteps);
|
|
21629
|
+
var link = this.getLinkParent(steps2);
|
|
21630
21630
|
if (!link)
|
|
21631
|
-
throw createError(ENOENT, funcName, sep2 +
|
|
21631
|
+
throw createError(ENOENT, funcName, sep2 + steps2.join(sep2));
|
|
21632
21632
|
if (!link.getNode().isDirectory())
|
|
21633
|
-
throw createError(ENOTDIR, funcName, sep2 +
|
|
21633
|
+
throw createError(ENOTDIR, funcName, sep2 + steps2.join(sep2));
|
|
21634
21634
|
return link;
|
|
21635
21635
|
};
|
|
21636
21636
|
Volume2.prototype.getFileByFd = function(fd) {
|
|
@@ -21796,16 +21796,16 @@ var require_volume = __commonJS({
|
|
|
21796
21796
|
if (resolveSymlinks === void 0) {
|
|
21797
21797
|
resolveSymlinks = true;
|
|
21798
21798
|
}
|
|
21799
|
-
var
|
|
21800
|
-
var link = resolveSymlinks ? this.getResolvedLink(
|
|
21799
|
+
var steps2 = filenameToSteps(filename);
|
|
21800
|
+
var link = resolveSymlinks ? this.getResolvedLink(steps2) : this.getLink(steps2);
|
|
21801
21801
|
if (link && flagsNum & O_EXCL)
|
|
21802
21802
|
throw createError(EEXIST, "open", filename);
|
|
21803
21803
|
if (!link && flagsNum & O_CREAT) {
|
|
21804
|
-
var dirLink = this.getResolvedLink(
|
|
21804
|
+
var dirLink = this.getResolvedLink(steps2.slice(0, steps2.length - 1));
|
|
21805
21805
|
if (!dirLink)
|
|
21806
|
-
throw createError(ENOENT, "open", sep2 +
|
|
21806
|
+
throw createError(ENOENT, "open", sep2 + steps2.join(sep2));
|
|
21807
21807
|
if (flagsNum & O_CREAT && typeof modeNum === "number") {
|
|
21808
|
-
link = this.createLink(dirLink,
|
|
21808
|
+
link = this.createLink(dirLink, steps2[steps2.length - 1], false, modeNum);
|
|
21809
21809
|
}
|
|
21810
21810
|
}
|
|
21811
21811
|
if (link)
|
|
@@ -21904,8 +21904,8 @@ var require_volume = __commonJS({
|
|
|
21904
21904
|
fd = id;
|
|
21905
21905
|
else {
|
|
21906
21906
|
var filename = pathToFilename(id);
|
|
21907
|
-
var
|
|
21908
|
-
var link = this.getResolvedLink(
|
|
21907
|
+
var steps2 = filenameToSteps(filename);
|
|
21908
|
+
var link = this.getResolvedLink(steps2);
|
|
21909
21909
|
if (link) {
|
|
21910
21910
|
var node = link.getNode();
|
|
21911
21911
|
if (node.isDirectory())
|
|
@@ -22128,8 +22128,8 @@ var require_volume = __commonJS({
|
|
|
22128
22128
|
this.wrapAsync(this.linkBase, [existingPathFilename, newPathFilename], callback);
|
|
22129
22129
|
};
|
|
22130
22130
|
Volume2.prototype.unlinkBase = function(filename) {
|
|
22131
|
-
var
|
|
22132
|
-
var link = this.getLink(
|
|
22131
|
+
var steps2 = filenameToSteps(filename);
|
|
22132
|
+
var link = this.getLink(steps2);
|
|
22133
22133
|
if (!link)
|
|
22134
22134
|
throw createError(ENOENT, "unlink", filename);
|
|
22135
22135
|
if (link.length)
|
|
@@ -22173,8 +22173,8 @@ var require_volume = __commonJS({
|
|
|
22173
22173
|
this.wrapAsync(this.symlinkBase, [targetFilename, pathFilename], callback);
|
|
22174
22174
|
};
|
|
22175
22175
|
Volume2.prototype.realpathBase = function(filename, encoding) {
|
|
22176
|
-
var
|
|
22177
|
-
var realLink = this.getResolvedLink(
|
|
22176
|
+
var steps2 = filenameToSteps(filename);
|
|
22177
|
+
var realLink = this.getResolvedLink(steps2);
|
|
22178
22178
|
if (!realLink)
|
|
22179
22179
|
throw createError(ENOENT, "realpath", filename);
|
|
22180
22180
|
return (0, encoding_1.strToEncoding)(realLink.getPath() || "/", encoding);
|
|
@@ -22340,8 +22340,8 @@ var require_volume = __commonJS({
|
|
|
22340
22340
|
this.writeFile(id, data, opts, callback);
|
|
22341
22341
|
};
|
|
22342
22342
|
Volume2.prototype.readdirBase = function(filename, options) {
|
|
22343
|
-
var
|
|
22344
|
-
var link = this.getResolvedLink(
|
|
22343
|
+
var steps2 = filenameToSteps(filename);
|
|
22344
|
+
var link = this.getResolvedLink(steps2);
|
|
22345
22345
|
if (!link)
|
|
22346
22346
|
throw createError(ENOENT, "readdir", filename);
|
|
22347
22347
|
var node = link.getNode();
|
|
@@ -22479,12 +22479,12 @@ var require_volume = __commonJS({
|
|
|
22479
22479
|
this.wrapAsync(this.utimesBase, [pathToFilename(path2), toUnixTimestamp(atime), toUnixTimestamp(mtime)], callback);
|
|
22480
22480
|
};
|
|
22481
22481
|
Volume2.prototype.mkdirBase = function(filename, modeNum) {
|
|
22482
|
-
var
|
|
22483
|
-
if (!
|
|
22482
|
+
var steps2 = filenameToSteps(filename);
|
|
22483
|
+
if (!steps2.length) {
|
|
22484
22484
|
throw createError(EEXIST, "mkdir", filename);
|
|
22485
22485
|
}
|
|
22486
22486
|
var dir = this.getLinkParentAsDirOrThrow(filename, "mkdir");
|
|
22487
|
-
var name =
|
|
22487
|
+
var name = steps2[steps2.length - 1];
|
|
22488
22488
|
if (dir.getChild(name))
|
|
22489
22489
|
throw createError(EEXIST, "mkdir", filename);
|
|
22490
22490
|
dir.createChild(name, this.createNode(true, modeNum));
|
|
@@ -22492,11 +22492,11 @@ var require_volume = __commonJS({
|
|
|
22492
22492
|
Volume2.prototype.mkdirpBase = function(filename, modeNum) {
|
|
22493
22493
|
var fullPath = resolve2(filename);
|
|
22494
22494
|
var fullPathSansSlash = fullPath.substring(1);
|
|
22495
|
-
var
|
|
22495
|
+
var steps2 = !fullPathSansSlash ? [] : fullPathSansSlash.split(sep2);
|
|
22496
22496
|
var link = this.root;
|
|
22497
22497
|
var created = false;
|
|
22498
|
-
for (var i2 = 0; i2 <
|
|
22499
|
-
var step =
|
|
22498
|
+
for (var i2 = 0; i2 < steps2.length; i2++) {
|
|
22499
|
+
var step = steps2[i2];
|
|
22500
22500
|
if (!link.getNode().isDirectory())
|
|
22501
22501
|
throw createError(ENOTDIR, "mkdir", link.getPath());
|
|
22502
22502
|
var child = link.getChild(step);
|
|
@@ -23243,7 +23243,7 @@ var require_ponyfill_es2018 = __commonJS({
|
|
|
23243
23243
|
})(exports, function(exports2) {
|
|
23244
23244
|
"use strict";
|
|
23245
23245
|
const SymbolPolyfill = typeof Symbol === "function" && typeof Symbol.iterator === "symbol" ? Symbol : (description) => `Symbol(${description})`;
|
|
23246
|
-
function
|
|
23246
|
+
function noop3() {
|
|
23247
23247
|
return void 0;
|
|
23248
23248
|
}
|
|
23249
23249
|
function getGlobals() {
|
|
@@ -23260,7 +23260,7 @@ var require_ponyfill_es2018 = __commonJS({
|
|
|
23260
23260
|
function typeIsObject(x2) {
|
|
23261
23261
|
return typeof x2 === "object" && x2 !== null || typeof x2 === "function";
|
|
23262
23262
|
}
|
|
23263
|
-
const rethrowAssertionErrorRejection =
|
|
23263
|
+
const rethrowAssertionErrorRejection = noop3;
|
|
23264
23264
|
const originalPromise = Promise;
|
|
23265
23265
|
const originalPromiseThen = Promise.prototype.then;
|
|
23266
23266
|
const originalPromiseResolve = Promise.resolve.bind(originalPromise);
|
|
@@ -25469,7 +25469,7 @@ var require_ponyfill_es2018 = __commonJS({
|
|
|
25469
25469
|
return newPromise((resolveRead, rejectRead) => {
|
|
25470
25470
|
ReadableStreamDefaultReaderRead(reader, {
|
|
25471
25471
|
_chunkSteps: (chunk) => {
|
|
25472
|
-
currentWrite = PerformPromiseThen(WritableStreamDefaultWriterWrite(writer, chunk), void 0,
|
|
25472
|
+
currentWrite = PerformPromiseThen(WritableStreamDefaultWriterWrite(writer, chunk), void 0, noop3);
|
|
25473
25473
|
resolveRead(false);
|
|
25474
25474
|
},
|
|
25475
25475
|
_closeSteps: () => resolveRead(true),
|
|
@@ -26364,7 +26364,7 @@ var require_ponyfill_es2018 = __commonJS({
|
|
|
26364
26364
|
reader._readIntoRequests = new SimpleQueue();
|
|
26365
26365
|
}
|
|
26366
26366
|
const sourceCancelPromise = stream._readableStreamController[CancelSteps](reason);
|
|
26367
|
-
return transformPromiseWith(sourceCancelPromise,
|
|
26367
|
+
return transformPromiseWith(sourceCancelPromise, noop3);
|
|
26368
26368
|
}
|
|
26369
26369
|
function ReadableStreamClose(stream) {
|
|
26370
26370
|
stream._state = "closed";
|
|
@@ -26848,9 +26848,9 @@ var require_streams = __commonJS({
|
|
|
26848
26848
|
}
|
|
26849
26849
|
}
|
|
26850
26850
|
try {
|
|
26851
|
-
const { Blob:
|
|
26852
|
-
if (
|
|
26853
|
-
|
|
26851
|
+
const { Blob: Blob4 } = require("buffer");
|
|
26852
|
+
if (Blob4 && !Blob4.prototype.stream) {
|
|
26853
|
+
Blob4.prototype.stream = function name(params) {
|
|
26854
26854
|
let position = 0;
|
|
26855
26855
|
const blob = this;
|
|
26856
26856
|
return new ReadableStream({
|
|
@@ -26901,12 +26901,12 @@ async function* toIterator(parts, clone2 = true) {
|
|
|
26901
26901
|
}
|
|
26902
26902
|
}
|
|
26903
26903
|
}
|
|
26904
|
-
var import_streams, POOL_SIZE, _Blob,
|
|
26904
|
+
var import_streams, POOL_SIZE, _Blob, Blob3, fetch_blob_default;
|
|
26905
26905
|
var init_fetch_blob = __esm({
|
|
26906
26906
|
"../../node_modules/.pnpm/fetch-blob@3.2.0/node_modules/fetch-blob/index.js"() {
|
|
26907
26907
|
import_streams = __toESM(require_streams(), 1);
|
|
26908
26908
|
POOL_SIZE = 65536;
|
|
26909
|
-
_Blob = class
|
|
26909
|
+
_Blob = class Blob2 {
|
|
26910
26910
|
#parts = [];
|
|
26911
26911
|
#type = "";
|
|
26912
26912
|
#size = 0;
|
|
@@ -26930,7 +26930,7 @@ var init_fetch_blob = __esm({
|
|
|
26930
26930
|
part = new Uint8Array(element.buffer.slice(element.byteOffset, element.byteOffset + element.byteLength));
|
|
26931
26931
|
} else if (element instanceof ArrayBuffer) {
|
|
26932
26932
|
part = new Uint8Array(element.slice(0));
|
|
26933
|
-
} else if (element instanceof
|
|
26933
|
+
} else if (element instanceof Blob2) {
|
|
26934
26934
|
part = element;
|
|
26935
26935
|
} else {
|
|
26936
26936
|
part = encoder.encode(`${element}`);
|
|
@@ -27009,7 +27009,7 @@ var init_fetch_blob = __esm({
|
|
|
27009
27009
|
relativeStart = 0;
|
|
27010
27010
|
}
|
|
27011
27011
|
}
|
|
27012
|
-
const blob = new
|
|
27012
|
+
const blob = new Blob2([], { type: String(type).toLowerCase() });
|
|
27013
27013
|
blob.#size = span;
|
|
27014
27014
|
blob.#parts = blobParts;
|
|
27015
27015
|
return blob;
|
|
@@ -27026,17 +27026,17 @@ var init_fetch_blob = __esm({
|
|
|
27026
27026
|
type: { enumerable: true },
|
|
27027
27027
|
slice: { enumerable: true }
|
|
27028
27028
|
});
|
|
27029
|
-
|
|
27030
|
-
fetch_blob_default =
|
|
27029
|
+
Blob3 = _Blob;
|
|
27030
|
+
fetch_blob_default = Blob3;
|
|
27031
27031
|
}
|
|
27032
27032
|
});
|
|
27033
27033
|
|
|
27034
27034
|
// ../../node_modules/.pnpm/fetch-blob@3.2.0/node_modules/fetch-blob/file.js
|
|
27035
|
-
var _File,
|
|
27035
|
+
var _File, File3, file_default;
|
|
27036
27036
|
var init_file = __esm({
|
|
27037
27037
|
"../../node_modules/.pnpm/fetch-blob@3.2.0/node_modules/fetch-blob/file.js"() {
|
|
27038
27038
|
init_fetch_blob();
|
|
27039
|
-
_File = class
|
|
27039
|
+
_File = class File2 extends fetch_blob_default {
|
|
27040
27040
|
#lastModified = 0;
|
|
27041
27041
|
#name = "";
|
|
27042
27042
|
constructor(fileBits, fileName, options = {}) {
|
|
@@ -27065,8 +27065,8 @@ var init_file = __esm({
|
|
|
27065
27065
|
return !!object && object instanceof fetch_blob_default && /^(File)$/.test(object[Symbol.toStringTag]);
|
|
27066
27066
|
}
|
|
27067
27067
|
};
|
|
27068
|
-
|
|
27069
|
-
file_default =
|
|
27068
|
+
File3 = _File;
|
|
27069
|
+
file_default = File3;
|
|
27070
27070
|
}
|
|
27071
27071
|
});
|
|
27072
27072
|
|
|
@@ -27084,7 +27084,7 @@ Content-Type: ${v.type || "application/octet-stream"}\r
|
|
|
27084
27084
|
c.push(`--${b}--`);
|
|
27085
27085
|
return new B(c, { type: "multipart/form-data; boundary=" + b });
|
|
27086
27086
|
}
|
|
27087
|
-
var t, i, h, r, m, f, e, x,
|
|
27087
|
+
var t, i, h, r, m, f, e, x, FormData2;
|
|
27088
27088
|
var init_esm_min = __esm({
|
|
27089
27089
|
"../../node_modules/.pnpm/formdata-polyfill@4.0.10/node_modules/formdata-polyfill/esm.min.js"() {
|
|
27090
27090
|
init_fetch_blob();
|
|
@@ -27099,7 +27099,7 @@ var init_esm_min = __esm({
|
|
|
27099
27099
|
throw new TypeError(`Failed to execute '${n}' on 'FormData': ${e2} arguments required, but only ${a.length} present.`);
|
|
27100
27100
|
}
|
|
27101
27101
|
};
|
|
27102
|
-
|
|
27102
|
+
FormData2 = class FormData3 {
|
|
27103
27103
|
#d = [];
|
|
27104
27104
|
constructor(...a) {
|
|
27105
27105
|
if (a.length)
|
|
@@ -27265,7 +27265,7 @@ async function toFormData(Body2, ct) {
|
|
|
27265
27265
|
let contentType;
|
|
27266
27266
|
let filename;
|
|
27267
27267
|
const entryChunks = [];
|
|
27268
|
-
const formData = new
|
|
27268
|
+
const formData = new FormData2();
|
|
27269
27269
|
const onPartData = (ui8a) => {
|
|
27270
27270
|
entryValue += decoder.decode(ui8a, { stream: true });
|
|
27271
27271
|
};
|
|
@@ -27323,7 +27323,7 @@ async function toFormData(Body2, ct) {
|
|
|
27323
27323
|
parser.end();
|
|
27324
27324
|
return formData;
|
|
27325
27325
|
}
|
|
27326
|
-
var s, S, f2, F, LF, CR, SPACE, HYPHEN, COLON, A, Z, lower,
|
|
27326
|
+
var s, S, f2, F, LF, CR, SPACE, HYPHEN, COLON, A, Z, lower, noop2, MultipartParser;
|
|
27327
27327
|
var init_multipart_parser = __esm({
|
|
27328
27328
|
"../../node_modules/.pnpm/node-fetch@3.3.0/node_modules/node-fetch/src/utils/multipart-parser.js"() {
|
|
27329
27329
|
init_from();
|
|
@@ -27354,19 +27354,19 @@ var init_multipart_parser = __esm({
|
|
|
27354
27354
|
A = 97;
|
|
27355
27355
|
Z = 122;
|
|
27356
27356
|
lower = (c) => c | 32;
|
|
27357
|
-
|
|
27357
|
+
noop2 = () => {
|
|
27358
27358
|
};
|
|
27359
27359
|
MultipartParser = class {
|
|
27360
27360
|
constructor(boundary) {
|
|
27361
27361
|
this.index = 0;
|
|
27362
27362
|
this.flags = 0;
|
|
27363
|
-
this.onHeaderEnd =
|
|
27364
|
-
this.onHeaderField =
|
|
27365
|
-
this.onHeadersEnd =
|
|
27366
|
-
this.onHeaderValue =
|
|
27367
|
-
this.onPartBegin =
|
|
27368
|
-
this.onPartData =
|
|
27369
|
-
this.onPartEnd =
|
|
27363
|
+
this.onHeaderEnd = noop2;
|
|
27364
|
+
this.onHeaderField = noop2;
|
|
27365
|
+
this.onHeadersEnd = noop2;
|
|
27366
|
+
this.onHeaderValue = noop2;
|
|
27367
|
+
this.onPartBegin = noop2;
|
|
27368
|
+
this.onPartData = noop2;
|
|
27369
|
+
this.onPartEnd = noop2;
|
|
27370
27370
|
this.boundaryChars = {};
|
|
27371
27371
|
boundary = "\r\n--" + boundary;
|
|
27372
27372
|
const ui8a = new Uint8Array(boundary.length);
|
|
@@ -37679,11 +37679,11 @@ var require_lib3 = __commonJS({
|
|
|
37679
37679
|
return this.parseV8Intrinsic() || super.parseExprAtom(refExpressionErrors);
|
|
37680
37680
|
}
|
|
37681
37681
|
};
|
|
37682
|
-
function hasPlugin(
|
|
37682
|
+
function hasPlugin(plugins2, expectedConfig) {
|
|
37683
37683
|
const [expectedName, expectedOptions] = typeof expectedConfig === "string" ? [expectedConfig, {}] : expectedConfig;
|
|
37684
37684
|
const expectedKeys = Object.keys(expectedOptions);
|
|
37685
37685
|
const expectedOptionsIsEmpty = expectedKeys.length === 0;
|
|
37686
|
-
return
|
|
37686
|
+
return plugins2.some((p) => {
|
|
37687
37687
|
if (typeof p === "string") {
|
|
37688
37688
|
return expectedOptionsIsEmpty && p === expectedName;
|
|
37689
37689
|
} else {
|
|
@@ -37700,8 +37700,8 @@ var require_lib3 = __commonJS({
|
|
|
37700
37700
|
}
|
|
37701
37701
|
});
|
|
37702
37702
|
}
|
|
37703
|
-
function getPluginOption(
|
|
37704
|
-
const plugin2 =
|
|
37703
|
+
function getPluginOption(plugins2, name, option) {
|
|
37704
|
+
const plugin2 = plugins2.find((plugin3) => {
|
|
37705
37705
|
if (Array.isArray(plugin3)) {
|
|
37706
37706
|
return plugin3[0] === name;
|
|
37707
37707
|
} else {
|
|
@@ -37716,43 +37716,43 @@ var require_lib3 = __commonJS({
|
|
|
37716
37716
|
var PIPELINE_PROPOSALS = ["minimal", "fsharp", "hack", "smart"];
|
|
37717
37717
|
var TOPIC_TOKENS = ["^^", "@@", "^", "%", "#"];
|
|
37718
37718
|
var RECORD_AND_TUPLE_SYNTAX_TYPES = ["hash", "bar"];
|
|
37719
|
-
function validatePlugins(
|
|
37720
|
-
if (hasPlugin(
|
|
37721
|
-
if (hasPlugin(
|
|
37719
|
+
function validatePlugins(plugins2) {
|
|
37720
|
+
if (hasPlugin(plugins2, "decorators")) {
|
|
37721
|
+
if (hasPlugin(plugins2, "decorators-legacy")) {
|
|
37722
37722
|
throw new Error("Cannot use the decorators and decorators-legacy plugin together");
|
|
37723
37723
|
}
|
|
37724
|
-
const decoratorsBeforeExport = getPluginOption(
|
|
37724
|
+
const decoratorsBeforeExport = getPluginOption(plugins2, "decorators", "decoratorsBeforeExport");
|
|
37725
37725
|
if (decoratorsBeforeExport != null && typeof decoratorsBeforeExport !== "boolean") {
|
|
37726
37726
|
throw new Error("'decoratorsBeforeExport' must be a boolean.");
|
|
37727
37727
|
}
|
|
37728
|
-
const allowCallParenthesized = getPluginOption(
|
|
37728
|
+
const allowCallParenthesized = getPluginOption(plugins2, "decorators", "allowCallParenthesized");
|
|
37729
37729
|
if (allowCallParenthesized != null && typeof allowCallParenthesized !== "boolean") {
|
|
37730
37730
|
throw new Error("'allowCallParenthesized' must be a boolean.");
|
|
37731
37731
|
}
|
|
37732
37732
|
}
|
|
37733
|
-
if (hasPlugin(
|
|
37733
|
+
if (hasPlugin(plugins2, "flow") && hasPlugin(plugins2, "typescript")) {
|
|
37734
37734
|
throw new Error("Cannot combine flow and typescript plugins.");
|
|
37735
37735
|
}
|
|
37736
|
-
if (hasPlugin(
|
|
37736
|
+
if (hasPlugin(plugins2, "placeholders") && hasPlugin(plugins2, "v8intrinsic")) {
|
|
37737
37737
|
throw new Error("Cannot combine placeholders and v8intrinsic plugins.");
|
|
37738
37738
|
}
|
|
37739
|
-
if (hasPlugin(
|
|
37740
|
-
const proposal = getPluginOption(
|
|
37739
|
+
if (hasPlugin(plugins2, "pipelineOperator")) {
|
|
37740
|
+
const proposal = getPluginOption(plugins2, "pipelineOperator", "proposal");
|
|
37741
37741
|
if (!PIPELINE_PROPOSALS.includes(proposal)) {
|
|
37742
37742
|
const proposalList = PIPELINE_PROPOSALS.map((p) => `"${p}"`).join(", ");
|
|
37743
37743
|
throw new Error(`"pipelineOperator" requires "proposal" option whose value must be one of: ${proposalList}.`);
|
|
37744
37744
|
}
|
|
37745
|
-
const tupleSyntaxIsHash = hasPlugin(
|
|
37745
|
+
const tupleSyntaxIsHash = hasPlugin(plugins2, ["recordAndTuple", {
|
|
37746
37746
|
syntaxType: "hash"
|
|
37747
37747
|
}]);
|
|
37748
37748
|
if (proposal === "hack") {
|
|
37749
|
-
if (hasPlugin(
|
|
37749
|
+
if (hasPlugin(plugins2, "placeholders")) {
|
|
37750
37750
|
throw new Error("Cannot combine placeholders plugin and Hack-style pipes.");
|
|
37751
37751
|
}
|
|
37752
|
-
if (hasPlugin(
|
|
37752
|
+
if (hasPlugin(plugins2, "v8intrinsic")) {
|
|
37753
37753
|
throw new Error("Cannot combine v8intrinsic plugin and Hack-style pipes.");
|
|
37754
37754
|
}
|
|
37755
|
-
const topicToken = getPluginOption(
|
|
37755
|
+
const topicToken = getPluginOption(plugins2, "pipelineOperator", "topicToken");
|
|
37756
37756
|
if (!TOPIC_TOKENS.includes(topicToken)) {
|
|
37757
37757
|
const tokenList = TOPIC_TOKENS.map((t2) => `"${t2}"`).join(", ");
|
|
37758
37758
|
throw new Error(`"pipelineOperator" in "proposal": "hack" mode also requires a "topicToken" option whose value must be one of: ${tokenList}.`);
|
|
@@ -37764,21 +37764,21 @@ var require_lib3 = __commonJS({
|
|
|
37764
37764
|
throw new Error('Plugin conflict between `["pipelineOperator", { proposal: "smart" }]` and `["recordAndtuple", { syntaxType: "hash"}]`.');
|
|
37765
37765
|
}
|
|
37766
37766
|
}
|
|
37767
|
-
if (hasPlugin(
|
|
37767
|
+
if (hasPlugin(plugins2, "moduleAttributes")) {
|
|
37768
37768
|
{
|
|
37769
|
-
if (hasPlugin(
|
|
37769
|
+
if (hasPlugin(plugins2, "importAssertions")) {
|
|
37770
37770
|
throw new Error("Cannot combine importAssertions and moduleAttributes plugins.");
|
|
37771
37771
|
}
|
|
37772
|
-
const moduleAttributesVersionPluginOption = getPluginOption(
|
|
37772
|
+
const moduleAttributesVersionPluginOption = getPluginOption(plugins2, "moduleAttributes", "version");
|
|
37773
37773
|
if (moduleAttributesVersionPluginOption !== "may-2020") {
|
|
37774
37774
|
throw new Error("The 'moduleAttributes' plugin requires a 'version' option, representing the last proposal update. Currently, the only supported value is 'may-2020'.");
|
|
37775
37775
|
}
|
|
37776
37776
|
}
|
|
37777
37777
|
}
|
|
37778
|
-
if (hasPlugin(
|
|
37778
|
+
if (hasPlugin(plugins2, "recordAndTuple") && getPluginOption(plugins2, "recordAndTuple", "syntaxType") != null && !RECORD_AND_TUPLE_SYNTAX_TYPES.includes(getPluginOption(plugins2, "recordAndTuple", "syntaxType"))) {
|
|
37779
37779
|
throw new Error("The 'syntaxType' option of the 'recordAndTuple' plugin must be one of: " + RECORD_AND_TUPLE_SYNTAX_TYPES.map((p) => `'${p}'`).join(", "));
|
|
37780
37780
|
}
|
|
37781
|
-
if (hasPlugin(
|
|
37781
|
+
if (hasPlugin(plugins2, "asyncDoExpressions") && !hasPlugin(plugins2, "doExpressions")) {
|
|
37782
37782
|
const error = new Error("'asyncDoExpressions' requires 'doExpressions', please add 'doExpressions' to parser plugins.");
|
|
37783
37783
|
error.missingPlugins = "doExpressions";
|
|
37784
37784
|
throw error;
|
|
@@ -42037,9 +42037,9 @@ var require_lib3 = __commonJS({
|
|
|
42037
42037
|
return file;
|
|
42038
42038
|
}
|
|
42039
42039
|
};
|
|
42040
|
-
function pluginsMap(
|
|
42040
|
+
function pluginsMap(plugins2) {
|
|
42041
42041
|
const pluginMap = /* @__PURE__ */ new Map();
|
|
42042
|
-
for (const plugin2 of
|
|
42042
|
+
for (const plugin2 of plugins2) {
|
|
42043
42043
|
const [name, options] = Array.isArray(plugin2) ? plugin2 : [plugin2, {}];
|
|
42044
42044
|
if (!pluginMap.has(name))
|
|
42045
42045
|
pluginMap.set(name, options || {});
|
|
@@ -44710,10 +44710,10 @@ var require_fork = __commonJS({
|
|
|
44710
44710
|
var path_1 = tslib_1.__importDefault(require_path2());
|
|
44711
44711
|
var node_path_1 = tslib_1.__importDefault(require_node_path());
|
|
44712
44712
|
var shared_1 = require_shared();
|
|
44713
|
-
function default_1(
|
|
44713
|
+
function default_1(plugins2) {
|
|
44714
44714
|
var fork = createFork();
|
|
44715
44715
|
var types4 = fork.use(types_1.default);
|
|
44716
|
-
|
|
44716
|
+
plugins2.forEach(fork.use);
|
|
44717
44717
|
types4.finalize();
|
|
44718
44718
|
var PathVisitor = fork.use(path_visitor_1.default);
|
|
44719
44719
|
return {
|
|
@@ -58398,17 +58398,21 @@ __export(lib_exports, {
|
|
|
58398
58398
|
CompiledSubscriptionKind: () => CompiledSubscriptionKind,
|
|
58399
58399
|
Config: () => Config,
|
|
58400
58400
|
DataSource: () => DataSource,
|
|
58401
|
+
DocumentStore: () => DocumentStore,
|
|
58402
|
+
HoudiniClient: () => HoudiniClient,
|
|
58401
58403
|
HoudiniError: () => HoudiniError,
|
|
58402
58404
|
LogLevel: () => LogLevel,
|
|
58403
58405
|
RefetchUpdateMode: () => RefetchUpdateMode,
|
|
58404
58406
|
TypeWrapper: () => TypeWrapper,
|
|
58405
58407
|
cleanupFiles: () => cleanupFiles,
|
|
58406
58408
|
computeID: () => computeID,
|
|
58409
|
+
createPluginHooks: () => createPluginHooks,
|
|
58407
58410
|
deepMerge: () => deepMerge,
|
|
58408
58411
|
defaultConfigValues: () => defaultConfigValues,
|
|
58409
58412
|
definitionFromAncestors: () => definitionFromAncestors,
|
|
58410
58413
|
ensureArtifactImport: () => ensureArtifactImport,
|
|
58411
58414
|
ensureImports: () => ensureImports,
|
|
58415
|
+
fetch: () => fetch2,
|
|
58412
58416
|
find_graphql: () => find_graphql,
|
|
58413
58417
|
formatErrors: () => formatErrors,
|
|
58414
58418
|
fs: () => fs_exports,
|
|
@@ -58419,6 +58423,7 @@ __export(lib_exports, {
|
|
|
58419
58423
|
hashDocument: () => hashDocument,
|
|
58420
58424
|
houdini_mode: () => houdini_mode,
|
|
58421
58425
|
keyFieldsForType: () => keyFieldsForType,
|
|
58426
|
+
mutation: () => mutation,
|
|
58422
58427
|
operation_requires_variables: () => operation_requires_variables,
|
|
58423
58428
|
orderedPlugins: () => orderedPlugins,
|
|
58424
58429
|
parentTypeFromAncestors: () => parentTypeFromAncestors,
|
|
@@ -58427,10 +58432,12 @@ __export(lib_exports, {
|
|
|
58427
58432
|
path: () => path_exports,
|
|
58428
58433
|
plugin: () => plugin,
|
|
58429
58434
|
pullSchema: () => pullSchema,
|
|
58435
|
+
query: () => query,
|
|
58430
58436
|
readConfigFile: () => readConfigFile,
|
|
58431
58437
|
runPipeline: () => runPipeline,
|
|
58432
58438
|
setMockConfig: () => setMockConfig,
|
|
58433
58439
|
siteURL: () => siteURL,
|
|
58440
|
+
subscription: () => subscription,
|
|
58434
58441
|
unwrapType: () => unwrapType,
|
|
58435
58442
|
wrapType: () => wrapType
|
|
58436
58443
|
});
|
|
@@ -61567,6 +61574,10 @@ var import_node_url2 = require("node:url");
|
|
|
61567
61574
|
// src/runtime/imports/config.ts
|
|
61568
61575
|
var config_default = {};
|
|
61569
61576
|
|
|
61577
|
+
// src/runtime/imports/pluginConfig.ts
|
|
61578
|
+
var configs = [];
|
|
61579
|
+
var pluginConfig_default = configs;
|
|
61580
|
+
|
|
61570
61581
|
// src/runtime/lib/config.ts
|
|
61571
61582
|
var mockConfig = null;
|
|
61572
61583
|
function getMockConfig() {
|
|
@@ -61602,45 +61613,284 @@ function computeID(configFile, type, data) {
|
|
|
61602
61613
|
}
|
|
61603
61614
|
return id.slice(0, -2);
|
|
61604
61615
|
}
|
|
61616
|
+
var _configFile = null;
|
|
61605
61617
|
function getCurrentConfig() {
|
|
61606
61618
|
const mockConfig2 = getMockConfig();
|
|
61607
61619
|
if (mockConfig2) {
|
|
61608
61620
|
return mockConfig2;
|
|
61609
61621
|
}
|
|
61610
|
-
|
|
61622
|
+
if (_configFile) {
|
|
61623
|
+
return _configFile;
|
|
61624
|
+
}
|
|
61625
|
+
let configFile = defaultConfigValues(config_default);
|
|
61626
|
+
for (const pluginConfig of pluginConfig_default) {
|
|
61627
|
+
configFile = pluginConfig(configFile);
|
|
61628
|
+
}
|
|
61629
|
+
_configFile = configFile;
|
|
61630
|
+
return configFile;
|
|
61631
|
+
}
|
|
61632
|
+
|
|
61633
|
+
// src/runtime/lib/deepEquals.ts
|
|
61634
|
+
function deepEquals(objA, objB, map = /* @__PURE__ */ new WeakMap()) {
|
|
61635
|
+
if (Object.is(objA, objB))
|
|
61636
|
+
return true;
|
|
61637
|
+
if (objA instanceof Date && objB instanceof Date) {
|
|
61638
|
+
return objA.getTime() === objB.getTime();
|
|
61639
|
+
}
|
|
61640
|
+
if (objA instanceof RegExp && objB instanceof RegExp) {
|
|
61641
|
+
return objA.toString() === objB.toString();
|
|
61642
|
+
}
|
|
61643
|
+
if (typeof objA !== "object" || objA === null || typeof objB !== "object" || objB === null) {
|
|
61644
|
+
return false;
|
|
61645
|
+
}
|
|
61646
|
+
if (map.get(objA) === objB)
|
|
61647
|
+
return true;
|
|
61648
|
+
map.set(objA, objB);
|
|
61649
|
+
const keysA = Reflect.ownKeys(objA);
|
|
61650
|
+
const keysB = Reflect.ownKeys(objB);
|
|
61651
|
+
if (keysA.length !== keysB.length) {
|
|
61652
|
+
return false;
|
|
61653
|
+
}
|
|
61654
|
+
for (let i2 = 0; i2 < keysA.length; i2++) {
|
|
61655
|
+
if (!Reflect.has(objB, keysA[i2]) || !deepEquals(objA[keysA[i2]], objB[keysA[i2]], map)) {
|
|
61656
|
+
return false;
|
|
61657
|
+
}
|
|
61658
|
+
}
|
|
61659
|
+
return true;
|
|
61660
|
+
}
|
|
61661
|
+
|
|
61662
|
+
// src/runtime/lib/selection.ts
|
|
61663
|
+
function getFieldsForType(selection, __typename) {
|
|
61664
|
+
let targetSelection = selection.fields || {};
|
|
61665
|
+
if (selection.abstractFields && __typename) {
|
|
61666
|
+
const mappedType = selection.abstractFields.typeMap[__typename];
|
|
61667
|
+
if (mappedType) {
|
|
61668
|
+
targetSelection = selection.abstractFields.fields[mappedType];
|
|
61669
|
+
} else if (selection.abstractFields.fields[__typename]) {
|
|
61670
|
+
targetSelection = selection.abstractFields.fields[__typename];
|
|
61671
|
+
}
|
|
61672
|
+
}
|
|
61673
|
+
return targetSelection;
|
|
61674
|
+
}
|
|
61675
|
+
|
|
61676
|
+
// src/runtime/lib/scalars.ts
|
|
61677
|
+
async function marshalSelection({
|
|
61678
|
+
selection,
|
|
61679
|
+
data
|
|
61680
|
+
}) {
|
|
61681
|
+
const config = getCurrentConfig();
|
|
61682
|
+
if (data === null || typeof data === "undefined") {
|
|
61683
|
+
return data;
|
|
61684
|
+
}
|
|
61685
|
+
if (Array.isArray(data)) {
|
|
61686
|
+
return await Promise.all(data.map((val) => marshalSelection({ selection, data: val })));
|
|
61687
|
+
}
|
|
61688
|
+
const targetSelection = getFieldsForType(selection, data["__typename"]);
|
|
61689
|
+
return Object.fromEntries(
|
|
61690
|
+
await Promise.all(
|
|
61691
|
+
Object.entries(data).map(async ([fieldName, value]) => {
|
|
61692
|
+
const { type, selection: selection2 } = targetSelection[fieldName];
|
|
61693
|
+
if (!type) {
|
|
61694
|
+
return [fieldName, value];
|
|
61695
|
+
}
|
|
61696
|
+
if (selection2) {
|
|
61697
|
+
return [fieldName, await marshalSelection({ selection: selection2, data: value })];
|
|
61698
|
+
}
|
|
61699
|
+
if (config.scalars?.[type]) {
|
|
61700
|
+
const marshalFn = config.scalars[type].marshal;
|
|
61701
|
+
if (!marshalFn) {
|
|
61702
|
+
throw new Error(
|
|
61703
|
+
`scalar type ${type} is missing a \`marshal\` function. see https://github.com/AlecAivazis/houdini#%EF%B8%8Fcustom-scalars`
|
|
61704
|
+
);
|
|
61705
|
+
}
|
|
61706
|
+
if (Array.isArray(value)) {
|
|
61707
|
+
return [fieldName, value.map(marshalFn)];
|
|
61708
|
+
}
|
|
61709
|
+
return [fieldName, marshalFn(value)];
|
|
61710
|
+
}
|
|
61711
|
+
return [fieldName, value];
|
|
61712
|
+
})
|
|
61713
|
+
)
|
|
61714
|
+
);
|
|
61715
|
+
}
|
|
61716
|
+
function marshalInputs({
|
|
61717
|
+
artifact,
|
|
61718
|
+
input,
|
|
61719
|
+
config,
|
|
61720
|
+
rootType = "@root"
|
|
61721
|
+
}) {
|
|
61722
|
+
if (input === null || typeof input === "undefined") {
|
|
61723
|
+
return input;
|
|
61724
|
+
}
|
|
61725
|
+
if (!artifact.input) {
|
|
61726
|
+
return input;
|
|
61727
|
+
}
|
|
61728
|
+
const fields = rootType === "@root" ? artifact.input.fields : artifact.input.types[rootType];
|
|
61729
|
+
if (Array.isArray(input)) {
|
|
61730
|
+
return input.map((val) => marshalInputs({ artifact, input: val, rootType, config }));
|
|
61731
|
+
}
|
|
61732
|
+
return Object.fromEntries(
|
|
61733
|
+
Object.entries(input).map(([fieldName, value]) => {
|
|
61734
|
+
const type = fields?.[fieldName];
|
|
61735
|
+
if (!type) {
|
|
61736
|
+
return [fieldName, value];
|
|
61737
|
+
}
|
|
61738
|
+
const marshalFn = config.scalars?.[type]?.marshal;
|
|
61739
|
+
if (marshalFn) {
|
|
61740
|
+
if (Array.isArray(value)) {
|
|
61741
|
+
return [fieldName, value.map(marshalFn)];
|
|
61742
|
+
}
|
|
61743
|
+
return [fieldName, marshalFn(value)];
|
|
61744
|
+
}
|
|
61745
|
+
if (isScalar(config, type) || !artifact.input.types[type]) {
|
|
61746
|
+
return [fieldName, value];
|
|
61747
|
+
}
|
|
61748
|
+
return [fieldName, marshalInputs({ artifact, input: value, rootType: type, config })];
|
|
61749
|
+
})
|
|
61750
|
+
);
|
|
61751
|
+
}
|
|
61752
|
+
function unmarshalSelection(config, selection, data) {
|
|
61753
|
+
if (data === null || typeof data === "undefined") {
|
|
61754
|
+
return data;
|
|
61755
|
+
}
|
|
61756
|
+
if (Array.isArray(data)) {
|
|
61757
|
+
return data.map((val) => unmarshalSelection(config, selection, val));
|
|
61758
|
+
}
|
|
61759
|
+
const targetSelection = getFieldsForType(selection, data["__typename"]);
|
|
61760
|
+
return Object.fromEntries(
|
|
61761
|
+
Object.entries(data).map(([fieldName, value]) => {
|
|
61762
|
+
const { type, selection: selection2 } = targetSelection[fieldName];
|
|
61763
|
+
if (!type) {
|
|
61764
|
+
return [fieldName, value];
|
|
61765
|
+
}
|
|
61766
|
+
if (selection2) {
|
|
61767
|
+
return [
|
|
61768
|
+
fieldName,
|
|
61769
|
+
unmarshalSelection(config, selection2, value)
|
|
61770
|
+
];
|
|
61771
|
+
}
|
|
61772
|
+
if (value === null) {
|
|
61773
|
+
return [fieldName, value];
|
|
61774
|
+
}
|
|
61775
|
+
if (config.scalars?.[type]?.marshal) {
|
|
61776
|
+
const unmarshalFn = config.scalars[type]?.unmarshal;
|
|
61777
|
+
if (!unmarshalFn) {
|
|
61778
|
+
throw new Error(
|
|
61779
|
+
`scalar type ${type} is missing an \`unmarshal\` function. see https://github.com/AlecAivazis/houdini#%EF%B8%8Fcustom-scalars`
|
|
61780
|
+
);
|
|
61781
|
+
}
|
|
61782
|
+
if (Array.isArray(value)) {
|
|
61783
|
+
return [fieldName, value.map(unmarshalFn)];
|
|
61784
|
+
}
|
|
61785
|
+
return [fieldName, unmarshalFn(value)];
|
|
61786
|
+
}
|
|
61787
|
+
return [fieldName, value];
|
|
61788
|
+
})
|
|
61789
|
+
);
|
|
61790
|
+
}
|
|
61791
|
+
function isScalar(config, type) {
|
|
61792
|
+
return ["String", "Boolean", "Float", "ID", "Int"].concat(Object.keys(config.scalars || {})).includes(type);
|
|
61611
61793
|
}
|
|
61612
61794
|
|
|
61613
61795
|
// src/runtime/lib/types.ts
|
|
61614
|
-
var CachePolicy =
|
|
61615
|
-
|
|
61616
|
-
|
|
61617
|
-
|
|
61618
|
-
|
|
61619
|
-
|
|
61620
|
-
|
|
61621
|
-
|
|
61622
|
-
|
|
61623
|
-
|
|
61624
|
-
|
|
61625
|
-
|
|
61626
|
-
|
|
61627
|
-
|
|
61628
|
-
var
|
|
61629
|
-
var
|
|
61630
|
-
var
|
|
61631
|
-
|
|
61632
|
-
|
|
61633
|
-
|
|
61634
|
-
|
|
61635
|
-
|
|
61636
|
-
|
|
61637
|
-
|
|
61638
|
-
|
|
61639
|
-
|
|
61640
|
-
|
|
61641
|
-
|
|
61642
|
-
|
|
61643
|
-
|
|
61796
|
+
var CachePolicy = {
|
|
61797
|
+
CacheOrNetwork: "CacheOrNetwork",
|
|
61798
|
+
CacheOnly: "CacheOnly",
|
|
61799
|
+
NetworkOnly: "NetworkOnly",
|
|
61800
|
+
CacheAndNetwork: "CacheAndNetwork"
|
|
61801
|
+
};
|
|
61802
|
+
var ArtifactKind = {
|
|
61803
|
+
Query: "HoudiniQuery",
|
|
61804
|
+
Subscription: "HoudiniSubscription",
|
|
61805
|
+
Mutation: "HoudiniMutation",
|
|
61806
|
+
Fragment: "HoudiniFragment"
|
|
61807
|
+
};
|
|
61808
|
+
var CompiledFragmentKind = ArtifactKind.Fragment;
|
|
61809
|
+
var CompiledMutationKind = ArtifactKind.Mutation;
|
|
61810
|
+
var CompiledQueryKind = ArtifactKind.Query;
|
|
61811
|
+
var CompiledSubscriptionKind = ArtifactKind.Subscription;
|
|
61812
|
+
var RefetchUpdateMode = {
|
|
61813
|
+
append: "append",
|
|
61814
|
+
prepend: "prepend",
|
|
61815
|
+
replace: "replace"
|
|
61816
|
+
};
|
|
61817
|
+
var DataSource = {
|
|
61818
|
+
Cache: "cache",
|
|
61819
|
+
Network: "network",
|
|
61820
|
+
Ssr: "ssr"
|
|
61821
|
+
};
|
|
61822
|
+
|
|
61823
|
+
// src/runtime/lib/store.ts
|
|
61824
|
+
var subscriber_queue = [];
|
|
61825
|
+
var noop = () => {
|
|
61826
|
+
};
|
|
61827
|
+
var Writable = class {
|
|
61828
|
+
state;
|
|
61829
|
+
#subscribers;
|
|
61830
|
+
#stop;
|
|
61831
|
+
#start;
|
|
61832
|
+
constructor(value, start = noop) {
|
|
61833
|
+
this.state = value;
|
|
61834
|
+
this.#subscribers = /* @__PURE__ */ new Set();
|
|
61835
|
+
this.#stop = null;
|
|
61836
|
+
this.#start = start;
|
|
61837
|
+
}
|
|
61838
|
+
set(new_value) {
|
|
61839
|
+
if (safe_not_equal(this.state, new_value)) {
|
|
61840
|
+
this.state = new_value;
|
|
61841
|
+
if (this.#stop) {
|
|
61842
|
+
const run_queue = !subscriber_queue.length;
|
|
61843
|
+
for (const subscriber of this.#subscribers) {
|
|
61844
|
+
subscriber[1]();
|
|
61845
|
+
subscriber_queue.push(subscriber, this.state);
|
|
61846
|
+
}
|
|
61847
|
+
if (run_queue) {
|
|
61848
|
+
for (let i2 = 0; i2 < subscriber_queue.length; i2 += 2) {
|
|
61849
|
+
subscriber_queue[i2][0](subscriber_queue[i2 + 1]);
|
|
61850
|
+
}
|
|
61851
|
+
subscriber_queue.length = 0;
|
|
61852
|
+
}
|
|
61853
|
+
}
|
|
61854
|
+
}
|
|
61855
|
+
}
|
|
61856
|
+
update(fn) {
|
|
61857
|
+
this.set(fn(this.state));
|
|
61858
|
+
}
|
|
61859
|
+
subscribe(run, invalidate = noop) {
|
|
61860
|
+
const subscriber = [run, invalidate];
|
|
61861
|
+
this.#subscribers.add(subscriber);
|
|
61862
|
+
if (this.#subscribers.size === 1) {
|
|
61863
|
+
this.#stop = this.#start(this.set) || noop;
|
|
61864
|
+
}
|
|
61865
|
+
run(this.state);
|
|
61866
|
+
return () => {
|
|
61867
|
+
this.#subscribers.delete(subscriber);
|
|
61868
|
+
if (this.#subscribers.size === 0) {
|
|
61869
|
+
this.#stop?.();
|
|
61870
|
+
this.#stop = null;
|
|
61871
|
+
}
|
|
61872
|
+
};
|
|
61873
|
+
}
|
|
61874
|
+
};
|
|
61875
|
+
function safe_not_equal(a, b) {
|
|
61876
|
+
return a != a ? b == b : a !== b || a && typeof a === "object" || typeof a === "function";
|
|
61877
|
+
}
|
|
61878
|
+
|
|
61879
|
+
// src/runtime/lib/key.ts
|
|
61880
|
+
var computeKey = ({ field, args }) => {
|
|
61881
|
+
const keys = Object.keys(args ?? {});
|
|
61882
|
+
keys.sort();
|
|
61883
|
+
return args && keys.length > 0 ? `${field}(${keys.map((key) => `${key}: ${stringifyObjectWithNoQuotesOnKeys(args[key])}`).join(", ")})` : field;
|
|
61884
|
+
};
|
|
61885
|
+
var stringifyObjectWithNoQuotesOnKeys = (obj_from_json) => {
|
|
61886
|
+
if (Array.isArray(obj_from_json)) {
|
|
61887
|
+
return `[${obj_from_json.map((obj) => `${stringifyObjectWithNoQuotesOnKeys(obj)}`).join(", ")}]`;
|
|
61888
|
+
}
|
|
61889
|
+
if (typeof obj_from_json !== "object" || obj_from_json instanceof Date || obj_from_json === null) {
|
|
61890
|
+
return JSON.stringify(obj_from_json).replace(/"([^"]+)":/g, "$1: ");
|
|
61891
|
+
}
|
|
61892
|
+
return `{${Object.keys(obj_from_json).map((key) => `${key}: ${stringifyObjectWithNoQuotesOnKeys(obj_from_json[key])}`).join(", ")}}`;
|
|
61893
|
+
};
|
|
61644
61894
|
|
|
61645
61895
|
// src/lib/constants.ts
|
|
61646
61896
|
var siteURL = "https://houdinigraphql.com";
|
|
@@ -62086,7 +62336,7 @@ var Body = class {
|
|
|
62086
62336
|
} else if (ArrayBuffer.isView(body)) {
|
|
62087
62337
|
body = import_node_buffer.Buffer.from(body.buffer, body.byteOffset, body.byteLength);
|
|
62088
62338
|
} else if (body instanceof import_node_stream.default) {
|
|
62089
|
-
} else if (body instanceof
|
|
62339
|
+
} else if (body instanceof FormData2) {
|
|
62090
62340
|
body = formDataToBlob(body);
|
|
62091
62341
|
boundary = body.type.split("=")[1];
|
|
62092
62342
|
} else {
|
|
@@ -62126,7 +62376,7 @@ var Body = class {
|
|
|
62126
62376
|
async formData() {
|
|
62127
62377
|
const ct = this.headers.get("content-type");
|
|
62128
62378
|
if (ct.startsWith("application/x-www-form-urlencoded")) {
|
|
62129
|
-
const formData = new
|
|
62379
|
+
const formData = new FormData2();
|
|
62130
62380
|
const parameters = new URLSearchParams(await this.text());
|
|
62131
62381
|
for (const [name, value] of parameters) {
|
|
62132
62382
|
formData.append(name, value);
|
|
@@ -62252,7 +62502,7 @@ var extractContentType = (body, request) => {
|
|
|
62252
62502
|
if (import_node_buffer.Buffer.isBuffer(body) || import_node_util2.types.isAnyArrayBuffer(body) || ArrayBuffer.isView(body)) {
|
|
62253
62503
|
return null;
|
|
62254
62504
|
}
|
|
62255
|
-
if (body instanceof
|
|
62505
|
+
if (body instanceof FormData2) {
|
|
62256
62506
|
return `multipart/form-data; boundary=${request[INTERNALS].boundary}`;
|
|
62257
62507
|
}
|
|
62258
62508
|
if (body && typeof body.getBoundary === "function") {
|
|
@@ -63219,14 +63469,2735 @@ function plugin(name, hooks) {
|
|
|
63219
63469
|
return data;
|
|
63220
63470
|
}
|
|
63221
63471
|
|
|
63472
|
+
// src/runtime/lib/flatten.ts
|
|
63473
|
+
function flatten(source) {
|
|
63474
|
+
if (!source) {
|
|
63475
|
+
return [];
|
|
63476
|
+
}
|
|
63477
|
+
return source.reduce((acc, element) => {
|
|
63478
|
+
if (!element) {
|
|
63479
|
+
return acc;
|
|
63480
|
+
}
|
|
63481
|
+
if (Array.isArray(element)) {
|
|
63482
|
+
return acc.concat(flatten(element));
|
|
63483
|
+
}
|
|
63484
|
+
return acc.concat(element);
|
|
63485
|
+
}, []);
|
|
63486
|
+
}
|
|
63487
|
+
|
|
63488
|
+
// src/runtime/client/plugins/fetch.ts
|
|
63489
|
+
var fetch2 = (target) => {
|
|
63490
|
+
return () => {
|
|
63491
|
+
return {
|
|
63492
|
+
async network(ctx, { client, resolve: resolve2, marshalVariables: marshalVariables2 }) {
|
|
63493
|
+
const fetch3 = ctx.fetch ?? globalThis.fetch;
|
|
63494
|
+
const fetchParams2 = {
|
|
63495
|
+
text: ctx.text,
|
|
63496
|
+
hash: ctx.hash,
|
|
63497
|
+
variables: marshalVariables2(ctx)
|
|
63498
|
+
};
|
|
63499
|
+
let fetchFn = defaultFetch(client.url, ctx.fetchParams);
|
|
63500
|
+
if (target) {
|
|
63501
|
+
if (typeof target === "string") {
|
|
63502
|
+
fetchFn = defaultFetch(target, ctx.fetchParams);
|
|
63503
|
+
} else {
|
|
63504
|
+
fetchFn = target;
|
|
63505
|
+
}
|
|
63506
|
+
}
|
|
63507
|
+
const result = await fetchFn({
|
|
63508
|
+
fetch: (url, args) => {
|
|
63509
|
+
const newArgs = handleMultipart(fetchParams2, args) ?? args;
|
|
63510
|
+
return fetch3(url, newArgs);
|
|
63511
|
+
},
|
|
63512
|
+
metadata: ctx.metadata,
|
|
63513
|
+
session: ctx.session || {},
|
|
63514
|
+
...fetchParams2
|
|
63515
|
+
});
|
|
63516
|
+
resolve2(ctx, {
|
|
63517
|
+
fetching: false,
|
|
63518
|
+
variables: ctx.variables ?? {},
|
|
63519
|
+
data: result.data,
|
|
63520
|
+
errors: !result.errors || result.errors.length === 0 ? null : result.errors,
|
|
63521
|
+
partial: false,
|
|
63522
|
+
stale: false,
|
|
63523
|
+
source: DataSource.Network
|
|
63524
|
+
});
|
|
63525
|
+
}
|
|
63526
|
+
};
|
|
63527
|
+
};
|
|
63528
|
+
};
|
|
63529
|
+
var defaultFetch = (url, params) => {
|
|
63530
|
+
if (!url) {
|
|
63531
|
+
throw new Error(
|
|
63532
|
+
"Could not find configured client url. Please specify one in your HoudiniClient constructor."
|
|
63533
|
+
);
|
|
63534
|
+
}
|
|
63535
|
+
return async ({ fetch: fetch3, text, variables }) => {
|
|
63536
|
+
const result = await fetch3(url, {
|
|
63537
|
+
method: "POST",
|
|
63538
|
+
body: JSON.stringify({ query: text, variables }),
|
|
63539
|
+
...params,
|
|
63540
|
+
headers: {
|
|
63541
|
+
Accept: "application/graphql+json, application/json",
|
|
63542
|
+
"Content-Type": "application/json",
|
|
63543
|
+
...params?.headers
|
|
63544
|
+
}
|
|
63545
|
+
});
|
|
63546
|
+
return await result.json();
|
|
63547
|
+
};
|
|
63548
|
+
};
|
|
63549
|
+
function handleMultipart(params, args) {
|
|
63550
|
+
const { clone: clone2, files } = extractFiles({
|
|
63551
|
+
query: params.text,
|
|
63552
|
+
variables: params.variables
|
|
63553
|
+
});
|
|
63554
|
+
if (files.size) {
|
|
63555
|
+
const req = args;
|
|
63556
|
+
let headers = {};
|
|
63557
|
+
if (req?.headers) {
|
|
63558
|
+
const filtered = Object.entries(req?.headers).filter(([key, value]) => {
|
|
63559
|
+
return !(key.toLowerCase() == "content-type" && value.toLowerCase() == "application/json");
|
|
63560
|
+
});
|
|
63561
|
+
headers = Object.fromEntries(filtered);
|
|
63562
|
+
}
|
|
63563
|
+
const form = new FormData();
|
|
63564
|
+
const operationJSON = JSON.stringify(clone2);
|
|
63565
|
+
form.set("operations", operationJSON);
|
|
63566
|
+
const map = {};
|
|
63567
|
+
let i2 = 0;
|
|
63568
|
+
files.forEach((paths) => {
|
|
63569
|
+
map[++i2] = paths;
|
|
63570
|
+
});
|
|
63571
|
+
form.set("map", JSON.stringify(map));
|
|
63572
|
+
i2 = 0;
|
|
63573
|
+
files.forEach((paths, file) => {
|
|
63574
|
+
form.set(`${++i2}`, file, file.name);
|
|
63575
|
+
});
|
|
63576
|
+
return { ...req, headers, body: form };
|
|
63577
|
+
}
|
|
63578
|
+
}
|
|
63579
|
+
function isExtractableFile(value) {
|
|
63580
|
+
return typeof File !== "undefined" && value instanceof File || typeof Blob !== "undefined" && value instanceof Blob;
|
|
63581
|
+
}
|
|
63582
|
+
function extractFiles(value) {
|
|
63583
|
+
if (!arguments.length)
|
|
63584
|
+
throw new TypeError("Argument 1 `value` is required.");
|
|
63585
|
+
const clones = /* @__PURE__ */ new Map();
|
|
63586
|
+
const files = /* @__PURE__ */ new Map();
|
|
63587
|
+
function recurse(value2, path2, recursed) {
|
|
63588
|
+
if (isExtractableFile(value2)) {
|
|
63589
|
+
const filePaths = files.get(value2);
|
|
63590
|
+
filePaths ? filePaths.push(path2) : files.set(value2, [path2]);
|
|
63591
|
+
return null;
|
|
63592
|
+
}
|
|
63593
|
+
const valueIsList = Array.isArray(value2) || typeof FileList !== "undefined" && value2 instanceof FileList;
|
|
63594
|
+
const valueIsPlainObject = isPlainObject(value2);
|
|
63595
|
+
if (valueIsList || valueIsPlainObject) {
|
|
63596
|
+
let clone2 = clones.get(value2);
|
|
63597
|
+
const uncloned = !clone2;
|
|
63598
|
+
if (uncloned) {
|
|
63599
|
+
clone2 = valueIsList ? [] : value2 instanceof Object ? {} : /* @__PURE__ */ Object.create(null);
|
|
63600
|
+
clones.set(value2, clone2);
|
|
63601
|
+
}
|
|
63602
|
+
if (!recursed.has(value2)) {
|
|
63603
|
+
const pathPrefix = path2 ? `${path2}.` : "";
|
|
63604
|
+
const recursedDeeper = new Set(recursed).add(value2);
|
|
63605
|
+
if (valueIsList) {
|
|
63606
|
+
let index = 0;
|
|
63607
|
+
for (const item of value2) {
|
|
63608
|
+
const itemClone = recurse(item, pathPrefix + index++, recursedDeeper);
|
|
63609
|
+
if (uncloned)
|
|
63610
|
+
clone2.push(itemClone);
|
|
63611
|
+
}
|
|
63612
|
+
} else
|
|
63613
|
+
for (const key in value2) {
|
|
63614
|
+
const propertyClone = recurse(value2[key], pathPrefix + key, recursedDeeper);
|
|
63615
|
+
if (uncloned)
|
|
63616
|
+
clone2[key] = propertyClone;
|
|
63617
|
+
}
|
|
63618
|
+
}
|
|
63619
|
+
return clone2;
|
|
63620
|
+
}
|
|
63621
|
+
return value2;
|
|
63622
|
+
}
|
|
63623
|
+
return {
|
|
63624
|
+
clone: recurse(value, "", /* @__PURE__ */ new Set()),
|
|
63625
|
+
files
|
|
63626
|
+
};
|
|
63627
|
+
}
|
|
63628
|
+
function isPlainObject(value) {
|
|
63629
|
+
if (typeof value !== "object" || value === null) {
|
|
63630
|
+
return false;
|
|
63631
|
+
}
|
|
63632
|
+
const prototype = Object.getPrototypeOf(value);
|
|
63633
|
+
return (prototype === null || prototype === Object.prototype || Object.getPrototypeOf(prototype) === null) && !(Symbol.toStringTag in value) && !(Symbol.iterator in value);
|
|
63634
|
+
}
|
|
63635
|
+
|
|
63636
|
+
// src/runtime/cache/gc.ts
|
|
63637
|
+
var GarbageCollector = class {
|
|
63638
|
+
cache;
|
|
63639
|
+
lifetimes = /* @__PURE__ */ new Map();
|
|
63640
|
+
get cacheBufferSize() {
|
|
63641
|
+
return this.cache._internal_unstable.config.cacheBufferSize ?? 10;
|
|
63642
|
+
}
|
|
63643
|
+
constructor(cache) {
|
|
63644
|
+
this.cache = cache;
|
|
63645
|
+
}
|
|
63646
|
+
resetLifetime(id, field) {
|
|
63647
|
+
if (!this.lifetimes.get(id)) {
|
|
63648
|
+
this.lifetimes.set(id, /* @__PURE__ */ new Map());
|
|
63649
|
+
}
|
|
63650
|
+
this.lifetimes.get(id).set(field, 0);
|
|
63651
|
+
}
|
|
63652
|
+
tick() {
|
|
63653
|
+
const dt_tick = Date.now().valueOf();
|
|
63654
|
+
const config_max_time = this.cache._internal_unstable.config.defaultLifetime;
|
|
63655
|
+
for (const [id, fieldMap] of this.lifetimes.entries()) {
|
|
63656
|
+
for (const [field, lifetime] of fieldMap.entries()) {
|
|
63657
|
+
if (this.cache._internal_unstable.subscriptions.get(id, field).length > 0) {
|
|
63658
|
+
continue;
|
|
63659
|
+
}
|
|
63660
|
+
fieldMap.set(field, lifetime + 1);
|
|
63661
|
+
if (fieldMap.get(field) > this.cacheBufferSize) {
|
|
63662
|
+
this.cache._internal_unstable.storage.deleteField(id, field);
|
|
63663
|
+
this.cache._internal_unstable.lists.deleteField(id, field);
|
|
63664
|
+
fieldMap.delete(field);
|
|
63665
|
+
if ([...fieldMap.keys()].length === 0) {
|
|
63666
|
+
this.lifetimes.delete(id);
|
|
63667
|
+
}
|
|
63668
|
+
this.cache._internal_unstable.staleManager.delete(id, field);
|
|
63669
|
+
}
|
|
63670
|
+
if (config_max_time && config_max_time > 0) {
|
|
63671
|
+
const dt_valueOf = this.cache.getFieldTime(id, field);
|
|
63672
|
+
if (dt_valueOf && dt_tick - dt_valueOf > config_max_time) {
|
|
63673
|
+
this.cache._internal_unstable.staleManager.markFieldStale(id, field);
|
|
63674
|
+
}
|
|
63675
|
+
}
|
|
63676
|
+
}
|
|
63677
|
+
}
|
|
63678
|
+
}
|
|
63679
|
+
};
|
|
63680
|
+
|
|
63681
|
+
// src/runtime/cache/lists.ts
|
|
63682
|
+
var ListManager = class {
|
|
63683
|
+
rootID;
|
|
63684
|
+
cache;
|
|
63685
|
+
constructor(cache, rootID2) {
|
|
63686
|
+
this.rootID = rootID2;
|
|
63687
|
+
this.cache = cache;
|
|
63688
|
+
}
|
|
63689
|
+
lists = /* @__PURE__ */ new Map();
|
|
63690
|
+
listsByField = /* @__PURE__ */ new Map();
|
|
63691
|
+
get(listName, id, allLists) {
|
|
63692
|
+
const matches = this.lists.get(listName);
|
|
63693
|
+
if (!matches || matches.size === 0) {
|
|
63694
|
+
return null;
|
|
63695
|
+
}
|
|
63696
|
+
if (allLists) {
|
|
63697
|
+
return new ListCollection(
|
|
63698
|
+
Array.from(matches, ([key, value]) => [...value.lists]).flat()
|
|
63699
|
+
);
|
|
63700
|
+
}
|
|
63701
|
+
const head = [...matches.values()][0];
|
|
63702
|
+
const { recordType } = head.lists[0];
|
|
63703
|
+
const parentID = id ? this.cache._internal_unstable.id(recordType || "", id) : this.rootID;
|
|
63704
|
+
if (matches?.size === 1) {
|
|
63705
|
+
if (!id) {
|
|
63706
|
+
return head;
|
|
63707
|
+
}
|
|
63708
|
+
return parentID === Array.from(matches.keys())[0] ? head : null;
|
|
63709
|
+
}
|
|
63710
|
+
if (!id) {
|
|
63711
|
+
console.error(
|
|
63712
|
+
`Found multiple instances of "${listName}". Please provide one of @parentID or @allLists directives to help identify which list you want modify. For more information, visit this guide: https://www.houdinigraphql.com/api/graphql#parentidvalue-string `
|
|
63713
|
+
);
|
|
63714
|
+
return null;
|
|
63715
|
+
}
|
|
63716
|
+
return this.lists.get(listName)?.get(parentID);
|
|
63717
|
+
}
|
|
63718
|
+
remove(listName, id) {
|
|
63719
|
+
this.lists.get(listName)?.delete(id || this.rootID);
|
|
63720
|
+
}
|
|
63721
|
+
add(list) {
|
|
63722
|
+
if (!this.lists.has(list.name)) {
|
|
63723
|
+
this.lists.set(list.name, /* @__PURE__ */ new Map());
|
|
63724
|
+
}
|
|
63725
|
+
const name = list.name;
|
|
63726
|
+
const parentID = list.recordID || this.rootID;
|
|
63727
|
+
if (this.lists.get(name)?.get(parentID)?.includes(list.key)) {
|
|
63728
|
+
return;
|
|
63729
|
+
}
|
|
63730
|
+
if (!this.lists.has(name)) {
|
|
63731
|
+
this.lists.set(name, /* @__PURE__ */ new Map());
|
|
63732
|
+
}
|
|
63733
|
+
if (!this.lists.get(name).has(parentID)) {
|
|
63734
|
+
this.lists.get(name).set(parentID, new ListCollection([]));
|
|
63735
|
+
}
|
|
63736
|
+
if (!this.listsByField.has(parentID)) {
|
|
63737
|
+
this.listsByField.set(parentID, /* @__PURE__ */ new Map());
|
|
63738
|
+
}
|
|
63739
|
+
if (!this.listsByField.get(parentID).has(list.key)) {
|
|
63740
|
+
this.listsByField.get(parentID)?.set(list.key, []);
|
|
63741
|
+
}
|
|
63742
|
+
const handler = new List({ ...list, manager: this });
|
|
63743
|
+
this.lists.get(list.name).get(parentID).lists.push(handler);
|
|
63744
|
+
this.listsByField.get(parentID).get(list.key).push(handler);
|
|
63745
|
+
}
|
|
63746
|
+
removeIDFromAllLists(id) {
|
|
63747
|
+
for (const fieldMap of this.lists.values()) {
|
|
63748
|
+
for (const list of fieldMap.values()) {
|
|
63749
|
+
list.removeID(id);
|
|
63750
|
+
}
|
|
63751
|
+
}
|
|
63752
|
+
}
|
|
63753
|
+
deleteField(parentID, field) {
|
|
63754
|
+
if (!this.listsByField.get(parentID)?.has(field)) {
|
|
63755
|
+
return;
|
|
63756
|
+
}
|
|
63757
|
+
for (const list of this.listsByField.get(parentID).get(field)) {
|
|
63758
|
+
this.lists.get(list.name)?.get(list.recordID)?.deleteListWithKey(field);
|
|
63759
|
+
if (this.lists.get(list.name)?.get(list.recordID)?.lists.length === 0) {
|
|
63760
|
+
this.lists.get(list.name)?.delete(list.recordID);
|
|
63761
|
+
}
|
|
63762
|
+
}
|
|
63763
|
+
this.listsByField.get(parentID).delete(field);
|
|
63764
|
+
}
|
|
63765
|
+
};
|
|
63766
|
+
var List = class {
|
|
63767
|
+
recordID;
|
|
63768
|
+
recordType;
|
|
63769
|
+
key;
|
|
63770
|
+
type;
|
|
63771
|
+
cache;
|
|
63772
|
+
selection;
|
|
63773
|
+
_when;
|
|
63774
|
+
filters;
|
|
63775
|
+
name;
|
|
63776
|
+
connection;
|
|
63777
|
+
manager;
|
|
63778
|
+
abstract;
|
|
63779
|
+
constructor({
|
|
63780
|
+
name,
|
|
63781
|
+
recordID,
|
|
63782
|
+
recordType,
|
|
63783
|
+
key,
|
|
63784
|
+
listType,
|
|
63785
|
+
selection,
|
|
63786
|
+
when,
|
|
63787
|
+
filters,
|
|
63788
|
+
connection,
|
|
63789
|
+
manager,
|
|
63790
|
+
abstract
|
|
63791
|
+
}) {
|
|
63792
|
+
this.recordID = recordID || rootID;
|
|
63793
|
+
this.recordType = recordType;
|
|
63794
|
+
this.key = key;
|
|
63795
|
+
this.type = listType;
|
|
63796
|
+
this.cache = manager.cache;
|
|
63797
|
+
this.selection = selection;
|
|
63798
|
+
this._when = when;
|
|
63799
|
+
this.filters = filters;
|
|
63800
|
+
this.name = name;
|
|
63801
|
+
this.connection = connection;
|
|
63802
|
+
this.manager = manager;
|
|
63803
|
+
this.abstract = abstract;
|
|
63804
|
+
}
|
|
63805
|
+
when(when) {
|
|
63806
|
+
return this.manager.lists.get(this.name).get(this.recordID).when(when);
|
|
63807
|
+
}
|
|
63808
|
+
append(selection, data, variables = {}) {
|
|
63809
|
+
return this.addToList(selection, data, variables, "last");
|
|
63810
|
+
}
|
|
63811
|
+
prepend(selection, data, variables = {}) {
|
|
63812
|
+
return this.addToList(selection, data, variables, "first");
|
|
63813
|
+
}
|
|
63814
|
+
addToList(selection, data, variables = {}, where) {
|
|
63815
|
+
const listType = this.listType(data);
|
|
63816
|
+
const dataID = this.cache._internal_unstable.id(listType, data);
|
|
63817
|
+
if (!this.validateWhen() || !dataID) {
|
|
63818
|
+
return;
|
|
63819
|
+
}
|
|
63820
|
+
let insertSelection = selection;
|
|
63821
|
+
let insertData = data;
|
|
63822
|
+
if (this.connection) {
|
|
63823
|
+
insertSelection = {
|
|
63824
|
+
fields: {
|
|
63825
|
+
newEntry: {
|
|
63826
|
+
keyRaw: this.key,
|
|
63827
|
+
type: "Connection",
|
|
63828
|
+
selection: {
|
|
63829
|
+
fields: {
|
|
63830
|
+
edges: {
|
|
63831
|
+
keyRaw: "edges",
|
|
63832
|
+
type: "ConnectionEdge",
|
|
63833
|
+
updates: ["append", "prepend"],
|
|
63834
|
+
selection: {
|
|
63835
|
+
fields: {
|
|
63836
|
+
node: {
|
|
63837
|
+
type: listType,
|
|
63838
|
+
keyRaw: "node",
|
|
63839
|
+
selection: {
|
|
63840
|
+
...selection,
|
|
63841
|
+
fields: {
|
|
63842
|
+
...selection.fields,
|
|
63843
|
+
__typename: {
|
|
63844
|
+
keyRaw: "__typename",
|
|
63845
|
+
type: "String"
|
|
63846
|
+
}
|
|
63847
|
+
}
|
|
63848
|
+
}
|
|
63849
|
+
}
|
|
63850
|
+
}
|
|
63851
|
+
}
|
|
63852
|
+
}
|
|
63853
|
+
}
|
|
63854
|
+
}
|
|
63855
|
+
}
|
|
63856
|
+
}
|
|
63857
|
+
};
|
|
63858
|
+
insertData = {
|
|
63859
|
+
newEntry: {
|
|
63860
|
+
edges: [{ node: { ...data, __typename: listType } }]
|
|
63861
|
+
}
|
|
63862
|
+
};
|
|
63863
|
+
} else {
|
|
63864
|
+
insertSelection = {
|
|
63865
|
+
fields: {
|
|
63866
|
+
newEntries: {
|
|
63867
|
+
keyRaw: this.key,
|
|
63868
|
+
type: listType,
|
|
63869
|
+
updates: ["append", "prepend"],
|
|
63870
|
+
selection: {
|
|
63871
|
+
...selection,
|
|
63872
|
+
fields: {
|
|
63873
|
+
...selection.fields,
|
|
63874
|
+
__typename: {
|
|
63875
|
+
keyRaw: "__typename",
|
|
63876
|
+
type: "String"
|
|
63877
|
+
}
|
|
63878
|
+
}
|
|
63879
|
+
}
|
|
63880
|
+
}
|
|
63881
|
+
}
|
|
63882
|
+
};
|
|
63883
|
+
insertData = {
|
|
63884
|
+
newEntries: [{ ...data, __typename: listType }]
|
|
63885
|
+
};
|
|
63886
|
+
}
|
|
63887
|
+
this.cache.write({
|
|
63888
|
+
selection: insertSelection,
|
|
63889
|
+
data: insertData,
|
|
63890
|
+
variables,
|
|
63891
|
+
parent: this.recordID,
|
|
63892
|
+
applyUpdates: [where === "first" ? "prepend" : "append"]
|
|
63893
|
+
});
|
|
63894
|
+
}
|
|
63895
|
+
removeID(id, variables = {}) {
|
|
63896
|
+
if (!this.validateWhen()) {
|
|
63897
|
+
return;
|
|
63898
|
+
}
|
|
63899
|
+
let parentID = this.recordID;
|
|
63900
|
+
let targetID = id;
|
|
63901
|
+
let targetKey = this.key;
|
|
63902
|
+
if (this.connection) {
|
|
63903
|
+
const { value: embeddedConnection } = this.cache._internal_unstable.storage.get(
|
|
63904
|
+
this.recordID,
|
|
63905
|
+
this.key
|
|
63906
|
+
);
|
|
63907
|
+
if (!embeddedConnection) {
|
|
63908
|
+
return;
|
|
63909
|
+
}
|
|
63910
|
+
const embeddedConnectionID = embeddedConnection;
|
|
63911
|
+
const { value: edges } = this.cache._internal_unstable.storage.get(
|
|
63912
|
+
embeddedConnectionID,
|
|
63913
|
+
"edges"
|
|
63914
|
+
);
|
|
63915
|
+
for (const edge of flatten(edges) || []) {
|
|
63916
|
+
if (!edge) {
|
|
63917
|
+
continue;
|
|
63918
|
+
}
|
|
63919
|
+
const edgeID = edge;
|
|
63920
|
+
const { value: nodeID } = this.cache._internal_unstable.storage.get(edgeID, "node");
|
|
63921
|
+
if (!nodeID) {
|
|
63922
|
+
continue;
|
|
63923
|
+
}
|
|
63924
|
+
if (nodeID === id) {
|
|
63925
|
+
targetID = edgeID;
|
|
63926
|
+
}
|
|
63927
|
+
}
|
|
63928
|
+
parentID = embeddedConnectionID;
|
|
63929
|
+
targetKey = "edges";
|
|
63930
|
+
}
|
|
63931
|
+
let value = this.cache._internal_unstable.storage.get(parentID, targetKey).value;
|
|
63932
|
+
if (!value || !value.includes(targetID)) {
|
|
63933
|
+
return;
|
|
63934
|
+
}
|
|
63935
|
+
const subscribers = this.cache._internal_unstable.subscriptions.get(this.recordID, this.key);
|
|
63936
|
+
this.cache._internal_unstable.subscriptions.remove(
|
|
63937
|
+
targetID,
|
|
63938
|
+
this.connection ? this.selection.fields.edges.selection : this.selection,
|
|
63939
|
+
subscribers.map((sub) => sub[0]),
|
|
63940
|
+
variables
|
|
63941
|
+
);
|
|
63942
|
+
this.cache._internal_unstable.storage.remove(parentID, targetKey, targetID);
|
|
63943
|
+
for (const [spec] of subscribers) {
|
|
63944
|
+
spec.set(
|
|
63945
|
+
this.cache._internal_unstable.getSelection({
|
|
63946
|
+
parent: spec.parentID || this.manager.rootID,
|
|
63947
|
+
selection: spec.selection,
|
|
63948
|
+
variables: spec.variables?.() || {}
|
|
63949
|
+
}).data
|
|
63950
|
+
);
|
|
63951
|
+
}
|
|
63952
|
+
return true;
|
|
63953
|
+
}
|
|
63954
|
+
remove(data, variables = {}) {
|
|
63955
|
+
const targetID = this.cache._internal_unstable.id(this.listType(data), data);
|
|
63956
|
+
if (!targetID) {
|
|
63957
|
+
return;
|
|
63958
|
+
}
|
|
63959
|
+
return this.removeID(targetID, variables);
|
|
63960
|
+
}
|
|
63961
|
+
listType(data) {
|
|
63962
|
+
return data.__typename || this.type;
|
|
63963
|
+
}
|
|
63964
|
+
validateWhen(when) {
|
|
63965
|
+
let filters = when || this._when;
|
|
63966
|
+
let ok = true;
|
|
63967
|
+
if (filters) {
|
|
63968
|
+
const targets = this.filters;
|
|
63969
|
+
if (filters.must && targets) {
|
|
63970
|
+
ok = Object.entries(filters.must).reduce(
|
|
63971
|
+
(prev, [key, value]) => Boolean(prev && targets[key] == value),
|
|
63972
|
+
ok
|
|
63973
|
+
);
|
|
63974
|
+
}
|
|
63975
|
+
if (filters.must_not) {
|
|
63976
|
+
ok = !targets || Object.entries(filters.must_not).reduce(
|
|
63977
|
+
(prev, [key, value]) => Boolean(prev && targets[key] != value),
|
|
63978
|
+
ok
|
|
63979
|
+
);
|
|
63980
|
+
}
|
|
63981
|
+
}
|
|
63982
|
+
return ok;
|
|
63983
|
+
}
|
|
63984
|
+
toggleElement(selection, data, variables = {}, where) {
|
|
63985
|
+
if (!this.remove(data, variables)) {
|
|
63986
|
+
this.addToList(selection, data, variables, where);
|
|
63987
|
+
}
|
|
63988
|
+
}
|
|
63989
|
+
*[Symbol.iterator]() {
|
|
63990
|
+
let entries = [];
|
|
63991
|
+
let value = this.cache._internal_unstable.storage.get(this.recordID, this.key).value;
|
|
63992
|
+
if (!this.connection) {
|
|
63993
|
+
entries = flatten(value);
|
|
63994
|
+
} else {
|
|
63995
|
+
entries = this.cache._internal_unstable.storage.get(value, "edges").value;
|
|
63996
|
+
}
|
|
63997
|
+
for (let record of entries) {
|
|
63998
|
+
yield record;
|
|
63999
|
+
}
|
|
64000
|
+
}
|
|
64001
|
+
};
|
|
64002
|
+
var ListCollection = class {
|
|
64003
|
+
lists = [];
|
|
64004
|
+
constructor(lists) {
|
|
64005
|
+
this.lists = lists;
|
|
64006
|
+
}
|
|
64007
|
+
get selection() {
|
|
64008
|
+
return this.lists[0].selection;
|
|
64009
|
+
}
|
|
64010
|
+
append(...args) {
|
|
64011
|
+
this.lists.forEach((list) => list.append(...args));
|
|
64012
|
+
}
|
|
64013
|
+
prepend(...args) {
|
|
64014
|
+
this.lists.forEach((list) => list.prepend(...args));
|
|
64015
|
+
}
|
|
64016
|
+
addToList(...args) {
|
|
64017
|
+
this.lists.forEach((list) => list.addToList(...args));
|
|
64018
|
+
}
|
|
64019
|
+
removeID(...args) {
|
|
64020
|
+
this.lists.forEach((list) => list.removeID(...args));
|
|
64021
|
+
}
|
|
64022
|
+
remove(...args) {
|
|
64023
|
+
this.lists.forEach((list) => list.remove(...args));
|
|
64024
|
+
}
|
|
64025
|
+
toggleElement(...args) {
|
|
64026
|
+
this.lists.forEach((list) => list.toggleElement(...args));
|
|
64027
|
+
}
|
|
64028
|
+
when(when) {
|
|
64029
|
+
return new ListCollection(
|
|
64030
|
+
this.lists.filter((list) => {
|
|
64031
|
+
return list.validateWhen(when);
|
|
64032
|
+
})
|
|
64033
|
+
);
|
|
64034
|
+
}
|
|
64035
|
+
includes(key) {
|
|
64036
|
+
return !!this.lists.find((list) => list.key === key);
|
|
64037
|
+
}
|
|
64038
|
+
deleteListWithKey(key) {
|
|
64039
|
+
return this.lists = this.lists.filter((list) => list.key !== key);
|
|
64040
|
+
}
|
|
64041
|
+
*[Symbol.iterator]() {
|
|
64042
|
+
for (let list of this.lists) {
|
|
64043
|
+
for (const entry of list) {
|
|
64044
|
+
yield entry;
|
|
64045
|
+
}
|
|
64046
|
+
}
|
|
64047
|
+
}
|
|
64048
|
+
};
|
|
64049
|
+
|
|
64050
|
+
// src/runtime/cache/schema.ts
|
|
64051
|
+
var SchemaManager = class {
|
|
64052
|
+
cache;
|
|
64053
|
+
fieldTypes = {};
|
|
64054
|
+
constructor(cache) {
|
|
64055
|
+
this.cache = cache;
|
|
64056
|
+
}
|
|
64057
|
+
setFieldType({
|
|
64058
|
+
parent,
|
|
64059
|
+
key,
|
|
64060
|
+
type,
|
|
64061
|
+
nullable = false,
|
|
64062
|
+
link
|
|
64063
|
+
}) {
|
|
64064
|
+
let parensIndex = key.indexOf("(");
|
|
64065
|
+
if (parensIndex !== -1) {
|
|
64066
|
+
key = key.substring(0, parensIndex);
|
|
64067
|
+
}
|
|
64068
|
+
if (parent === rootID) {
|
|
64069
|
+
parent = "Query";
|
|
64070
|
+
} else if (parent.includes(":")) {
|
|
64071
|
+
parent = parent.substring(0, parent.indexOf(":"));
|
|
64072
|
+
}
|
|
64073
|
+
if (!this.fieldTypes[parent]) {
|
|
64074
|
+
this.fieldTypes[parent] = {};
|
|
64075
|
+
}
|
|
64076
|
+
this.fieldTypes[parent][key] = {
|
|
64077
|
+
type,
|
|
64078
|
+
nullable,
|
|
64079
|
+
link: !!link
|
|
64080
|
+
};
|
|
64081
|
+
}
|
|
64082
|
+
fieldType(type, field) {
|
|
64083
|
+
return this.fieldTypes[type]?.[field] || null;
|
|
64084
|
+
}
|
|
64085
|
+
get config() {
|
|
64086
|
+
return this.cache._internal_unstable.config;
|
|
64087
|
+
}
|
|
64088
|
+
};
|
|
64089
|
+
|
|
64090
|
+
// src/runtime/cache/staleManager.ts
|
|
64091
|
+
var StaleManager = class {
|
|
64092
|
+
cache;
|
|
64093
|
+
fieldsTime = /* @__PURE__ */ new Map();
|
|
64094
|
+
constructor(cache) {
|
|
64095
|
+
this.cache = cache;
|
|
64096
|
+
}
|
|
64097
|
+
#initMapId = (id) => {
|
|
64098
|
+
if (!this.fieldsTime.get(id)) {
|
|
64099
|
+
this.fieldsTime.set(id, /* @__PURE__ */ new Map());
|
|
64100
|
+
}
|
|
64101
|
+
};
|
|
64102
|
+
getFieldTime(id, field) {
|
|
64103
|
+
return this.fieldsTime.get(id)?.get(field);
|
|
64104
|
+
}
|
|
64105
|
+
setFieldTimeToNow(id, field) {
|
|
64106
|
+
this.#initMapId(id);
|
|
64107
|
+
this.fieldsTime.get(id)?.set(field, new Date().valueOf());
|
|
64108
|
+
}
|
|
64109
|
+
markFieldStale(id, field) {
|
|
64110
|
+
this.#initMapId(id);
|
|
64111
|
+
this.fieldsTime.get(id)?.set(field, null);
|
|
64112
|
+
}
|
|
64113
|
+
markAllStale() {
|
|
64114
|
+
for (const [id, fieldMap] of this.fieldsTime.entries()) {
|
|
64115
|
+
for (const [field] of fieldMap.entries()) {
|
|
64116
|
+
this.markFieldStale(id, field);
|
|
64117
|
+
}
|
|
64118
|
+
}
|
|
64119
|
+
}
|
|
64120
|
+
markRecordStale(id) {
|
|
64121
|
+
const fieldsTimeOfType = this.fieldsTime.get(id);
|
|
64122
|
+
if (fieldsTimeOfType) {
|
|
64123
|
+
for (const [field] of fieldsTimeOfType.entries()) {
|
|
64124
|
+
this.markFieldStale(id, field);
|
|
64125
|
+
}
|
|
64126
|
+
}
|
|
64127
|
+
}
|
|
64128
|
+
markTypeStale(type) {
|
|
64129
|
+
for (const [id, fieldMap] of this.fieldsTime.entries()) {
|
|
64130
|
+
if (id.startsWith(`${type}:`)) {
|
|
64131
|
+
for (const [field] of fieldMap.entries()) {
|
|
64132
|
+
this.markFieldStale(id, field);
|
|
64133
|
+
}
|
|
64134
|
+
}
|
|
64135
|
+
}
|
|
64136
|
+
}
|
|
64137
|
+
markTypeFieldStale(type, field, when) {
|
|
64138
|
+
const key = computeKey({ field, args: when });
|
|
64139
|
+
for (const [id, fieldMap] of this.fieldsTime.entries()) {
|
|
64140
|
+
if (id.startsWith(`${type}:`)) {
|
|
64141
|
+
for (const local_field of fieldMap.keys()) {
|
|
64142
|
+
if (local_field === key) {
|
|
64143
|
+
this.markFieldStale(id, field);
|
|
64144
|
+
}
|
|
64145
|
+
}
|
|
64146
|
+
}
|
|
64147
|
+
}
|
|
64148
|
+
}
|
|
64149
|
+
delete(id, field) {
|
|
64150
|
+
if (this.fieldsTime.has(id)) {
|
|
64151
|
+
this.fieldsTime.get(id)?.delete(field);
|
|
64152
|
+
if (this.fieldsTime.get(id)?.size === 0) {
|
|
64153
|
+
this.fieldsTime.delete(id);
|
|
64154
|
+
}
|
|
64155
|
+
}
|
|
64156
|
+
}
|
|
64157
|
+
};
|
|
64158
|
+
|
|
64159
|
+
// src/runtime/cache/storage.ts
|
|
64160
|
+
var InMemoryStorage = class {
|
|
64161
|
+
data;
|
|
64162
|
+
idCount = 0;
|
|
64163
|
+
rank = 0;
|
|
64164
|
+
constructor() {
|
|
64165
|
+
this.data = [];
|
|
64166
|
+
}
|
|
64167
|
+
get layerCount() {
|
|
64168
|
+
return this.data.length;
|
|
64169
|
+
}
|
|
64170
|
+
get nextRank() {
|
|
64171
|
+
return this.rank++;
|
|
64172
|
+
}
|
|
64173
|
+
createLayer(optimistic = false) {
|
|
64174
|
+
const layer = new Layer(this.idCount++);
|
|
64175
|
+
layer.optimistic = optimistic;
|
|
64176
|
+
this.data.push(layer);
|
|
64177
|
+
return layer;
|
|
64178
|
+
}
|
|
64179
|
+
insert(id, field, location, target) {
|
|
64180
|
+
return this.topLayer.insert(id, field, location, target);
|
|
64181
|
+
}
|
|
64182
|
+
remove(id, field, target) {
|
|
64183
|
+
return this.topLayer.remove(id, field, target);
|
|
64184
|
+
}
|
|
64185
|
+
delete(id) {
|
|
64186
|
+
return this.topLayer.delete(id);
|
|
64187
|
+
}
|
|
64188
|
+
deleteField(id, field) {
|
|
64189
|
+
return this.topLayer.deleteField(id, field);
|
|
64190
|
+
}
|
|
64191
|
+
getLayer(id) {
|
|
64192
|
+
for (const layer of this.data) {
|
|
64193
|
+
if (layer.id === id) {
|
|
64194
|
+
return layer;
|
|
64195
|
+
}
|
|
64196
|
+
}
|
|
64197
|
+
throw new Error("Could not find layer with id: " + id);
|
|
64198
|
+
}
|
|
64199
|
+
replaceID(replacement) {
|
|
64200
|
+
for (const layer of this.data) {
|
|
64201
|
+
layer.replaceID(replacement);
|
|
64202
|
+
}
|
|
64203
|
+
}
|
|
64204
|
+
get(id, field) {
|
|
64205
|
+
const operations = {
|
|
64206
|
+
[OperationKind.insert]: {
|
|
64207
|
+
[OperationLocation.start]: [],
|
|
64208
|
+
[OperationLocation.end]: []
|
|
64209
|
+
},
|
|
64210
|
+
[OperationKind.remove]: /* @__PURE__ */ new Set()
|
|
64211
|
+
};
|
|
64212
|
+
const layerIDs = [];
|
|
64213
|
+
for (let i2 = this.data.length - 1; i2 >= 0; i2--) {
|
|
64214
|
+
const layer = this.data[i2];
|
|
64215
|
+
const [layerValue, kind] = layer.get(id, field);
|
|
64216
|
+
const layerOperations = layer.getOperations(id, field) || [];
|
|
64217
|
+
layer.deletedIDs.forEach((v) => {
|
|
64218
|
+
if (layer.operations[v]?.undoDeletesInList?.includes(field)) {
|
|
64219
|
+
return;
|
|
64220
|
+
}
|
|
64221
|
+
operations.remove.add(v);
|
|
64222
|
+
});
|
|
64223
|
+
if (typeof layerValue === "undefined" && layerOperations.length === 0) {
|
|
64224
|
+
if (layer.deletedIDs.size > 0) {
|
|
64225
|
+
layerIDs.push(layer.id);
|
|
64226
|
+
}
|
|
64227
|
+
continue;
|
|
64228
|
+
}
|
|
64229
|
+
if (typeof layerValue !== "undefined" && !Array.isArray(layerValue)) {
|
|
64230
|
+
return {
|
|
64231
|
+
value: layerValue,
|
|
64232
|
+
kind,
|
|
64233
|
+
displayLayers: [layer.id]
|
|
64234
|
+
};
|
|
64235
|
+
}
|
|
64236
|
+
layerIDs.push(layer.id);
|
|
64237
|
+
if (layerOperations.length > 0) {
|
|
64238
|
+
for (const op of layerOperations) {
|
|
64239
|
+
if (isRemoveOperation(op)) {
|
|
64240
|
+
operations.remove.add(op.id);
|
|
64241
|
+
}
|
|
64242
|
+
if (isInsertOperation(op)) {
|
|
64243
|
+
operations.insert[op.location].unshift(op.id);
|
|
64244
|
+
}
|
|
64245
|
+
if (isDeleteOperation(op)) {
|
|
64246
|
+
return {
|
|
64247
|
+
value: void 0,
|
|
64248
|
+
kind: "unknown",
|
|
64249
|
+
displayLayers: []
|
|
64250
|
+
};
|
|
64251
|
+
}
|
|
64252
|
+
}
|
|
64253
|
+
}
|
|
64254
|
+
if (typeof layerValue === "undefined") {
|
|
64255
|
+
continue;
|
|
64256
|
+
}
|
|
64257
|
+
if (!operations.remove.size && !operations.insert.start.length && !operations.insert.end.length) {
|
|
64258
|
+
return { value: layerValue, displayLayers: layerIDs, kind: "link" };
|
|
64259
|
+
}
|
|
64260
|
+
return {
|
|
64261
|
+
value: [...operations.insert.start, ...layerValue, ...operations.insert.end].filter(
|
|
64262
|
+
(value) => !operations.remove.has(value)
|
|
64263
|
+
),
|
|
64264
|
+
displayLayers: layerIDs,
|
|
64265
|
+
kind
|
|
64266
|
+
};
|
|
64267
|
+
}
|
|
64268
|
+
return {
|
|
64269
|
+
value: void 0,
|
|
64270
|
+
kind: "unknown",
|
|
64271
|
+
displayLayers: []
|
|
64272
|
+
};
|
|
64273
|
+
}
|
|
64274
|
+
writeLink(id, field, value) {
|
|
64275
|
+
return this.topLayer.writeLink(id, field, value);
|
|
64276
|
+
}
|
|
64277
|
+
writeField(id, field, value) {
|
|
64278
|
+
return this.topLayer.writeField(id, field, value);
|
|
64279
|
+
}
|
|
64280
|
+
resolveLayer(id) {
|
|
64281
|
+
let startingIndex = null;
|
|
64282
|
+
for (const [index, layer] of this.data.entries()) {
|
|
64283
|
+
if (layer.id !== id) {
|
|
64284
|
+
continue;
|
|
64285
|
+
}
|
|
64286
|
+
startingIndex = index - 1;
|
|
64287
|
+
this.data[index].optimistic = false;
|
|
64288
|
+
break;
|
|
64289
|
+
}
|
|
64290
|
+
if (startingIndex === null) {
|
|
64291
|
+
throw new Error("could not find layer with id: " + id);
|
|
64292
|
+
}
|
|
64293
|
+
if (startingIndex === -1) {
|
|
64294
|
+
startingIndex = 0;
|
|
64295
|
+
}
|
|
64296
|
+
if (this.data[startingIndex].optimistic) {
|
|
64297
|
+
startingIndex++;
|
|
64298
|
+
}
|
|
64299
|
+
const baseLayer = this.data[startingIndex];
|
|
64300
|
+
let layerIndex = startingIndex;
|
|
64301
|
+
while (layerIndex < this.data.length) {
|
|
64302
|
+
const layer = this.data[layerIndex++];
|
|
64303
|
+
if (layer.optimistic) {
|
|
64304
|
+
layerIndex--;
|
|
64305
|
+
break;
|
|
64306
|
+
}
|
|
64307
|
+
baseLayer.writeLayer(layer);
|
|
64308
|
+
}
|
|
64309
|
+
this.data.splice(startingIndex + 1, layerIndex - startingIndex - 1);
|
|
64310
|
+
}
|
|
64311
|
+
get topLayer() {
|
|
64312
|
+
if (this.data.length === 0) {
|
|
64313
|
+
this.createLayer();
|
|
64314
|
+
}
|
|
64315
|
+
if (this.data[this.data.length - 1]?.optimistic) {
|
|
64316
|
+
this.createLayer();
|
|
64317
|
+
}
|
|
64318
|
+
return this.data[this.data.length - 1];
|
|
64319
|
+
}
|
|
64320
|
+
};
|
|
64321
|
+
var Layer = class {
|
|
64322
|
+
id;
|
|
64323
|
+
optimistic = false;
|
|
64324
|
+
fields = {};
|
|
64325
|
+
links = {};
|
|
64326
|
+
operations = {};
|
|
64327
|
+
deletedIDs = /* @__PURE__ */ new Set();
|
|
64328
|
+
constructor(id) {
|
|
64329
|
+
this.id = id;
|
|
64330
|
+
}
|
|
64331
|
+
get(id, field) {
|
|
64332
|
+
if (typeof this.links[id]?.[field] !== "undefined") {
|
|
64333
|
+
return [this.links[id][field], "link"];
|
|
64334
|
+
}
|
|
64335
|
+
return [this.fields[id]?.[field], "scalar"];
|
|
64336
|
+
}
|
|
64337
|
+
getOperations(id, field) {
|
|
64338
|
+
if (this.operations[id]?.deleted) {
|
|
64339
|
+
return [
|
|
64340
|
+
{
|
|
64341
|
+
kind: OperationKind.delete,
|
|
64342
|
+
target: id
|
|
64343
|
+
}
|
|
64344
|
+
];
|
|
64345
|
+
}
|
|
64346
|
+
if (this.operations[id]?.fields?.[field]) {
|
|
64347
|
+
return this.operations[id].fields[field];
|
|
64348
|
+
}
|
|
64349
|
+
}
|
|
64350
|
+
writeField(id, field, value) {
|
|
64351
|
+
this.fields[id] = {
|
|
64352
|
+
...this.fields[id],
|
|
64353
|
+
[field]: value
|
|
64354
|
+
};
|
|
64355
|
+
return this.id;
|
|
64356
|
+
}
|
|
64357
|
+
writeLink(id, field, value) {
|
|
64358
|
+
const valueList = Array.isArray(value) ? value : [value];
|
|
64359
|
+
for (const value2 of flatten(valueList)) {
|
|
64360
|
+
if (!value2) {
|
|
64361
|
+
continue;
|
|
64362
|
+
}
|
|
64363
|
+
const fieldOperations = this.operations[id]?.fields[field];
|
|
64364
|
+
if (this.operations[value2]?.deleted || this.deletedIDs.has(value2)) {
|
|
64365
|
+
this.operations[value2] = {
|
|
64366
|
+
...this.operations[value2],
|
|
64367
|
+
undoDeletesInList: [...this.operations[id]?.undoDeletesInList || [], field]
|
|
64368
|
+
};
|
|
64369
|
+
} else if (value2 && fieldOperations?.length > 0) {
|
|
64370
|
+
this.operations[id].fields[field] = fieldOperations.filter(
|
|
64371
|
+
(op) => op.kind !== "remove" || op.id !== value2
|
|
64372
|
+
);
|
|
64373
|
+
}
|
|
64374
|
+
}
|
|
64375
|
+
this.links[id] = {
|
|
64376
|
+
...this.links[id],
|
|
64377
|
+
[field]: value
|
|
64378
|
+
};
|
|
64379
|
+
return this.id;
|
|
64380
|
+
}
|
|
64381
|
+
isDisplayLayer(displayLayers) {
|
|
64382
|
+
return displayLayers.length === 0 || displayLayers.includes(this.id) || Math.max(...displayLayers) < this.id;
|
|
64383
|
+
}
|
|
64384
|
+
clear() {
|
|
64385
|
+
this.links = {};
|
|
64386
|
+
this.fields = {};
|
|
64387
|
+
this.operations = {};
|
|
64388
|
+
this.deletedIDs = /* @__PURE__ */ new Set();
|
|
64389
|
+
}
|
|
64390
|
+
replaceID({ from, to }) {
|
|
64391
|
+
this.fields[to] = this.fields[from];
|
|
64392
|
+
this.links[to] = this.links[from];
|
|
64393
|
+
this.operations[to] = this.operations[from] || { fields: {} };
|
|
64394
|
+
if (this.deletedIDs.has(from)) {
|
|
64395
|
+
this.deletedIDs.add(to);
|
|
64396
|
+
}
|
|
64397
|
+
}
|
|
64398
|
+
removeUndefinedFields() {
|
|
64399
|
+
for (const [id, fields] of Object.entries(this.fields)) {
|
|
64400
|
+
for (const [field, value] of Object.entries(fields)) {
|
|
64401
|
+
if (typeof value === "undefined") {
|
|
64402
|
+
try {
|
|
64403
|
+
delete this.fields[id][field];
|
|
64404
|
+
} catch {
|
|
64405
|
+
}
|
|
64406
|
+
try {
|
|
64407
|
+
delete this.links[id][field];
|
|
64408
|
+
} catch {
|
|
64409
|
+
}
|
|
64410
|
+
}
|
|
64411
|
+
}
|
|
64412
|
+
if (Object.keys(fields || {}).length === 0) {
|
|
64413
|
+
delete this.fields[id];
|
|
64414
|
+
}
|
|
64415
|
+
if (Object.keys(this.links[id] || {}).length === 0) {
|
|
64416
|
+
delete this.links[id];
|
|
64417
|
+
}
|
|
64418
|
+
}
|
|
64419
|
+
}
|
|
64420
|
+
delete(id) {
|
|
64421
|
+
this.operations = {
|
|
64422
|
+
...this.operations,
|
|
64423
|
+
[id]: {
|
|
64424
|
+
...this.operations[id],
|
|
64425
|
+
deleted: true,
|
|
64426
|
+
undoDeletesInList: []
|
|
64427
|
+
}
|
|
64428
|
+
};
|
|
64429
|
+
this.deletedIDs.add(id);
|
|
64430
|
+
}
|
|
64431
|
+
deleteField(id, field) {
|
|
64432
|
+
this.fields[id] = {
|
|
64433
|
+
...this.fields[id],
|
|
64434
|
+
[field]: void 0
|
|
64435
|
+
};
|
|
64436
|
+
}
|
|
64437
|
+
insert(id, field, where, target) {
|
|
64438
|
+
this.addFieldOperation(id, field, {
|
|
64439
|
+
kind: OperationKind.insert,
|
|
64440
|
+
id: target,
|
|
64441
|
+
location: where
|
|
64442
|
+
});
|
|
64443
|
+
}
|
|
64444
|
+
remove(id, field, target) {
|
|
64445
|
+
this.addFieldOperation(id, field, {
|
|
64446
|
+
kind: OperationKind.remove,
|
|
64447
|
+
id: target
|
|
64448
|
+
});
|
|
64449
|
+
}
|
|
64450
|
+
writeLayer(layer) {
|
|
64451
|
+
if (layer.id === this.id) {
|
|
64452
|
+
return;
|
|
64453
|
+
}
|
|
64454
|
+
for (const [id, ops] of Object.entries(layer.operations)) {
|
|
64455
|
+
const fields = {};
|
|
64456
|
+
for (const opMap of [this.operations[id], layer.operations[id]].filter(Boolean)) {
|
|
64457
|
+
for (const [fieldName, operations] of Object.entries(opMap.fields || {})) {
|
|
64458
|
+
fields[fieldName] = [...fields[fieldName] || [], ...operations];
|
|
64459
|
+
}
|
|
64460
|
+
}
|
|
64461
|
+
if (Object.keys(fields).length > 0) {
|
|
64462
|
+
this.operations[id] = {
|
|
64463
|
+
...this.operations[id],
|
|
64464
|
+
fields
|
|
64465
|
+
};
|
|
64466
|
+
}
|
|
64467
|
+
if (ops?.deleted) {
|
|
64468
|
+
delete this.fields[id];
|
|
64469
|
+
delete this.links[id];
|
|
64470
|
+
}
|
|
64471
|
+
}
|
|
64472
|
+
for (const [id, values] of Object.entries(layer.fields)) {
|
|
64473
|
+
if (!values) {
|
|
64474
|
+
continue;
|
|
64475
|
+
}
|
|
64476
|
+
for (const [field, value] of Object.entries(values)) {
|
|
64477
|
+
this.writeField(id, field, value);
|
|
64478
|
+
}
|
|
64479
|
+
}
|
|
64480
|
+
for (const [id, values] of Object.entries(layer.links)) {
|
|
64481
|
+
if (!values) {
|
|
64482
|
+
continue;
|
|
64483
|
+
}
|
|
64484
|
+
for (const [field, value] of Object.entries(values)) {
|
|
64485
|
+
this.writeLink(id, field, value);
|
|
64486
|
+
}
|
|
64487
|
+
}
|
|
64488
|
+
layer.deletedIDs.forEach((v) => this.deletedIDs.add(v));
|
|
64489
|
+
}
|
|
64490
|
+
addFieldOperation(id, field, operation) {
|
|
64491
|
+
this.operations = {
|
|
64492
|
+
...this.operations,
|
|
64493
|
+
[id]: {
|
|
64494
|
+
...this.operations[id],
|
|
64495
|
+
fields: {
|
|
64496
|
+
[field]: [...this.operations[id]?.fields[field] || [], operation]
|
|
64497
|
+
}
|
|
64498
|
+
}
|
|
64499
|
+
};
|
|
64500
|
+
}
|
|
64501
|
+
};
|
|
64502
|
+
function isDeleteOperation(value) {
|
|
64503
|
+
return !!value && value.kind === OperationKind.delete;
|
|
64504
|
+
}
|
|
64505
|
+
function isInsertOperation(value) {
|
|
64506
|
+
return !!value && value.kind === OperationKind.insert;
|
|
64507
|
+
}
|
|
64508
|
+
function isRemoveOperation(value) {
|
|
64509
|
+
return !!value && value.kind === OperationKind.remove;
|
|
64510
|
+
}
|
|
64511
|
+
var OperationLocation = {
|
|
64512
|
+
start: "start",
|
|
64513
|
+
end: "end"
|
|
64514
|
+
};
|
|
64515
|
+
var OperationKind = {
|
|
64516
|
+
delete: "delete",
|
|
64517
|
+
insert: "insert",
|
|
64518
|
+
remove: "remove"
|
|
64519
|
+
};
|
|
64520
|
+
|
|
64521
|
+
// src/runtime/cache/stuff.ts
|
|
64522
|
+
function evaluateKey(key, variables = {}) {
|
|
64523
|
+
let evaluated = "";
|
|
64524
|
+
let varName = "";
|
|
64525
|
+
let inString = false;
|
|
64526
|
+
for (const char of key) {
|
|
64527
|
+
if (varName) {
|
|
64528
|
+
if (varChars.includes(char)) {
|
|
64529
|
+
varName += char;
|
|
64530
|
+
continue;
|
|
64531
|
+
}
|
|
64532
|
+
const value = variables[varName.slice(1)];
|
|
64533
|
+
evaluated += typeof value !== "undefined" ? JSON.stringify(value) : "undefined";
|
|
64534
|
+
varName = "";
|
|
64535
|
+
}
|
|
64536
|
+
if (char === "$" && !inString) {
|
|
64537
|
+
varName = "$";
|
|
64538
|
+
continue;
|
|
64539
|
+
}
|
|
64540
|
+
if (char === '"') {
|
|
64541
|
+
inString = !inString;
|
|
64542
|
+
}
|
|
64543
|
+
evaluated += char;
|
|
64544
|
+
}
|
|
64545
|
+
return evaluated;
|
|
64546
|
+
}
|
|
64547
|
+
var varChars = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ_0123456789";
|
|
64548
|
+
|
|
64549
|
+
// src/runtime/cache/subscription.ts
|
|
64550
|
+
var InMemorySubscriptions = class {
|
|
64551
|
+
cache;
|
|
64552
|
+
constructor(cache) {
|
|
64553
|
+
this.cache = cache;
|
|
64554
|
+
}
|
|
64555
|
+
subscribers = {};
|
|
64556
|
+
referenceCounts = {};
|
|
64557
|
+
keyVersions = {};
|
|
64558
|
+
add({
|
|
64559
|
+
parent,
|
|
64560
|
+
spec,
|
|
64561
|
+
selection,
|
|
64562
|
+
variables,
|
|
64563
|
+
parentType
|
|
64564
|
+
}) {
|
|
64565
|
+
const __typename = this.cache._internal_unstable.storage.get(parent, "__typename").value;
|
|
64566
|
+
let targetSelection = getFieldsForType(selection, __typename);
|
|
64567
|
+
for (const fieldSelection of Object.values(targetSelection || {})) {
|
|
64568
|
+
const { keyRaw, selection: innerSelection, type, list, filters } = fieldSelection;
|
|
64569
|
+
const key = evaluateKey(keyRaw, variables);
|
|
64570
|
+
let targetSelection2;
|
|
64571
|
+
if (innerSelection) {
|
|
64572
|
+
const __typename2 = this.cache._internal_unstable.storage.get(parent, "__typename").value;
|
|
64573
|
+
targetSelection2 = getFieldsForType(innerSelection, __typename2);
|
|
64574
|
+
}
|
|
64575
|
+
this.addFieldSubscription({
|
|
64576
|
+
id: parent,
|
|
64577
|
+
key,
|
|
64578
|
+
selection: [spec, targetSelection2],
|
|
64579
|
+
type
|
|
64580
|
+
});
|
|
64581
|
+
if (list) {
|
|
64582
|
+
this.registerList({
|
|
64583
|
+
list,
|
|
64584
|
+
filters,
|
|
64585
|
+
id: parent,
|
|
64586
|
+
key,
|
|
64587
|
+
variables,
|
|
64588
|
+
selection: innerSelection,
|
|
64589
|
+
parentType: parentType || spec.rootType
|
|
64590
|
+
});
|
|
64591
|
+
}
|
|
64592
|
+
if (innerSelection) {
|
|
64593
|
+
const { value: linkedRecord } = this.cache._internal_unstable.storage.get(
|
|
64594
|
+
parent,
|
|
64595
|
+
key
|
|
64596
|
+
);
|
|
64597
|
+
let children = !Array.isArray(linkedRecord) ? [linkedRecord] : flatten(linkedRecord) || [];
|
|
64598
|
+
for (const child of children) {
|
|
64599
|
+
if (!child) {
|
|
64600
|
+
continue;
|
|
64601
|
+
}
|
|
64602
|
+
this.add({
|
|
64603
|
+
parent: child,
|
|
64604
|
+
spec,
|
|
64605
|
+
selection: innerSelection,
|
|
64606
|
+
variables,
|
|
64607
|
+
parentType: type
|
|
64608
|
+
});
|
|
64609
|
+
}
|
|
64610
|
+
}
|
|
64611
|
+
}
|
|
64612
|
+
}
|
|
64613
|
+
addFieldSubscription({
|
|
64614
|
+
id,
|
|
64615
|
+
key,
|
|
64616
|
+
selection,
|
|
64617
|
+
type
|
|
64618
|
+
}) {
|
|
64619
|
+
const spec = selection[0];
|
|
64620
|
+
if (!this.subscribers[id]) {
|
|
64621
|
+
this.subscribers[id] = {};
|
|
64622
|
+
}
|
|
64623
|
+
if (!this.subscribers[id][key]) {
|
|
64624
|
+
this.subscribers[id][key] = [];
|
|
64625
|
+
}
|
|
64626
|
+
if (!this.keyVersions[key]) {
|
|
64627
|
+
this.keyVersions[key] = /* @__PURE__ */ new Set();
|
|
64628
|
+
}
|
|
64629
|
+
this.keyVersions[key].add(key);
|
|
64630
|
+
if (!this.subscribers[id][key].map(([{ set }]) => set).includes(spec.set)) {
|
|
64631
|
+
this.subscribers[id][key].push([spec, selection[1]]);
|
|
64632
|
+
}
|
|
64633
|
+
if (!this.referenceCounts[id]) {
|
|
64634
|
+
this.referenceCounts[id] = {};
|
|
64635
|
+
}
|
|
64636
|
+
if (!this.referenceCounts[id][key]) {
|
|
64637
|
+
this.referenceCounts[id][key] = /* @__PURE__ */ new Map();
|
|
64638
|
+
}
|
|
64639
|
+
const counts = this.referenceCounts[id][key];
|
|
64640
|
+
counts.set(spec.set, (counts.get(spec.set) || 0) + 1);
|
|
64641
|
+
this.cache._internal_unstable.lifetimes.resetLifetime(id, key);
|
|
64642
|
+
const { selection: innerSelection } = selection[1]?.[key] ?? {};
|
|
64643
|
+
}
|
|
64644
|
+
registerList({
|
|
64645
|
+
list,
|
|
64646
|
+
id,
|
|
64647
|
+
key,
|
|
64648
|
+
parentType,
|
|
64649
|
+
selection,
|
|
64650
|
+
filters,
|
|
64651
|
+
variables
|
|
64652
|
+
}) {
|
|
64653
|
+
this.cache._internal_unstable.lists.add({
|
|
64654
|
+
name: list.name,
|
|
64655
|
+
connection: list.connection,
|
|
64656
|
+
recordID: id,
|
|
64657
|
+
recordType: this.cache._internal_unstable.storage.get(id, "__typename")?.value || parentType,
|
|
64658
|
+
listType: list.type,
|
|
64659
|
+
key,
|
|
64660
|
+
selection,
|
|
64661
|
+
filters: Object.entries(filters || {}).reduce((acc, [key2, { kind, value }]) => {
|
|
64662
|
+
return {
|
|
64663
|
+
...acc,
|
|
64664
|
+
[key2]: kind !== "Variable" ? value : variables[value]
|
|
64665
|
+
};
|
|
64666
|
+
}, {})
|
|
64667
|
+
});
|
|
64668
|
+
}
|
|
64669
|
+
addMany({
|
|
64670
|
+
parent,
|
|
64671
|
+
variables,
|
|
64672
|
+
subscribers,
|
|
64673
|
+
parentType
|
|
64674
|
+
}) {
|
|
64675
|
+
for (const [spec, targetSelection] of subscribers) {
|
|
64676
|
+
for (const selection of Object.values(targetSelection ?? {})) {
|
|
64677
|
+
const {
|
|
64678
|
+
type: linkedType,
|
|
64679
|
+
keyRaw,
|
|
64680
|
+
selection: innerSelection,
|
|
64681
|
+
list,
|
|
64682
|
+
filters
|
|
64683
|
+
} = selection;
|
|
64684
|
+
const key = evaluateKey(keyRaw, variables);
|
|
64685
|
+
const fieldSelection = innerSelection ? getFieldsForType(innerSelection, parentType) : void 0;
|
|
64686
|
+
this.addFieldSubscription({
|
|
64687
|
+
id: parent,
|
|
64688
|
+
key,
|
|
64689
|
+
selection: [spec, fieldSelection],
|
|
64690
|
+
type: linkedType
|
|
64691
|
+
});
|
|
64692
|
+
if (list) {
|
|
64693
|
+
this.registerList({
|
|
64694
|
+
list,
|
|
64695
|
+
filters,
|
|
64696
|
+
id: parent,
|
|
64697
|
+
key,
|
|
64698
|
+
variables,
|
|
64699
|
+
selection: innerSelection,
|
|
64700
|
+
parentType: parentType || spec.rootType
|
|
64701
|
+
});
|
|
64702
|
+
}
|
|
64703
|
+
const childSelection = selection.selection;
|
|
64704
|
+
if (childSelection) {
|
|
64705
|
+
const { value: link } = this.cache._internal_unstable.storage.get(parent, key);
|
|
64706
|
+
const children = !Array.isArray(link) ? [link] : flatten(link);
|
|
64707
|
+
for (const linkedRecord of children) {
|
|
64708
|
+
if (!linkedRecord) {
|
|
64709
|
+
continue;
|
|
64710
|
+
}
|
|
64711
|
+
const __typename = this.cache._internal_unstable.storage.get(
|
|
64712
|
+
linkedRecord,
|
|
64713
|
+
"__typename"
|
|
64714
|
+
).value;
|
|
64715
|
+
let targetSelection2 = getFieldsForType(childSelection, __typename);
|
|
64716
|
+
this.addMany({
|
|
64717
|
+
parent: linkedRecord,
|
|
64718
|
+
variables,
|
|
64719
|
+
subscribers: subscribers.map(([sub]) => [sub, targetSelection2]),
|
|
64720
|
+
parentType: linkedType
|
|
64721
|
+
});
|
|
64722
|
+
}
|
|
64723
|
+
}
|
|
64724
|
+
}
|
|
64725
|
+
}
|
|
64726
|
+
}
|
|
64727
|
+
get(id, field) {
|
|
64728
|
+
return this.subscribers[id]?.[field] || [];
|
|
64729
|
+
}
|
|
64730
|
+
remove(id, selection, targets, variables, visited = []) {
|
|
64731
|
+
visited.push(id);
|
|
64732
|
+
const linkedIDs = [];
|
|
64733
|
+
const __typename = this.cache._internal_unstable.storage.get(id, "__typename").value;
|
|
64734
|
+
let targetSelection = getFieldsForType(selection, __typename);
|
|
64735
|
+
for (const fieldSelection of Object.values(targetSelection || {})) {
|
|
64736
|
+
const key = evaluateKey(fieldSelection.keyRaw, variables);
|
|
64737
|
+
this.removeSubscribers(id, key, targets);
|
|
64738
|
+
if (!fieldSelection.selection) {
|
|
64739
|
+
continue;
|
|
64740
|
+
}
|
|
64741
|
+
const { value: previousValue } = this.cache._internal_unstable.storage.get(id, key);
|
|
64742
|
+
const links = !Array.isArray(previousValue) ? [previousValue] : flatten(previousValue);
|
|
64743
|
+
for (const link of links) {
|
|
64744
|
+
if (link !== null) {
|
|
64745
|
+
linkedIDs.push([link, fieldSelection.selection || {}]);
|
|
64746
|
+
}
|
|
64747
|
+
}
|
|
64748
|
+
}
|
|
64749
|
+
for (const [linkedRecordID, linkFields] of linkedIDs) {
|
|
64750
|
+
this.remove(linkedRecordID, linkFields, targets, visited);
|
|
64751
|
+
}
|
|
64752
|
+
}
|
|
64753
|
+
removeSubscribers(id, fieldName, specs) {
|
|
64754
|
+
let targets = [];
|
|
64755
|
+
for (const spec of specs) {
|
|
64756
|
+
if (!this.referenceCounts[id]?.[fieldName]?.has(spec.set)) {
|
|
64757
|
+
continue;
|
|
64758
|
+
}
|
|
64759
|
+
const counts = this.referenceCounts[id][fieldName];
|
|
64760
|
+
const newVal = (counts.get(spec.set) || 0) - 1;
|
|
64761
|
+
counts.set(spec.set, newVal);
|
|
64762
|
+
if (newVal <= 0) {
|
|
64763
|
+
targets.push(spec.set);
|
|
64764
|
+
counts.delete(spec.set);
|
|
64765
|
+
}
|
|
64766
|
+
}
|
|
64767
|
+
if (this.subscribers[id]) {
|
|
64768
|
+
this.subscribers[id][fieldName] = this.get(id, fieldName).filter(
|
|
64769
|
+
([{ set }]) => !targets.includes(set)
|
|
64770
|
+
);
|
|
64771
|
+
}
|
|
64772
|
+
}
|
|
64773
|
+
removeAllSubscribers(id, targets, visited = []) {
|
|
64774
|
+
visited.push(id);
|
|
64775
|
+
for (const field of Object.keys(this.subscribers[id] || [])) {
|
|
64776
|
+
const subscribers = targets || this.subscribers[id][field].map(([spec]) => spec);
|
|
64777
|
+
this.removeSubscribers(id, field, subscribers);
|
|
64778
|
+
const { value, kind } = this.cache._internal_unstable.storage.get(id, field);
|
|
64779
|
+
if (kind === "scalar") {
|
|
64780
|
+
continue;
|
|
64781
|
+
}
|
|
64782
|
+
const nextTargets = Array.isArray(value) ? flatten(value) : [value];
|
|
64783
|
+
for (const id2 of nextTargets) {
|
|
64784
|
+
if (visited.includes(id2)) {
|
|
64785
|
+
continue;
|
|
64786
|
+
}
|
|
64787
|
+
this.removeAllSubscribers(id2, subscribers, visited);
|
|
64788
|
+
}
|
|
64789
|
+
}
|
|
64790
|
+
}
|
|
64791
|
+
};
|
|
64792
|
+
|
|
64793
|
+
// src/runtime/cache/cache.ts
|
|
64794
|
+
var Cache = class {
|
|
64795
|
+
_internal_unstable;
|
|
64796
|
+
constructor(config) {
|
|
64797
|
+
this._internal_unstable = new CacheInternal({
|
|
64798
|
+
cache: this,
|
|
64799
|
+
storage: new InMemoryStorage(),
|
|
64800
|
+
subscriptions: new InMemorySubscriptions(this),
|
|
64801
|
+
lists: new ListManager(this, rootID),
|
|
64802
|
+
lifetimes: new GarbageCollector(this),
|
|
64803
|
+
staleManager: new StaleManager(this),
|
|
64804
|
+
schema: new SchemaManager(this)
|
|
64805
|
+
});
|
|
64806
|
+
if (config) {
|
|
64807
|
+
this.setConfig(defaultConfigValues(config));
|
|
64808
|
+
}
|
|
64809
|
+
}
|
|
64810
|
+
write({
|
|
64811
|
+
layer: layerID,
|
|
64812
|
+
notifySubscribers = [],
|
|
64813
|
+
...args
|
|
64814
|
+
}) {
|
|
64815
|
+
const layer = layerID ? this._internal_unstable.storage.getLayer(layerID) : this._internal_unstable.storage.topLayer;
|
|
64816
|
+
const subscribers = this._internal_unstable.writeSelection({ ...args, layer }).map((sub) => sub[0]);
|
|
64817
|
+
const notified = [];
|
|
64818
|
+
for (const spec of subscribers.concat(notifySubscribers)) {
|
|
64819
|
+
if (!notified.includes(spec.set)) {
|
|
64820
|
+
notified.push(spec.set);
|
|
64821
|
+
spec.set(
|
|
64822
|
+
this._internal_unstable.getSelection({
|
|
64823
|
+
parent: spec.parentID || rootID,
|
|
64824
|
+
selection: spec.selection,
|
|
64825
|
+
variables: spec.variables?.() || {}
|
|
64826
|
+
}).data
|
|
64827
|
+
);
|
|
64828
|
+
}
|
|
64829
|
+
}
|
|
64830
|
+
return subscribers;
|
|
64831
|
+
}
|
|
64832
|
+
read(...args) {
|
|
64833
|
+
const { data, partial, stale, hasData } = this._internal_unstable.getSelection(...args);
|
|
64834
|
+
if (!hasData) {
|
|
64835
|
+
return { data: null, partial: false, stale: false };
|
|
64836
|
+
}
|
|
64837
|
+
return {
|
|
64838
|
+
data,
|
|
64839
|
+
partial,
|
|
64840
|
+
stale
|
|
64841
|
+
};
|
|
64842
|
+
}
|
|
64843
|
+
subscribe(spec, variables = {}) {
|
|
64844
|
+
return this._internal_unstable.subscriptions.add({
|
|
64845
|
+
parent: spec.parentID || rootID,
|
|
64846
|
+
spec,
|
|
64847
|
+
selection: spec.selection,
|
|
64848
|
+
variables
|
|
64849
|
+
});
|
|
64850
|
+
}
|
|
64851
|
+
unsubscribe(spec, variables = {}) {
|
|
64852
|
+
return this._internal_unstable.subscriptions.remove(
|
|
64853
|
+
spec.parentID || rootID,
|
|
64854
|
+
spec.selection,
|
|
64855
|
+
[spec],
|
|
64856
|
+
variables
|
|
64857
|
+
);
|
|
64858
|
+
}
|
|
64859
|
+
list(name, parentID, allLists) {
|
|
64860
|
+
const handler = this._internal_unstable.lists.get(name, parentID, allLists);
|
|
64861
|
+
if (!handler) {
|
|
64862
|
+
throw new Error(
|
|
64863
|
+
`Cannot find list with name: ${name}${parentID ? " under parent " + parentID : ""}. Is it possible that the query is not mounted?`
|
|
64864
|
+
);
|
|
64865
|
+
}
|
|
64866
|
+
return handler;
|
|
64867
|
+
}
|
|
64868
|
+
delete(id) {
|
|
64869
|
+
this._internal_unstable.subscriptions.removeAllSubscribers(id);
|
|
64870
|
+
this._internal_unstable.lists.removeIDFromAllLists(id);
|
|
64871
|
+
this._internal_unstable.storage.delete(id);
|
|
64872
|
+
}
|
|
64873
|
+
setConfig(config) {
|
|
64874
|
+
this._internal_unstable.setConfig(config);
|
|
64875
|
+
}
|
|
64876
|
+
markTypeStale(options) {
|
|
64877
|
+
if (!options) {
|
|
64878
|
+
this._internal_unstable.staleManager.markAllStale();
|
|
64879
|
+
} else if (!options.field) {
|
|
64880
|
+
this._internal_unstable.staleManager.markTypeStale(options.type);
|
|
64881
|
+
} else {
|
|
64882
|
+
this._internal_unstable.staleManager.markTypeFieldStale(
|
|
64883
|
+
options.type,
|
|
64884
|
+
options.field,
|
|
64885
|
+
options.when
|
|
64886
|
+
);
|
|
64887
|
+
}
|
|
64888
|
+
}
|
|
64889
|
+
markRecordStale(id, options) {
|
|
64890
|
+
if (options.field) {
|
|
64891
|
+
const key = computeKey({ field: options.field, args: options.when ?? {} });
|
|
64892
|
+
this._internal_unstable.staleManager.markFieldStale(id, key);
|
|
64893
|
+
} else {
|
|
64894
|
+
this._internal_unstable.staleManager.markRecordStale(id);
|
|
64895
|
+
}
|
|
64896
|
+
}
|
|
64897
|
+
getFieldTime(id, field) {
|
|
64898
|
+
return this._internal_unstable.staleManager.getFieldTime(id, field);
|
|
64899
|
+
}
|
|
64900
|
+
};
|
|
64901
|
+
var CacheInternal = class {
|
|
64902
|
+
_disabled = false;
|
|
64903
|
+
config = defaultConfigValues({
|
|
64904
|
+
plugins: {
|
|
64905
|
+
"houdini-svelte": {
|
|
64906
|
+
client: ""
|
|
64907
|
+
}
|
|
64908
|
+
}
|
|
64909
|
+
});
|
|
64910
|
+
storage;
|
|
64911
|
+
subscriptions;
|
|
64912
|
+
lists;
|
|
64913
|
+
cache;
|
|
64914
|
+
lifetimes;
|
|
64915
|
+
staleManager;
|
|
64916
|
+
schema;
|
|
64917
|
+
constructor({
|
|
64918
|
+
storage,
|
|
64919
|
+
subscriptions,
|
|
64920
|
+
lists,
|
|
64921
|
+
cache,
|
|
64922
|
+
lifetimes,
|
|
64923
|
+
staleManager,
|
|
64924
|
+
schema
|
|
64925
|
+
}) {
|
|
64926
|
+
this.storage = storage;
|
|
64927
|
+
this.subscriptions = subscriptions;
|
|
64928
|
+
this.lists = lists;
|
|
64929
|
+
this.cache = cache;
|
|
64930
|
+
this.lifetimes = lifetimes;
|
|
64931
|
+
this.staleManager = staleManager;
|
|
64932
|
+
this.schema = schema;
|
|
64933
|
+
this._disabled = typeof globalThis.window === "undefined";
|
|
64934
|
+
try {
|
|
64935
|
+
if (process.env.HOUDINI_TEST === "true") {
|
|
64936
|
+
this._disabled = false;
|
|
64937
|
+
}
|
|
64938
|
+
} catch {
|
|
64939
|
+
}
|
|
64940
|
+
}
|
|
64941
|
+
setConfig(config) {
|
|
64942
|
+
this.config = config;
|
|
64943
|
+
}
|
|
64944
|
+
writeSelection({
|
|
64945
|
+
data,
|
|
64946
|
+
selection,
|
|
64947
|
+
variables = {},
|
|
64948
|
+
parent = rootID,
|
|
64949
|
+
applyUpdates,
|
|
64950
|
+
layer,
|
|
64951
|
+
toNotify = [],
|
|
64952
|
+
forceNotify,
|
|
64953
|
+
forceStale
|
|
64954
|
+
}) {
|
|
64955
|
+
if (this._disabled) {
|
|
64956
|
+
return [];
|
|
64957
|
+
}
|
|
64958
|
+
let targetSelection = getFieldsForType(selection, data["__typename"]);
|
|
64959
|
+
for (const [field, value] of Object.entries(data)) {
|
|
64960
|
+
if (!selection || !targetSelection[field]) {
|
|
64961
|
+
throw new Error(
|
|
64962
|
+
"Could not find field listing in selection for " + field + " @ " + JSON.stringify(selection)
|
|
64963
|
+
);
|
|
64964
|
+
}
|
|
64965
|
+
let {
|
|
64966
|
+
type: linkedType,
|
|
64967
|
+
keyRaw,
|
|
64968
|
+
selection: fieldSelection,
|
|
64969
|
+
operations,
|
|
64970
|
+
abstract: isAbstract,
|
|
64971
|
+
updates,
|
|
64972
|
+
nullable
|
|
64973
|
+
} = targetSelection[field];
|
|
64974
|
+
const key = evaluateKey(keyRaw, variables);
|
|
64975
|
+
this.schema.setFieldType({
|
|
64976
|
+
parent,
|
|
64977
|
+
key: keyRaw,
|
|
64978
|
+
type: linkedType,
|
|
64979
|
+
nullable,
|
|
64980
|
+
link: !!fieldSelection
|
|
64981
|
+
});
|
|
64982
|
+
const currentSubscribers = this.subscriptions.get(parent, key);
|
|
64983
|
+
const specs = currentSubscribers.map((sub) => sub[0]);
|
|
64984
|
+
const { value: previousValue, displayLayers } = this.storage.get(parent, key);
|
|
64985
|
+
const displayLayer = layer.isDisplayLayer(displayLayers);
|
|
64986
|
+
if (displayLayer) {
|
|
64987
|
+
this.lifetimes.resetLifetime(parent, key);
|
|
64988
|
+
if (forceStale) {
|
|
64989
|
+
this.staleManager.markFieldStale(parent, key);
|
|
64990
|
+
} else {
|
|
64991
|
+
this.staleManager.setFieldTimeToNow(parent, key);
|
|
64992
|
+
}
|
|
64993
|
+
}
|
|
64994
|
+
if (!fieldSelection) {
|
|
64995
|
+
let newValue = value;
|
|
64996
|
+
if (updates && applyUpdates && Array.isArray(value)) {
|
|
64997
|
+
for (const update of applyUpdates) {
|
|
64998
|
+
if (!updates.includes(update)) {
|
|
64999
|
+
continue;
|
|
65000
|
+
}
|
|
65001
|
+
if (update === "append") {
|
|
65002
|
+
newValue = (previousValue || []).concat(value);
|
|
65003
|
+
} else if (update === "prepend") {
|
|
65004
|
+
newValue = value.concat(previousValue || []);
|
|
65005
|
+
}
|
|
65006
|
+
}
|
|
65007
|
+
}
|
|
65008
|
+
if (updates && applyUpdates?.includes("prepend") && ["endCursor", "hasNextPage"].includes(key)) {
|
|
65009
|
+
newValue = previousValue;
|
|
65010
|
+
} else if (updates && applyUpdates?.includes("append") && ["startCursor", "hasPreviousPage"].includes(key)) {
|
|
65011
|
+
newValue = previousValue;
|
|
65012
|
+
}
|
|
65013
|
+
const valueChanged = !deepEquals(newValue, previousValue);
|
|
65014
|
+
if (displayLayer && (valueChanged || forceNotify)) {
|
|
65015
|
+
toNotify.push(...currentSubscribers);
|
|
65016
|
+
}
|
|
65017
|
+
layer.writeField(parent, key, newValue);
|
|
65018
|
+
} else if (value === null) {
|
|
65019
|
+
if (previousValue === null) {
|
|
65020
|
+
continue;
|
|
65021
|
+
}
|
|
65022
|
+
const previousLinks = flatten([previousValue]);
|
|
65023
|
+
for (const link of previousLinks) {
|
|
65024
|
+
this.subscriptions.remove(link, fieldSelection, specs, variables);
|
|
65025
|
+
}
|
|
65026
|
+
layer.writeLink(parent, key, null);
|
|
65027
|
+
toNotify.push(...currentSubscribers);
|
|
65028
|
+
} else if (value instanceof Object && !Array.isArray(value)) {
|
|
65029
|
+
if (isAbstract) {
|
|
65030
|
+
if (!value.__typename) {
|
|
65031
|
+
throw new Error(
|
|
65032
|
+
"Encountered interface type without __typename in the payload"
|
|
65033
|
+
);
|
|
65034
|
+
}
|
|
65035
|
+
linkedType = value.__typename;
|
|
65036
|
+
}
|
|
65037
|
+
const embedded = this.idFields(linkedType)?.filter(
|
|
65038
|
+
(field2) => typeof value[field2] === "undefined"
|
|
65039
|
+
).length > 0;
|
|
65040
|
+
let linkedID = null;
|
|
65041
|
+
if (value !== null) {
|
|
65042
|
+
linkedID = !embedded ? this.id(linkedType, value) : `${parent}.${key}`;
|
|
65043
|
+
}
|
|
65044
|
+
let linkChange = linkedID !== previousValue;
|
|
65045
|
+
layer.writeLink(parent, key, linkedID);
|
|
65046
|
+
if (linkedID && displayLayer && (linkChange || forceNotify)) {
|
|
65047
|
+
if (previousValue && typeof previousValue === "string") {
|
|
65048
|
+
this.subscriptions.remove(previousValue, fieldSelection, specs, variables);
|
|
65049
|
+
}
|
|
65050
|
+
this.subscriptions.addMany({
|
|
65051
|
+
parent: linkedID,
|
|
65052
|
+
subscribers: currentSubscribers,
|
|
65053
|
+
variables,
|
|
65054
|
+
parentType: linkedType
|
|
65055
|
+
});
|
|
65056
|
+
toNotify.push(...currentSubscribers);
|
|
65057
|
+
}
|
|
65058
|
+
if (linkedID) {
|
|
65059
|
+
this.writeSelection({
|
|
65060
|
+
selection: fieldSelection,
|
|
65061
|
+
parent: linkedID,
|
|
65062
|
+
data: value,
|
|
65063
|
+
variables,
|
|
65064
|
+
toNotify,
|
|
65065
|
+
applyUpdates,
|
|
65066
|
+
layer,
|
|
65067
|
+
forceNotify
|
|
65068
|
+
});
|
|
65069
|
+
}
|
|
65070
|
+
} else if (Array.isArray(value) && (typeof previousValue === "undefined" || Array.isArray(previousValue))) {
|
|
65071
|
+
let oldIDs = [...previousValue || []];
|
|
65072
|
+
const emptyEdges = !updates ? [] : oldIDs.map((id) => {
|
|
65073
|
+
if (!id) {
|
|
65074
|
+
return "";
|
|
65075
|
+
}
|
|
65076
|
+
const { value: cursorField } = this.storage.get(id, "cursor");
|
|
65077
|
+
if (cursorField) {
|
|
65078
|
+
return "";
|
|
65079
|
+
}
|
|
65080
|
+
const { value: node } = this.storage.get(id, "node");
|
|
65081
|
+
if (!node) {
|
|
65082
|
+
return "";
|
|
65083
|
+
}
|
|
65084
|
+
return node;
|
|
65085
|
+
});
|
|
65086
|
+
let linkedIDs = [];
|
|
65087
|
+
const { newIDs, nestedIDs } = this.extractNestedListIDs({
|
|
65088
|
+
value,
|
|
65089
|
+
abstract: Boolean(isAbstract),
|
|
65090
|
+
specs: toNotify,
|
|
65091
|
+
applyUpdates,
|
|
65092
|
+
recordID: parent,
|
|
65093
|
+
key,
|
|
65094
|
+
linkedType,
|
|
65095
|
+
variables,
|
|
65096
|
+
fields: fieldSelection,
|
|
65097
|
+
layer,
|
|
65098
|
+
forceNotify
|
|
65099
|
+
});
|
|
65100
|
+
if (applyUpdates && updates) {
|
|
65101
|
+
if (key === "edges") {
|
|
65102
|
+
const newNodeIDs = [];
|
|
65103
|
+
for (const id of newIDs) {
|
|
65104
|
+
if (!id) {
|
|
65105
|
+
continue;
|
|
65106
|
+
}
|
|
65107
|
+
const { value: node } = this.storage.get(id, "node");
|
|
65108
|
+
if (typeof node !== "string") {
|
|
65109
|
+
continue;
|
|
65110
|
+
}
|
|
65111
|
+
if (!node || !this.storage.get(node, "__typename")) {
|
|
65112
|
+
continue;
|
|
65113
|
+
}
|
|
65114
|
+
newNodeIDs.push(node);
|
|
65115
|
+
}
|
|
65116
|
+
oldIDs = oldIDs.filter((id) => {
|
|
65117
|
+
if (!id) {
|
|
65118
|
+
return true;
|
|
65119
|
+
}
|
|
65120
|
+
const { value: value2 } = this.storage.get(id, "node");
|
|
65121
|
+
const node = value2;
|
|
65122
|
+
if (newNodeIDs.includes(node) && emptyEdges.includes(node)) {
|
|
65123
|
+
return false;
|
|
65124
|
+
}
|
|
65125
|
+
return true;
|
|
65126
|
+
});
|
|
65127
|
+
}
|
|
65128
|
+
for (const update of applyUpdates) {
|
|
65129
|
+
if (update !== "replace" && !updates.includes(update)) {
|
|
65130
|
+
continue;
|
|
65131
|
+
}
|
|
65132
|
+
if (update === "prepend") {
|
|
65133
|
+
linkedIDs = newIDs.concat(oldIDs);
|
|
65134
|
+
} else if (update === "append") {
|
|
65135
|
+
linkedIDs = oldIDs.concat(newIDs);
|
|
65136
|
+
} else if (update === "replace") {
|
|
65137
|
+
linkedIDs = newIDs;
|
|
65138
|
+
}
|
|
65139
|
+
}
|
|
65140
|
+
} else {
|
|
65141
|
+
linkedIDs = nestedIDs;
|
|
65142
|
+
}
|
|
65143
|
+
const contentChanged = !deepEquals(linkedIDs, oldIDs);
|
|
65144
|
+
if (contentChanged || forceNotify) {
|
|
65145
|
+
toNotify.push(...currentSubscribers);
|
|
65146
|
+
}
|
|
65147
|
+
for (const lostID of oldIDs) {
|
|
65148
|
+
if (linkedIDs.includes(lostID) || !lostID) {
|
|
65149
|
+
continue;
|
|
65150
|
+
}
|
|
65151
|
+
this.subscriptions.remove(lostID, fieldSelection, specs, variables);
|
|
65152
|
+
}
|
|
65153
|
+
if (contentChanged || oldIDs.length === 0 && newIDs.length === 0) {
|
|
65154
|
+
layer.writeLink(parent, key, linkedIDs);
|
|
65155
|
+
}
|
|
65156
|
+
for (const id of newIDs.filter((id2) => !oldIDs.includes(id2))) {
|
|
65157
|
+
if (id == null) {
|
|
65158
|
+
continue;
|
|
65159
|
+
}
|
|
65160
|
+
this.subscriptions.addMany({
|
|
65161
|
+
parent: id,
|
|
65162
|
+
subscribers: currentSubscribers,
|
|
65163
|
+
variables,
|
|
65164
|
+
parentType: linkedType
|
|
65165
|
+
});
|
|
65166
|
+
}
|
|
65167
|
+
}
|
|
65168
|
+
for (const operation of operations || []) {
|
|
65169
|
+
let parentID;
|
|
65170
|
+
if (operation.parentID) {
|
|
65171
|
+
if (operation.parentID.kind !== "Variable") {
|
|
65172
|
+
parentID = operation.parentID.value;
|
|
65173
|
+
} else {
|
|
65174
|
+
const id = variables[operation.parentID.value];
|
|
65175
|
+
if (typeof id !== "string") {
|
|
65176
|
+
throw new Error("parentID value must be a string");
|
|
65177
|
+
}
|
|
65178
|
+
parentID = id;
|
|
65179
|
+
}
|
|
65180
|
+
}
|
|
65181
|
+
if (operation.list && !this.lists.get(operation.list, parentID, operation.target === "all")) {
|
|
65182
|
+
continue;
|
|
65183
|
+
}
|
|
65184
|
+
const targets = Array.isArray(value) ? value : [value];
|
|
65185
|
+
for (const target of targets) {
|
|
65186
|
+
if (operation.action === "insert" && target instanceof Object && fieldSelection && operation.list) {
|
|
65187
|
+
this.cache.list(operation.list, parentID, operation.target === "all").when(operation.when).addToList(
|
|
65188
|
+
fieldSelection,
|
|
65189
|
+
target,
|
|
65190
|
+
variables,
|
|
65191
|
+
operation.position || "last"
|
|
65192
|
+
);
|
|
65193
|
+
} else if (operation.action === "remove" && target instanceof Object && fieldSelection && operation.list) {
|
|
65194
|
+
this.cache.list(operation.list, parentID, operation.target === "all").when(operation.when).remove(target, variables);
|
|
65195
|
+
} else if (operation.action === "delete" && operation.type) {
|
|
65196
|
+
if (typeof target !== "string") {
|
|
65197
|
+
throw new Error("Cannot delete a record with a non-string ID");
|
|
65198
|
+
}
|
|
65199
|
+
const targetID = this.id(operation.type, target);
|
|
65200
|
+
if (!targetID) {
|
|
65201
|
+
continue;
|
|
65202
|
+
}
|
|
65203
|
+
this.cache.delete(targetID);
|
|
65204
|
+
} else if (operation.action === "toggle" && target instanceof Object && fieldSelection && operation.list) {
|
|
65205
|
+
this.cache.list(operation.list, parentID, operation.target === "all").when(operation.when).toggleElement(
|
|
65206
|
+
fieldSelection,
|
|
65207
|
+
target,
|
|
65208
|
+
variables,
|
|
65209
|
+
operation.position || "last"
|
|
65210
|
+
);
|
|
65211
|
+
}
|
|
65212
|
+
}
|
|
65213
|
+
}
|
|
65214
|
+
}
|
|
65215
|
+
return toNotify;
|
|
65216
|
+
}
|
|
65217
|
+
getSelection({
|
|
65218
|
+
selection,
|
|
65219
|
+
parent = rootID,
|
|
65220
|
+
variables,
|
|
65221
|
+
stepsFromConnection = null
|
|
65222
|
+
}) {
|
|
65223
|
+
if (parent === null) {
|
|
65224
|
+
return { data: null, partial: false, stale: false, hasData: true };
|
|
65225
|
+
}
|
|
65226
|
+
const target = {};
|
|
65227
|
+
let hasData = false;
|
|
65228
|
+
let partial = false;
|
|
65229
|
+
let cascadeNull = false;
|
|
65230
|
+
let stale = false;
|
|
65231
|
+
const typename = this.storage.get(parent, "__typename").value;
|
|
65232
|
+
let targetSelection = getFieldsForType(selection, typename);
|
|
65233
|
+
for (const [
|
|
65234
|
+
attributeName,
|
|
65235
|
+
{ type, keyRaw, selection: fieldSelection, nullable, list }
|
|
65236
|
+
] of Object.entries(targetSelection)) {
|
|
65237
|
+
const key = evaluateKey(keyRaw, variables);
|
|
65238
|
+
const { value } = this.storage.get(parent, key);
|
|
65239
|
+
const dt_field = this.staleManager.getFieldTime(parent, key);
|
|
65240
|
+
if (dt_field === null) {
|
|
65241
|
+
stale = true;
|
|
65242
|
+
}
|
|
65243
|
+
let nextStep = stepsFromConnection;
|
|
65244
|
+
if (nextStep !== null) {
|
|
65245
|
+
if (nextStep >= 2) {
|
|
65246
|
+
nextStep = null;
|
|
65247
|
+
} else {
|
|
65248
|
+
nextStep += 1;
|
|
65249
|
+
}
|
|
65250
|
+
}
|
|
65251
|
+
if (list?.connection) {
|
|
65252
|
+
nextStep = 0;
|
|
65253
|
+
}
|
|
65254
|
+
const embeddedCursor = key === "cursor" && stepsFromConnection === 1;
|
|
65255
|
+
if (typeof value === "undefined" && !embeddedCursor) {
|
|
65256
|
+
partial = true;
|
|
65257
|
+
}
|
|
65258
|
+
if (typeof value === "undefined" || value === null) {
|
|
65259
|
+
target[attributeName] = null;
|
|
65260
|
+
if (typeof value !== "undefined") {
|
|
65261
|
+
hasData = true;
|
|
65262
|
+
}
|
|
65263
|
+
} else if (!fieldSelection) {
|
|
65264
|
+
const fnUnmarshal = this.config?.scalars?.[type]?.unmarshal;
|
|
65265
|
+
if (fnUnmarshal) {
|
|
65266
|
+
target[attributeName] = fnUnmarshal(value);
|
|
65267
|
+
} else {
|
|
65268
|
+
target[attributeName] = value;
|
|
65269
|
+
}
|
|
65270
|
+
hasData = true;
|
|
65271
|
+
} else if (Array.isArray(value)) {
|
|
65272
|
+
const listValue = this.hydrateNestedList({
|
|
65273
|
+
fields: fieldSelection,
|
|
65274
|
+
variables,
|
|
65275
|
+
linkedList: value,
|
|
65276
|
+
stepsFromConnection: nextStep
|
|
65277
|
+
});
|
|
65278
|
+
target[attributeName] = listValue.data;
|
|
65279
|
+
if (listValue.partial) {
|
|
65280
|
+
partial = true;
|
|
65281
|
+
}
|
|
65282
|
+
if (listValue.stale) {
|
|
65283
|
+
stale = true;
|
|
65284
|
+
}
|
|
65285
|
+
if (listValue.hasData || value.length === 0) {
|
|
65286
|
+
hasData = true;
|
|
65287
|
+
}
|
|
65288
|
+
} else {
|
|
65289
|
+
const objectFields = this.getSelection({
|
|
65290
|
+
parent: value,
|
|
65291
|
+
selection: fieldSelection,
|
|
65292
|
+
variables,
|
|
65293
|
+
stepsFromConnection: nextStep
|
|
65294
|
+
});
|
|
65295
|
+
target[attributeName] = objectFields.data;
|
|
65296
|
+
if (objectFields.partial) {
|
|
65297
|
+
partial = true;
|
|
65298
|
+
}
|
|
65299
|
+
if (objectFields.stale) {
|
|
65300
|
+
stale = true;
|
|
65301
|
+
}
|
|
65302
|
+
if (objectFields.hasData) {
|
|
65303
|
+
hasData = true;
|
|
65304
|
+
}
|
|
65305
|
+
}
|
|
65306
|
+
if (target[attributeName] === null && !nullable && !embeddedCursor) {
|
|
65307
|
+
cascadeNull = true;
|
|
65308
|
+
}
|
|
65309
|
+
}
|
|
65310
|
+
return {
|
|
65311
|
+
data: cascadeNull ? null : target,
|
|
65312
|
+
partial: hasData && partial,
|
|
65313
|
+
stale: hasData && stale,
|
|
65314
|
+
hasData
|
|
65315
|
+
};
|
|
65316
|
+
}
|
|
65317
|
+
id(type, data) {
|
|
65318
|
+
const id = typeof data === "string" ? data : this.computeID(type, data);
|
|
65319
|
+
if (!id) {
|
|
65320
|
+
return null;
|
|
65321
|
+
}
|
|
65322
|
+
if (!type) {
|
|
65323
|
+
return id;
|
|
65324
|
+
}
|
|
65325
|
+
return type + ":" + id;
|
|
65326
|
+
}
|
|
65327
|
+
idFields(type) {
|
|
65328
|
+
return keyFieldsForType(this.config, type);
|
|
65329
|
+
}
|
|
65330
|
+
computeID(type, data) {
|
|
65331
|
+
return computeID(this.config, type, data);
|
|
65332
|
+
}
|
|
65333
|
+
hydrateNestedList({
|
|
65334
|
+
fields,
|
|
65335
|
+
variables,
|
|
65336
|
+
linkedList,
|
|
65337
|
+
stepsFromConnection
|
|
65338
|
+
}) {
|
|
65339
|
+
const result = [];
|
|
65340
|
+
let partialData = false;
|
|
65341
|
+
let stale = false;
|
|
65342
|
+
let hasValues = false;
|
|
65343
|
+
for (const entry of linkedList) {
|
|
65344
|
+
if (Array.isArray(entry)) {
|
|
65345
|
+
const nestedValue = this.hydrateNestedList({
|
|
65346
|
+
fields,
|
|
65347
|
+
variables,
|
|
65348
|
+
linkedList: entry,
|
|
65349
|
+
stepsFromConnection
|
|
65350
|
+
});
|
|
65351
|
+
result.push(nestedValue.data);
|
|
65352
|
+
if (nestedValue.partial) {
|
|
65353
|
+
partialData = true;
|
|
65354
|
+
}
|
|
65355
|
+
continue;
|
|
65356
|
+
}
|
|
65357
|
+
if (entry === null) {
|
|
65358
|
+
result.push(entry);
|
|
65359
|
+
continue;
|
|
65360
|
+
}
|
|
65361
|
+
const {
|
|
65362
|
+
data,
|
|
65363
|
+
partial,
|
|
65364
|
+
stale: local_stale,
|
|
65365
|
+
hasData
|
|
65366
|
+
} = this.getSelection({
|
|
65367
|
+
parent: entry,
|
|
65368
|
+
selection: fields,
|
|
65369
|
+
variables,
|
|
65370
|
+
stepsFromConnection
|
|
65371
|
+
});
|
|
65372
|
+
result.push(data);
|
|
65373
|
+
if (partial) {
|
|
65374
|
+
partialData = true;
|
|
65375
|
+
}
|
|
65376
|
+
if (local_stale) {
|
|
65377
|
+
stale = true;
|
|
65378
|
+
}
|
|
65379
|
+
if (hasData) {
|
|
65380
|
+
hasValues = true;
|
|
65381
|
+
}
|
|
65382
|
+
}
|
|
65383
|
+
return {
|
|
65384
|
+
data: result,
|
|
65385
|
+
partial: partialData,
|
|
65386
|
+
stale,
|
|
65387
|
+
hasData: hasValues
|
|
65388
|
+
};
|
|
65389
|
+
}
|
|
65390
|
+
extractNestedListIDs({
|
|
65391
|
+
value,
|
|
65392
|
+
abstract,
|
|
65393
|
+
recordID,
|
|
65394
|
+
key,
|
|
65395
|
+
linkedType,
|
|
65396
|
+
fields,
|
|
65397
|
+
variables,
|
|
65398
|
+
applyUpdates,
|
|
65399
|
+
specs,
|
|
65400
|
+
layer,
|
|
65401
|
+
forceNotify
|
|
65402
|
+
}) {
|
|
65403
|
+
const nestedIDs = [];
|
|
65404
|
+
const newIDs = [];
|
|
65405
|
+
for (const [i2, entry] of value.entries()) {
|
|
65406
|
+
if (Array.isArray(entry)) {
|
|
65407
|
+
const inner = this.extractNestedListIDs({
|
|
65408
|
+
value: entry,
|
|
65409
|
+
abstract,
|
|
65410
|
+
recordID,
|
|
65411
|
+
key,
|
|
65412
|
+
linkedType,
|
|
65413
|
+
fields,
|
|
65414
|
+
variables,
|
|
65415
|
+
applyUpdates,
|
|
65416
|
+
specs,
|
|
65417
|
+
layer,
|
|
65418
|
+
forceNotify
|
|
65419
|
+
});
|
|
65420
|
+
newIDs.push(...inner.newIDs);
|
|
65421
|
+
nestedIDs[i2] = inner.nestedIDs;
|
|
65422
|
+
continue;
|
|
65423
|
+
}
|
|
65424
|
+
if (entry === null || typeof entry === "undefined") {
|
|
65425
|
+
newIDs.push(null);
|
|
65426
|
+
nestedIDs[i2] = null;
|
|
65427
|
+
continue;
|
|
65428
|
+
}
|
|
65429
|
+
const entryObj = entry;
|
|
65430
|
+
let linkedID = `${recordID}.${key}[${this.storage.nextRank}]`;
|
|
65431
|
+
const embedded = this.idFields(linkedType)?.filter(
|
|
65432
|
+
(field) => typeof entry[field] === "undefined"
|
|
65433
|
+
).length > 0;
|
|
65434
|
+
const typename = entryObj.__typename;
|
|
65435
|
+
let innerType = linkedType;
|
|
65436
|
+
if (abstract) {
|
|
65437
|
+
if (!typename) {
|
|
65438
|
+
throw new Error("Encountered interface type without __typename in the payload");
|
|
65439
|
+
}
|
|
65440
|
+
innerType = typename;
|
|
65441
|
+
}
|
|
65442
|
+
if (!embedded) {
|
|
65443
|
+
const id = this.id(innerType, entry);
|
|
65444
|
+
if (id) {
|
|
65445
|
+
linkedID = id;
|
|
65446
|
+
} else {
|
|
65447
|
+
continue;
|
|
65448
|
+
}
|
|
65449
|
+
}
|
|
65450
|
+
this.writeSelection({
|
|
65451
|
+
root: rootID,
|
|
65452
|
+
selection: fields,
|
|
65453
|
+
parent: linkedID,
|
|
65454
|
+
data: entryObj,
|
|
65455
|
+
variables,
|
|
65456
|
+
toNotify: specs,
|
|
65457
|
+
applyUpdates,
|
|
65458
|
+
layer,
|
|
65459
|
+
forceNotify
|
|
65460
|
+
});
|
|
65461
|
+
newIDs.push(linkedID);
|
|
65462
|
+
nestedIDs[i2] = linkedID;
|
|
65463
|
+
}
|
|
65464
|
+
return { newIDs, nestedIDs };
|
|
65465
|
+
}
|
|
65466
|
+
collectGarbage() {
|
|
65467
|
+
this.lifetimes.tick();
|
|
65468
|
+
if (this.storage.layerCount === 1) {
|
|
65469
|
+
this.storage.topLayer.removeUndefinedFields();
|
|
65470
|
+
}
|
|
65471
|
+
}
|
|
65472
|
+
};
|
|
65473
|
+
var rootID = "_ROOT_";
|
|
65474
|
+
|
|
65475
|
+
// src/runtime/cache/index.ts
|
|
65476
|
+
var cache_default = new Cache();
|
|
65477
|
+
|
|
65478
|
+
// src/runtime/client/plugins/cache.ts
|
|
65479
|
+
var cachePolicy = ({
|
|
65480
|
+
enabled,
|
|
65481
|
+
setFetching,
|
|
65482
|
+
cache: localCache = cache_default
|
|
65483
|
+
}) => () => {
|
|
65484
|
+
return {
|
|
65485
|
+
network(ctx, { initialValue, next, resolve: resolve2, marshalVariables: marshalVariables2 }) {
|
|
65486
|
+
const { policy, artifact } = ctx;
|
|
65487
|
+
let useCache = false;
|
|
65488
|
+
if (enabled && artifact.kind === ArtifactKind.Query && !ctx.cacheParams?.disableRead) {
|
|
65489
|
+
if (policy !== CachePolicy.NetworkOnly) {
|
|
65490
|
+
const value = localCache.read({
|
|
65491
|
+
selection: artifact.selection,
|
|
65492
|
+
variables: marshalVariables2(ctx)
|
|
65493
|
+
});
|
|
65494
|
+
const allowed = !value.partial || artifact.kind === ArtifactKind.Query && artifact.partial;
|
|
65495
|
+
if (policy === CachePolicy.CacheOnly) {
|
|
65496
|
+
return resolve2(ctx, {
|
|
65497
|
+
fetching: false,
|
|
65498
|
+
variables: ctx.variables ?? null,
|
|
65499
|
+
data: allowed ? value.data : initialValue.data,
|
|
65500
|
+
errors: null,
|
|
65501
|
+
source: DataSource.Cache,
|
|
65502
|
+
partial: allowed ? value.partial : false,
|
|
65503
|
+
stale: value.stale
|
|
65504
|
+
});
|
|
65505
|
+
}
|
|
65506
|
+
useCache = !!(value.data !== null && allowed);
|
|
65507
|
+
if (useCache) {
|
|
65508
|
+
resolve2(ctx, {
|
|
65509
|
+
fetching: false,
|
|
65510
|
+
variables: ctx.variables ?? null,
|
|
65511
|
+
data: value.data,
|
|
65512
|
+
errors: null,
|
|
65513
|
+
source: DataSource.Cache,
|
|
65514
|
+
partial: value.partial,
|
|
65515
|
+
stale: value.stale
|
|
65516
|
+
});
|
|
65517
|
+
}
|
|
65518
|
+
if (useCache && !value.partial && !value.stale) {
|
|
65519
|
+
return;
|
|
65520
|
+
}
|
|
65521
|
+
}
|
|
65522
|
+
}
|
|
65523
|
+
if (enabled) {
|
|
65524
|
+
setTimeout(() => {
|
|
65525
|
+
localCache._internal_unstable.collectGarbage();
|
|
65526
|
+
}, 0);
|
|
65527
|
+
}
|
|
65528
|
+
setFetching(!useCache);
|
|
65529
|
+
return next(ctx);
|
|
65530
|
+
},
|
|
65531
|
+
afterNetwork(ctx, { resolve: resolve2, value, marshalVariables: marshalVariables2 }) {
|
|
65532
|
+
if (value.source !== DataSource.Cache && enabled && value.data && !ctx.cacheParams?.disableWrite) {
|
|
65533
|
+
localCache.write({
|
|
65534
|
+
...ctx.cacheParams,
|
|
65535
|
+
layer: ctx.cacheParams?.layer?.id,
|
|
65536
|
+
selection: ctx.artifact.selection,
|
|
65537
|
+
data: value.data,
|
|
65538
|
+
variables: marshalVariables2(ctx)
|
|
65539
|
+
});
|
|
65540
|
+
}
|
|
65541
|
+
resolve2(ctx, value);
|
|
65542
|
+
}
|
|
65543
|
+
};
|
|
65544
|
+
};
|
|
65545
|
+
|
|
65546
|
+
// src/runtime/client/utils/documentPlugins.ts
|
|
65547
|
+
var documentPlugin = (kind, source) => {
|
|
65548
|
+
return () => {
|
|
65549
|
+
const sourceHandlers = source();
|
|
65550
|
+
const enterWrapper = (handler) => {
|
|
65551
|
+
return !handler ? void 0 : (ctx, handlers) => {
|
|
65552
|
+
if (ctx.artifact.kind !== kind) {
|
|
65553
|
+
return handlers.next(ctx);
|
|
65554
|
+
}
|
|
65555
|
+
return handler(ctx, handlers);
|
|
65556
|
+
};
|
|
65557
|
+
};
|
|
65558
|
+
const exitWrapper = (handler) => {
|
|
65559
|
+
return !handler ? void 0 : (ctx, handlers) => {
|
|
65560
|
+
if (ctx.artifact.kind !== kind) {
|
|
65561
|
+
return handlers.resolve(ctx);
|
|
65562
|
+
}
|
|
65563
|
+
return handler(ctx, handlers);
|
|
65564
|
+
};
|
|
65565
|
+
};
|
|
65566
|
+
return {
|
|
65567
|
+
start: enterWrapper(sourceHandlers.start),
|
|
65568
|
+
network: enterWrapper(sourceHandlers.network),
|
|
65569
|
+
afterNetwork: exitWrapper(sourceHandlers.afterNetwork),
|
|
65570
|
+
end: exitWrapper(sourceHandlers.end),
|
|
65571
|
+
catch: sourceHandlers.catch ? (ctx, handlers) => sourceHandlers.catch(ctx, handlers) : void 0,
|
|
65572
|
+
cleanup: (...args) => sourceHandlers.cleanup?.(...args)
|
|
65573
|
+
};
|
|
65574
|
+
};
|
|
65575
|
+
};
|
|
65576
|
+
|
|
65577
|
+
// src/runtime/client/plugins/query.ts
|
|
65578
|
+
var query = documentPlugin(ArtifactKind.Query, function() {
|
|
65579
|
+
let subscriptionSpec = null;
|
|
65580
|
+
let lastVariables = null;
|
|
65581
|
+
let artifactName = "";
|
|
65582
|
+
return {
|
|
65583
|
+
start(ctx, { next }) {
|
|
65584
|
+
ctx.variables = {
|
|
65585
|
+
...lastVariables,
|
|
65586
|
+
...ctx.variables
|
|
65587
|
+
};
|
|
65588
|
+
next(ctx);
|
|
65589
|
+
},
|
|
65590
|
+
end(ctx, { resolve: resolve2, marshalVariables: marshalVariables2, variablesChanged: variablesChanged2 }) {
|
|
65591
|
+
if (variablesChanged2(ctx)) {
|
|
65592
|
+
artifactName = ctx.artifact.name;
|
|
65593
|
+
if (subscriptionSpec) {
|
|
65594
|
+
cache_default.unsubscribe(subscriptionSpec, subscriptionSpec.variables?.() || {});
|
|
65595
|
+
}
|
|
65596
|
+
lastVariables = { ...marshalVariables2(ctx) };
|
|
65597
|
+
subscriptionSpec = {
|
|
65598
|
+
rootType: ctx.artifact.rootType,
|
|
65599
|
+
selection: ctx.artifact.selection,
|
|
65600
|
+
variables: () => lastVariables,
|
|
65601
|
+
set: (newValue) => {
|
|
65602
|
+
resolve2(ctx, {
|
|
65603
|
+
data: newValue,
|
|
65604
|
+
errors: null,
|
|
65605
|
+
fetching: false,
|
|
65606
|
+
partial: false,
|
|
65607
|
+
stale: false,
|
|
65608
|
+
source: DataSource.Cache,
|
|
65609
|
+
variables: ctx.variables ?? {}
|
|
65610
|
+
});
|
|
65611
|
+
}
|
|
65612
|
+
};
|
|
65613
|
+
cache_default.subscribe(subscriptionSpec, lastVariables ?? {});
|
|
65614
|
+
}
|
|
65615
|
+
resolve2(ctx);
|
|
65616
|
+
},
|
|
65617
|
+
cleanup() {
|
|
65618
|
+
if (subscriptionSpec) {
|
|
65619
|
+
cache_default.unsubscribe(subscriptionSpec, subscriptionSpec.variables?.() ?? {});
|
|
65620
|
+
lastVariables = null;
|
|
65621
|
+
}
|
|
65622
|
+
}
|
|
65623
|
+
};
|
|
65624
|
+
});
|
|
65625
|
+
|
|
65626
|
+
// src/runtime/client/plugins/mutation.ts
|
|
65627
|
+
var mutation = documentPlugin(ArtifactKind.Mutation, () => {
|
|
65628
|
+
return {
|
|
65629
|
+
async start(ctx, { next, marshalVariables: marshalVariables2 }) {
|
|
65630
|
+
const layer = cache_default._internal_unstable.storage.createLayer(true);
|
|
65631
|
+
const optimisticResponse = ctx.stuff.optimisticResponse;
|
|
65632
|
+
let toNotify = [];
|
|
65633
|
+
if (optimisticResponse) {
|
|
65634
|
+
toNotify = cache_default.write({
|
|
65635
|
+
selection: ctx.artifact.selection,
|
|
65636
|
+
data: await marshalSelection({
|
|
65637
|
+
selection: ctx.artifact.selection,
|
|
65638
|
+
data: optimisticResponse
|
|
65639
|
+
}),
|
|
65640
|
+
variables: marshalVariables2(ctx),
|
|
65641
|
+
layer: layer.id
|
|
65642
|
+
});
|
|
65643
|
+
}
|
|
65644
|
+
ctx.cacheParams = {
|
|
65645
|
+
...ctx.cacheParams,
|
|
65646
|
+
layer,
|
|
65647
|
+
notifySubscribers: toNotify,
|
|
65648
|
+
forceNotify: true
|
|
65649
|
+
};
|
|
65650
|
+
next(ctx);
|
|
65651
|
+
},
|
|
65652
|
+
afterNetwork(ctx, { resolve: resolve2 }) {
|
|
65653
|
+
ctx.cacheParams?.layer?.clear();
|
|
65654
|
+
resolve2(ctx);
|
|
65655
|
+
},
|
|
65656
|
+
end(ctx, { resolve: resolve2, value }) {
|
|
65657
|
+
const hasErrors = value.errors && value.errors.length > 0;
|
|
65658
|
+
if (hasErrors) {
|
|
65659
|
+
ctx.cacheParams?.layer?.clear();
|
|
65660
|
+
}
|
|
65661
|
+
if (ctx.cacheParams?.layer) {
|
|
65662
|
+
cache_default._internal_unstable.storage.resolveLayer(ctx.cacheParams.layer.id);
|
|
65663
|
+
}
|
|
65664
|
+
resolve2(ctx);
|
|
65665
|
+
},
|
|
65666
|
+
catch(ctx, { error }) {
|
|
65667
|
+
if (ctx.cacheParams?.layer) {
|
|
65668
|
+
const { layer } = ctx.cacheParams;
|
|
65669
|
+
layer.clear();
|
|
65670
|
+
cache_default._internal_unstable.storage.resolveLayer(layer.id);
|
|
65671
|
+
}
|
|
65672
|
+
throw error;
|
|
65673
|
+
}
|
|
65674
|
+
};
|
|
65675
|
+
});
|
|
65676
|
+
|
|
65677
|
+
// src/runtime/client/plugins/subscription.ts
|
|
65678
|
+
function subscription(factory) {
|
|
65679
|
+
return documentPlugin(ArtifactKind.Subscription, () => {
|
|
65680
|
+
let clearSubscription = null;
|
|
65681
|
+
let socketClient = null;
|
|
65682
|
+
let check = null;
|
|
65683
|
+
return {
|
|
65684
|
+
start(ctx, { resolve: resolve2, next, initialValue }) {
|
|
65685
|
+
if (typeof globalThis.window === "undefined") {
|
|
65686
|
+
resolve2(ctx, initialValue);
|
|
65687
|
+
return;
|
|
65688
|
+
}
|
|
65689
|
+
next(ctx);
|
|
65690
|
+
},
|
|
65691
|
+
network(ctx, { resolve: resolve2, initialValue, variablesChanged: variablesChanged2, marshalVariables: marshalVariables2 }) {
|
|
65692
|
+
const checkValue = {
|
|
65693
|
+
fetchParams: ctx.fetchParams ?? {},
|
|
65694
|
+
session: ctx.session ?? {},
|
|
65695
|
+
metadata: ctx.metadata ?? {}
|
|
65696
|
+
};
|
|
65697
|
+
const changed = variablesChanged2(ctx);
|
|
65698
|
+
const sessionChange = !deepEquals(check, checkValue);
|
|
65699
|
+
if (!changed && !sessionChange) {
|
|
65700
|
+
resolve2(ctx, initialValue);
|
|
65701
|
+
return;
|
|
65702
|
+
}
|
|
65703
|
+
check = checkValue;
|
|
65704
|
+
clearSubscription?.();
|
|
65705
|
+
if (!socketClient || sessionChange) {
|
|
65706
|
+
socketClient = factory(ctx);
|
|
65707
|
+
}
|
|
65708
|
+
clearSubscription = socketClient.subscribe(
|
|
65709
|
+
{
|
|
65710
|
+
query: ctx.artifact.raw,
|
|
65711
|
+
variables: marshalVariables2(ctx)
|
|
65712
|
+
},
|
|
65713
|
+
{
|
|
65714
|
+
next: ({ data, errors }) => {
|
|
65715
|
+
resolve2(ctx, {
|
|
65716
|
+
data: data ?? null,
|
|
65717
|
+
errors: [...errors ?? []],
|
|
65718
|
+
fetching: false,
|
|
65719
|
+
partial: true,
|
|
65720
|
+
stale: false,
|
|
65721
|
+
source: DataSource.Network,
|
|
65722
|
+
variables: ctx.variables ?? {}
|
|
65723
|
+
});
|
|
65724
|
+
},
|
|
65725
|
+
error(data) {
|
|
65726
|
+
clearSubscription?.();
|
|
65727
|
+
resolve2(ctx, {
|
|
65728
|
+
partial: true,
|
|
65729
|
+
stale: false,
|
|
65730
|
+
source: DataSource.Network,
|
|
65731
|
+
data: null,
|
|
65732
|
+
errors: [data],
|
|
65733
|
+
fetching: false,
|
|
65734
|
+
variables: ctx.variables ?? {}
|
|
65735
|
+
});
|
|
65736
|
+
},
|
|
65737
|
+
complete() {
|
|
65738
|
+
}
|
|
65739
|
+
}
|
|
65740
|
+
);
|
|
65741
|
+
},
|
|
65742
|
+
cleanup() {
|
|
65743
|
+
clearSubscription?.();
|
|
65744
|
+
}
|
|
65745
|
+
};
|
|
65746
|
+
});
|
|
65747
|
+
}
|
|
65748
|
+
|
|
65749
|
+
// src/runtime/client/plugins/throwOnError.ts
|
|
65750
|
+
var throwOnError = ({ operations, error }) => () => {
|
|
65751
|
+
const all = operations.includes("all");
|
|
65752
|
+
const throwOnKind = (kind) => all || {
|
|
65753
|
+
[ArtifactKind.Query]: operations.includes("query"),
|
|
65754
|
+
[ArtifactKind.Mutation]: operations.includes("mutation"),
|
|
65755
|
+
[ArtifactKind.Fragment]: false,
|
|
65756
|
+
[ArtifactKind.Subscription]: operations.includes("subscription")
|
|
65757
|
+
}[kind];
|
|
65758
|
+
return {
|
|
65759
|
+
async end(ctx, { value, resolve: resolve2 }) {
|
|
65760
|
+
if (value.errors && value.errors.length > 0 && throwOnKind(ctx.artifact.kind)) {
|
|
65761
|
+
const result = await (error ?? defaultErrorFn)(value.errors);
|
|
65762
|
+
throw result;
|
|
65763
|
+
}
|
|
65764
|
+
resolve2(ctx);
|
|
65765
|
+
}
|
|
65766
|
+
};
|
|
65767
|
+
};
|
|
65768
|
+
var defaultErrorFn = async (errors) => new Error(errors.map((error) => error.message).join(". ") + ".");
|
|
65769
|
+
|
|
65770
|
+
// src/runtime/client/plugins/fetchParams.ts
|
|
65771
|
+
var fetchParams = (fn = () => ({})) => () => ({
|
|
65772
|
+
beforeNetwork(ctx, { next, marshalVariables: marshalVariables2 }) {
|
|
65773
|
+
next({
|
|
65774
|
+
...ctx,
|
|
65775
|
+
fetchParams: fn({
|
|
65776
|
+
config: ctx.config,
|
|
65777
|
+
policy: ctx.policy,
|
|
65778
|
+
metadata: ctx.metadata,
|
|
65779
|
+
session: ctx.session,
|
|
65780
|
+
stuff: ctx.stuff,
|
|
65781
|
+
document: ctx.artifact,
|
|
65782
|
+
variables: marshalVariables2(ctx),
|
|
65783
|
+
text: ctx.artifact.raw,
|
|
65784
|
+
hash: ctx.artifact.hash
|
|
65785
|
+
})
|
|
65786
|
+
});
|
|
65787
|
+
}
|
|
65788
|
+
});
|
|
65789
|
+
|
|
65790
|
+
// src/runtime/client/documentStore.ts
|
|
65791
|
+
var steps = {
|
|
65792
|
+
forward: ["start", "beforeNetwork", "network"],
|
|
65793
|
+
backwards: ["end", "afterNetwork"]
|
|
65794
|
+
};
|
|
65795
|
+
var DocumentStore = class extends Writable {
|
|
65796
|
+
#artifact;
|
|
65797
|
+
#client;
|
|
65798
|
+
#configFile;
|
|
65799
|
+
#plugins;
|
|
65800
|
+
#lastVariables;
|
|
65801
|
+
#lastContext = null;
|
|
65802
|
+
constructor({
|
|
65803
|
+
artifact,
|
|
65804
|
+
plugins: plugins2,
|
|
65805
|
+
pipeline: pipeline2,
|
|
65806
|
+
client,
|
|
65807
|
+
cache = true,
|
|
65808
|
+
initialValue,
|
|
65809
|
+
fetching
|
|
65810
|
+
}) {
|
|
65811
|
+
fetching ??= artifact.kind === ArtifactKind.Query;
|
|
65812
|
+
const initialState = {
|
|
65813
|
+
data: initialValue ?? null,
|
|
65814
|
+
errors: null,
|
|
65815
|
+
partial: false,
|
|
65816
|
+
stale: false,
|
|
65817
|
+
source: null,
|
|
65818
|
+
fetching,
|
|
65819
|
+
variables: null
|
|
65820
|
+
};
|
|
65821
|
+
super(initialState, () => {
|
|
65822
|
+
return () => {
|
|
65823
|
+
this.#lastVariables = null;
|
|
65824
|
+
for (const plugin2 of this.#plugins) {
|
|
65825
|
+
plugin2.cleanup?.(this.#lastContext);
|
|
65826
|
+
}
|
|
65827
|
+
};
|
|
65828
|
+
});
|
|
65829
|
+
this.#artifact = artifact;
|
|
65830
|
+
this.#client = client;
|
|
65831
|
+
this.#lastVariables = null;
|
|
65832
|
+
this.#configFile = getCurrentConfig();
|
|
65833
|
+
this.#plugins = pipeline2 ?? [
|
|
65834
|
+
cachePolicy({
|
|
65835
|
+
enabled: cache,
|
|
65836
|
+
setFetching: (fetching2) => this.update((state) => ({ ...state, fetching: fetching2 }))
|
|
65837
|
+
})(),
|
|
65838
|
+
...plugins2 ?? []
|
|
65839
|
+
];
|
|
65840
|
+
}
|
|
65841
|
+
async send({
|
|
65842
|
+
metadata,
|
|
65843
|
+
session,
|
|
65844
|
+
fetch: fetch3 = globalThis.fetch,
|
|
65845
|
+
variables,
|
|
65846
|
+
policy,
|
|
65847
|
+
stuff,
|
|
65848
|
+
cacheParams,
|
|
65849
|
+
setup = false,
|
|
65850
|
+
silenceEcho = false
|
|
65851
|
+
} = {}) {
|
|
65852
|
+
let context = new ClientPluginContextWrapper({
|
|
65853
|
+
config: this.#configFile,
|
|
65854
|
+
text: this.#artifact.raw,
|
|
65855
|
+
hash: this.#artifact.hash,
|
|
65856
|
+
policy: policy ?? this.#artifact.policy,
|
|
65857
|
+
variables: null,
|
|
65858
|
+
metadata,
|
|
65859
|
+
session,
|
|
65860
|
+
fetch: fetch3,
|
|
65861
|
+
stuff: {
|
|
65862
|
+
inputs: {
|
|
65863
|
+
changed: false,
|
|
65864
|
+
init: false,
|
|
65865
|
+
marshaled: {}
|
|
65866
|
+
},
|
|
65867
|
+
...stuff
|
|
65868
|
+
},
|
|
65869
|
+
artifact: this.#artifact,
|
|
65870
|
+
lastVariables: this.#lastVariables,
|
|
65871
|
+
cacheParams
|
|
65872
|
+
});
|
|
65873
|
+
const draft = context.draft();
|
|
65874
|
+
draft.variables = variables ?? null;
|
|
65875
|
+
context = context.apply(draft, false);
|
|
65876
|
+
return await new Promise((resolve2, reject) => {
|
|
65877
|
+
const state = {
|
|
65878
|
+
setup,
|
|
65879
|
+
currentStep: 0,
|
|
65880
|
+
index: 0,
|
|
65881
|
+
silenceEcho,
|
|
65882
|
+
promise: {
|
|
65883
|
+
resolved: false,
|
|
65884
|
+
resolve: resolve2,
|
|
65885
|
+
reject
|
|
65886
|
+
},
|
|
65887
|
+
context
|
|
65888
|
+
};
|
|
65889
|
+
this.#step("forward", state);
|
|
65890
|
+
});
|
|
65891
|
+
}
|
|
65892
|
+
#step(direction, ctx, value) {
|
|
65893
|
+
const hook = direction === "error" ? "catch" : steps[direction][ctx.currentStep];
|
|
65894
|
+
let valid = (i2) => i2 <= this.#plugins.length;
|
|
65895
|
+
let step = (i2) => i2 + 1;
|
|
65896
|
+
if (["backwards", "error"].includes(direction)) {
|
|
65897
|
+
valid = (i2) => i2 >= 0;
|
|
65898
|
+
step = (i2) => i2 - 1;
|
|
65899
|
+
}
|
|
65900
|
+
for (let index = ctx.index; valid(index); index = step(index)) {
|
|
65901
|
+
let target = this.#plugins[index]?.[hook];
|
|
65902
|
+
if (!target) {
|
|
65903
|
+
continue;
|
|
65904
|
+
}
|
|
65905
|
+
const draft = ctx.context.draft();
|
|
65906
|
+
let variablesRefChanged = (newContext) => newContext.variables !== draft.variables;
|
|
65907
|
+
const common = {
|
|
65908
|
+
initialValue: this.state,
|
|
65909
|
+
client: this.#client,
|
|
65910
|
+
variablesChanged,
|
|
65911
|
+
marshalVariables,
|
|
65912
|
+
updateState: this.update.bind(this),
|
|
65913
|
+
next: (newContext) => {
|
|
65914
|
+
const nextIndex = ["forward", "error"].includes(direction) ? index + 1 : index;
|
|
65915
|
+
const nextStep = ["backwards", "error"].includes(direction) ? 0 : ctx.currentStep;
|
|
65916
|
+
this.#step("forward", {
|
|
65917
|
+
...ctx,
|
|
65918
|
+
index: nextIndex,
|
|
65919
|
+
currentStep: nextStep,
|
|
65920
|
+
context: ctx.context.apply(newContext, variablesRefChanged(newContext))
|
|
65921
|
+
});
|
|
65922
|
+
},
|
|
65923
|
+
resolve: (newContext, value2) => {
|
|
65924
|
+
const nextIndex = direction === "backwards" ? index - 1 : index;
|
|
65925
|
+
this.#step(
|
|
65926
|
+
"backwards",
|
|
65927
|
+
{
|
|
65928
|
+
...ctx,
|
|
65929
|
+
index: nextIndex,
|
|
65930
|
+
context: ctx.context.apply(newContext, variablesRefChanged(newContext))
|
|
65931
|
+
},
|
|
65932
|
+
value2
|
|
65933
|
+
);
|
|
65934
|
+
}
|
|
65935
|
+
};
|
|
65936
|
+
let handlers;
|
|
65937
|
+
if (direction === "forward") {
|
|
65938
|
+
handlers = common;
|
|
65939
|
+
} else if (direction === "backwards") {
|
|
65940
|
+
handlers = {
|
|
65941
|
+
...common,
|
|
65942
|
+
value,
|
|
65943
|
+
resolve: (ctx2, data2) => {
|
|
65944
|
+
return common.resolve(ctx2, data2 ?? value);
|
|
65945
|
+
}
|
|
65946
|
+
};
|
|
65947
|
+
} else if (direction === "error") {
|
|
65948
|
+
handlers = {
|
|
65949
|
+
...common,
|
|
65950
|
+
error: value
|
|
65951
|
+
};
|
|
65952
|
+
}
|
|
65953
|
+
try {
|
|
65954
|
+
const result = target(draft, handlers);
|
|
65955
|
+
result?.catch((err) => {
|
|
65956
|
+
this.#step("error", { ...ctx, index: index - 1 }, err);
|
|
65957
|
+
});
|
|
65958
|
+
} catch (err) {
|
|
65959
|
+
this.#step("error", { ...ctx, index: index - 1 }, err);
|
|
65960
|
+
}
|
|
65961
|
+
return;
|
|
65962
|
+
}
|
|
65963
|
+
if (direction === "forward") {
|
|
65964
|
+
if (ctx.setup) {
|
|
65965
|
+
return this.#step(
|
|
65966
|
+
"backwards",
|
|
65967
|
+
{
|
|
65968
|
+
...ctx,
|
|
65969
|
+
currentStep: 0,
|
|
65970
|
+
index: this.#plugins.length
|
|
65971
|
+
},
|
|
65972
|
+
this.state
|
|
65973
|
+
);
|
|
65974
|
+
}
|
|
65975
|
+
if (ctx.currentStep <= steps.forward.length - 2) {
|
|
65976
|
+
return this.#step("forward", {
|
|
65977
|
+
...ctx,
|
|
65978
|
+
currentStep: ctx.currentStep + 1,
|
|
65979
|
+
index: 0
|
|
65980
|
+
});
|
|
65981
|
+
}
|
|
65982
|
+
throw new Error(
|
|
65983
|
+
"Called next() on last possible plugin. Your chain is missing a plugin that calls resolve()."
|
|
65984
|
+
);
|
|
65985
|
+
}
|
|
65986
|
+
if (direction === "error") {
|
|
65987
|
+
if (!ctx.promise.resolved) {
|
|
65988
|
+
ctx.promise.reject(value);
|
|
65989
|
+
ctx.promise.resolved = true;
|
|
65990
|
+
}
|
|
65991
|
+
return;
|
|
65992
|
+
}
|
|
65993
|
+
if (ctx.currentStep > 0) {
|
|
65994
|
+
return this.#step(
|
|
65995
|
+
"backwards",
|
|
65996
|
+
{
|
|
65997
|
+
...ctx,
|
|
65998
|
+
currentStep: ctx.currentStep - 1,
|
|
65999
|
+
index: this.#plugins.length - 1
|
|
66000
|
+
},
|
|
66001
|
+
value
|
|
66002
|
+
);
|
|
66003
|
+
}
|
|
66004
|
+
let data = value.data;
|
|
66005
|
+
try {
|
|
66006
|
+
data = unmarshalSelection(this.#configFile, this.#artifact.selection, data) ?? null;
|
|
66007
|
+
} catch {
|
|
66008
|
+
}
|
|
66009
|
+
const finalValue = {
|
|
66010
|
+
...value,
|
|
66011
|
+
data
|
|
66012
|
+
};
|
|
66013
|
+
if (!ctx.promise.resolved) {
|
|
66014
|
+
ctx.promise.resolve(finalValue);
|
|
66015
|
+
ctx.promise.resolved = true;
|
|
66016
|
+
}
|
|
66017
|
+
this.#lastContext = ctx.context.draft();
|
|
66018
|
+
this.#lastVariables = this.#lastContext.stuff.inputs.marshaled;
|
|
66019
|
+
if (ctx.silenceEcho && finalValue.data === this.state.data) {
|
|
66020
|
+
return;
|
|
66021
|
+
}
|
|
66022
|
+
this.set(finalValue);
|
|
66023
|
+
}
|
|
66024
|
+
};
|
|
66025
|
+
var ClientPluginContextWrapper = class {
|
|
66026
|
+
#context;
|
|
66027
|
+
#lastVariables;
|
|
66028
|
+
constructor({
|
|
66029
|
+
lastVariables,
|
|
66030
|
+
...values
|
|
66031
|
+
}) {
|
|
66032
|
+
this.#context = values;
|
|
66033
|
+
this.#lastVariables = lastVariables;
|
|
66034
|
+
}
|
|
66035
|
+
get variables() {
|
|
66036
|
+
return this.#context.variables;
|
|
66037
|
+
}
|
|
66038
|
+
draft() {
|
|
66039
|
+
const ctx = {
|
|
66040
|
+
...this.#context
|
|
66041
|
+
};
|
|
66042
|
+
const applyVariables = this.applyVariables.bind(this);
|
|
66043
|
+
return {
|
|
66044
|
+
...ctx,
|
|
66045
|
+
get stuff() {
|
|
66046
|
+
return ctx.stuff;
|
|
66047
|
+
},
|
|
66048
|
+
set stuff(val) {
|
|
66049
|
+
ctx.stuff = val;
|
|
66050
|
+
},
|
|
66051
|
+
get variables() {
|
|
66052
|
+
return ctx.variables ?? null;
|
|
66053
|
+
},
|
|
66054
|
+
set variables(val) {
|
|
66055
|
+
Object.assign(ctx, applyVariables(ctx, { variables: val }));
|
|
66056
|
+
}
|
|
66057
|
+
};
|
|
66058
|
+
}
|
|
66059
|
+
applyVariables(source, values) {
|
|
66060
|
+
const artifact = source.artifact;
|
|
66061
|
+
const ctx = {
|
|
66062
|
+
...source,
|
|
66063
|
+
...values
|
|
66064
|
+
};
|
|
66065
|
+
const val = values.variables;
|
|
66066
|
+
let changed = {};
|
|
66067
|
+
for (const [name, value] of Object.entries(val ?? {})) {
|
|
66068
|
+
if (value !== source.variables?.[name]) {
|
|
66069
|
+
changed[name] = value;
|
|
66070
|
+
}
|
|
66071
|
+
}
|
|
66072
|
+
ctx.stuff = {
|
|
66073
|
+
...ctx.stuff,
|
|
66074
|
+
inputs: {
|
|
66075
|
+
...ctx.stuff.inputs
|
|
66076
|
+
}
|
|
66077
|
+
};
|
|
66078
|
+
const firstInit = !ctx.stuff.inputs || !ctx.stuff.inputs.init;
|
|
66079
|
+
const hasChanged = Object.keys(changed).length > 0 || firstInit;
|
|
66080
|
+
if (artifact.kind !== ArtifactKind.Fragment && hasChanged) {
|
|
66081
|
+
const newVariables = {
|
|
66082
|
+
...ctx.stuff.inputs?.marshaled,
|
|
66083
|
+
...marshalInputs({
|
|
66084
|
+
artifact,
|
|
66085
|
+
input: changed,
|
|
66086
|
+
config: source.config
|
|
66087
|
+
})
|
|
66088
|
+
};
|
|
66089
|
+
ctx.stuff.inputs = {
|
|
66090
|
+
init: true,
|
|
66091
|
+
marshaled: newVariables,
|
|
66092
|
+
changed: true
|
|
66093
|
+
};
|
|
66094
|
+
ctx.variables = val;
|
|
66095
|
+
}
|
|
66096
|
+
ctx.stuff = {
|
|
66097
|
+
...ctx.stuff,
|
|
66098
|
+
inputs: {
|
|
66099
|
+
...ctx.stuff.inputs,
|
|
66100
|
+
changed: !deepEquals(ctx.stuff.inputs.marshaled, this.#lastVariables)
|
|
66101
|
+
}
|
|
66102
|
+
};
|
|
66103
|
+
return ctx;
|
|
66104
|
+
}
|
|
66105
|
+
apply(values, newVariables) {
|
|
66106
|
+
if (newVariables) {
|
|
66107
|
+
values = this.applyVariables(this.#context, values);
|
|
66108
|
+
}
|
|
66109
|
+
const wrapper = new ClientPluginContextWrapper({
|
|
66110
|
+
...values,
|
|
66111
|
+
lastVariables: this.#lastVariables
|
|
66112
|
+
});
|
|
66113
|
+
return wrapper;
|
|
66114
|
+
}
|
|
66115
|
+
};
|
|
66116
|
+
function marshalVariables(ctx) {
|
|
66117
|
+
return ctx.stuff.inputs?.marshaled ?? {};
|
|
66118
|
+
}
|
|
66119
|
+
function variablesChanged(ctx) {
|
|
66120
|
+
return ctx.stuff.inputs?.changed;
|
|
66121
|
+
}
|
|
66122
|
+
|
|
66123
|
+
// src/runtime/client/plugins/injectedPlugins.ts
|
|
66124
|
+
var plugins = [];
|
|
66125
|
+
var injectedPlugins_default = plugins;
|
|
66126
|
+
|
|
66127
|
+
// src/runtime/client/index.ts
|
|
66128
|
+
var HoudiniClient = class {
|
|
66129
|
+
url;
|
|
66130
|
+
#plugins;
|
|
66131
|
+
constructor({ url, fetchParams: fetchParams2, plugins: plugins2, pipeline: pipeline2, throwOnError: throwOnError2 }) {
|
|
66132
|
+
if (plugins2 && pipeline2) {
|
|
66133
|
+
throw new Error(
|
|
66134
|
+
"A client cannot be given a pipeline and a list of plugins at the same time."
|
|
66135
|
+
);
|
|
66136
|
+
}
|
|
66137
|
+
this.#plugins = flatten(
|
|
66138
|
+
[].concat(
|
|
66139
|
+
throwOnError2 ? [throwOnError(throwOnError2)] : [],
|
|
66140
|
+
fetchParams(fetchParams2),
|
|
66141
|
+
pipeline2 ?? [
|
|
66142
|
+
query,
|
|
66143
|
+
mutation
|
|
66144
|
+
].concat(
|
|
66145
|
+
plugins2 ?? [],
|
|
66146
|
+
injectedPlugins_default,
|
|
66147
|
+
fetch2()
|
|
66148
|
+
)
|
|
66149
|
+
)
|
|
66150
|
+
);
|
|
66151
|
+
this.url = url;
|
|
66152
|
+
}
|
|
66153
|
+
observe({
|
|
66154
|
+
artifact,
|
|
66155
|
+
cache = true,
|
|
66156
|
+
initialValue,
|
|
66157
|
+
fetching = false
|
|
66158
|
+
}) {
|
|
66159
|
+
return new DocumentStore({
|
|
66160
|
+
client: this,
|
|
66161
|
+
artifact,
|
|
66162
|
+
plugins: createPluginHooks(this.#plugins),
|
|
66163
|
+
cache,
|
|
66164
|
+
initialValue,
|
|
66165
|
+
fetching
|
|
66166
|
+
});
|
|
66167
|
+
}
|
|
66168
|
+
};
|
|
66169
|
+
function createPluginHooks(plugins2) {
|
|
66170
|
+
return plugins2.reduce((hooks, plugin2) => {
|
|
66171
|
+
if (typeof plugin2 !== "function") {
|
|
66172
|
+
throw new Error("Encountered client plugin that's not a function");
|
|
66173
|
+
}
|
|
66174
|
+
const result = plugin2();
|
|
66175
|
+
if (!result) {
|
|
66176
|
+
return hooks;
|
|
66177
|
+
}
|
|
66178
|
+
if (!Array.isArray(result)) {
|
|
66179
|
+
return hooks.concat(result);
|
|
66180
|
+
}
|
|
66181
|
+
for (const value of result) {
|
|
66182
|
+
if (!value) {
|
|
66183
|
+
continue;
|
|
66184
|
+
}
|
|
66185
|
+
if (typeof value === "function") {
|
|
66186
|
+
return hooks.concat(createPluginHooks([value]));
|
|
66187
|
+
}
|
|
66188
|
+
hooks.push(value);
|
|
66189
|
+
}
|
|
66190
|
+
return hooks;
|
|
66191
|
+
}, []);
|
|
66192
|
+
}
|
|
66193
|
+
|
|
63222
66194
|
// src/lib/types.ts
|
|
63223
|
-
var LogLevel =
|
|
63224
|
-
|
|
63225
|
-
|
|
63226
|
-
|
|
63227
|
-
|
|
63228
|
-
|
|
63229
|
-
})(LogLevel || {});
|
|
66195
|
+
var LogLevel = {
|
|
66196
|
+
Full: "full",
|
|
66197
|
+
Summary: "summary",
|
|
66198
|
+
ShortSummary: "short-summary",
|
|
66199
|
+
Quiet: "quiet"
|
|
66200
|
+
};
|
|
63230
66201
|
|
|
63231
66202
|
// src/lib/config.ts
|
|
63232
66203
|
var import_meta = {};
|
|
@@ -63278,7 +66249,7 @@ var Config = class {
|
|
|
63278
66249
|
scalars,
|
|
63279
66250
|
cacheBufferSize,
|
|
63280
66251
|
definitionsPath,
|
|
63281
|
-
defaultCachePolicy =
|
|
66252
|
+
defaultCachePolicy = CachePolicy.CacheOrNetwork,
|
|
63282
66253
|
defaultPartial = false,
|
|
63283
66254
|
defaultListPosition = "append",
|
|
63284
66255
|
defaultListTarget = null,
|
|
@@ -63300,7 +66271,7 @@ var Config = class {
|
|
|
63300
66271
|
Object.values(LogLevel)
|
|
63301
66272
|
)}`
|
|
63302
66273
|
);
|
|
63303
|
-
logLevel =
|
|
66274
|
+
logLevel = LogLevel.Summary;
|
|
63304
66275
|
}
|
|
63305
66276
|
this.schemaPath = schemaPath;
|
|
63306
66277
|
this.filepath = filepath;
|
|
@@ -63316,7 +66287,7 @@ var Config = class {
|
|
|
63316
66287
|
this.internalListPosition = defaultListPosition === "append" ? "last" : "first";
|
|
63317
66288
|
this.defaultListTarget = defaultListTarget;
|
|
63318
66289
|
this.definitionsFolder = definitionsPath;
|
|
63319
|
-
this.logLevel = (logLevel ||
|
|
66290
|
+
this.logLevel = (logLevel || LogLevel.Summary).toLowerCase();
|
|
63320
66291
|
this.defaultFragmentMasking = defaultFragmentMasking;
|
|
63321
66292
|
this.routesDir = join2(this.projectRoot, "src", "routes");
|
|
63322
66293
|
this.schemaPollInterval = watchSchema?.interval ?? 2e3;
|
|
@@ -63657,8 +66628,10 @@ var Config = class {
|
|
|
63657
66628
|
return node.name.value === "CachePolicy";
|
|
63658
66629
|
}
|
|
63659
66630
|
isInternalDirective(name) {
|
|
63660
|
-
const internalDirectives = this.#newSchemaInstance?.getDirectives().
|
|
63661
|
-
|
|
66631
|
+
const internalDirectives = this.#newSchemaInstance?.getDirectives().reduce((list, directive) => {
|
|
66632
|
+
return list.concat(directive.name);
|
|
66633
|
+
}, []) ?? [];
|
|
66634
|
+
return !defaultDirectives.includes(name) && (internalDirectives.includes(name) || this.isDeleteDirective(name));
|
|
63662
66635
|
}
|
|
63663
66636
|
isListFragment(name) {
|
|
63664
66637
|
return name.endsWith(this.insertFragmentSuffix) || name.endsWith(this.removeFragmentSuffix) || name.endsWith(this.toggleFragmentSuffix);
|
|
@@ -63762,10 +66735,16 @@ async function getConfig({
|
|
|
63762
66735
|
await flattenPluginList(configPath, hooksList, pluginName, pluginFile)
|
|
63763
66736
|
);
|
|
63764
66737
|
}
|
|
63765
|
-
const
|
|
63766
|
-
for (const plugin2 of
|
|
66738
|
+
const plugins2 = pluginsNested.flat();
|
|
66739
|
+
for (const plugin2 of plugins2) {
|
|
63767
66740
|
if (plugin2.config) {
|
|
63768
|
-
|
|
66741
|
+
try {
|
|
66742
|
+
const configFactory = await import(plugin2.config);
|
|
66743
|
+
const newValue = typeof configFactory === "function" ? configFactory(configFile) : configFactory;
|
|
66744
|
+
configFile = deepMerge(configPath, configFile, newValue);
|
|
66745
|
+
} catch {
|
|
66746
|
+
console.log("could not load config file" + plugin2.config);
|
|
66747
|
+
}
|
|
63769
66748
|
}
|
|
63770
66749
|
}
|
|
63771
66750
|
_config = new Config({
|
|
@@ -63791,7 +66770,7 @@ async function getConfig({
|
|
|
63791
66770
|
_config.schema = await loadSchemaFile(_config.schemaPath);
|
|
63792
66771
|
}
|
|
63793
66772
|
}
|
|
63794
|
-
_config.plugins = orderedPlugins(
|
|
66773
|
+
_config.plugins = orderedPlugins(plugins2);
|
|
63795
66774
|
await Promise.all(_config.plugins.map((plugin2) => plugin2.afterLoad?.({ config: _config })));
|
|
63796
66775
|
resolve2(_config);
|
|
63797
66776
|
return _config;
|
|
@@ -63845,13 +66824,13 @@ ${e2.message}`);
|
|
|
63845
66824
|
const config = imported.default || imported;
|
|
63846
66825
|
return config;
|
|
63847
66826
|
}
|
|
63848
|
-
var orderedPlugins = (
|
|
63849
|
-
const ordered =
|
|
66827
|
+
var orderedPlugins = (plugins2) => {
|
|
66828
|
+
const ordered = plugins2.filter(
|
|
63850
66829
|
(plugin2) => plugin2.order === "before" || plugin2.order === void 0
|
|
63851
66830
|
);
|
|
63852
66831
|
ordered.push(
|
|
63853
|
-
...
|
|
63854
|
-
...
|
|
66832
|
+
...plugins2.filter((plugin2) => plugin2.order === "core"),
|
|
66833
|
+
...plugins2.filter((plugin2) => plugin2.order === "after")
|
|
63855
66834
|
);
|
|
63856
66835
|
return ordered;
|
|
63857
66836
|
};
|
|
@@ -63923,6 +66902,8 @@ async function loadSchemaFile(schemaPath) {
|
|
|
63923
66902
|
}
|
|
63924
66903
|
return graphql2.buildClientSchema(jsonContents);
|
|
63925
66904
|
}
|
|
66905
|
+
var emptySchema = graphql2.buildSchema("type Query { hello: String }");
|
|
66906
|
+
var defaultDirectives = emptySchema.getDirectives().map((dir) => dir.name);
|
|
63926
66907
|
|
|
63927
66908
|
// src/lib/graphql.ts
|
|
63928
66909
|
var graphql3 = __toESM(require_graphql2(), 1);
|
|
@@ -63939,7 +66920,7 @@ function getRootType(type) {
|
|
|
63939
66920
|
function hashDocument({
|
|
63940
66921
|
document
|
|
63941
66922
|
}) {
|
|
63942
|
-
const docString = typeof document === "string" ? document : document.
|
|
66923
|
+
const docString = typeof document === "string" ? document : document.originalString;
|
|
63943
66924
|
return import_node_crypto.default.createHash("sha256").update(docString ?? "").digest("hex");
|
|
63944
66925
|
}
|
|
63945
66926
|
function parentTypeFromAncestors(schema, filepath, ancestors) {
|
|
@@ -64363,17 +67344,21 @@ async function find_graphql(config, parsedScript, walker) {
|
|
|
64363
67344
|
CompiledSubscriptionKind,
|
|
64364
67345
|
Config,
|
|
64365
67346
|
DataSource,
|
|
67347
|
+
DocumentStore,
|
|
67348
|
+
HoudiniClient,
|
|
64366
67349
|
HoudiniError,
|
|
64367
67350
|
LogLevel,
|
|
64368
67351
|
RefetchUpdateMode,
|
|
64369
67352
|
TypeWrapper,
|
|
64370
67353
|
cleanupFiles,
|
|
64371
67354
|
computeID,
|
|
67355
|
+
createPluginHooks,
|
|
64372
67356
|
deepMerge,
|
|
64373
67357
|
defaultConfigValues,
|
|
64374
67358
|
definitionFromAncestors,
|
|
64375
67359
|
ensureArtifactImport,
|
|
64376
67360
|
ensureImports,
|
|
67361
|
+
fetch,
|
|
64377
67362
|
find_graphql,
|
|
64378
67363
|
formatErrors,
|
|
64379
67364
|
fs,
|
|
@@ -64384,6 +67369,7 @@ async function find_graphql(config, parsedScript, walker) {
|
|
|
64384
67369
|
hashDocument,
|
|
64385
67370
|
houdini_mode,
|
|
64386
67371
|
keyFieldsForType,
|
|
67372
|
+
mutation,
|
|
64387
67373
|
operation_requires_variables,
|
|
64388
67374
|
orderedPlugins,
|
|
64389
67375
|
parentTypeFromAncestors,
|
|
@@ -64392,10 +67378,12 @@ async function find_graphql(config, parsedScript, walker) {
|
|
|
64392
67378
|
path,
|
|
64393
67379
|
plugin,
|
|
64394
67380
|
pullSchema,
|
|
67381
|
+
query,
|
|
64395
67382
|
readConfigFile,
|
|
64396
67383
|
runPipeline,
|
|
64397
67384
|
setMockConfig,
|
|
64398
67385
|
siteURL,
|
|
67386
|
+
subscription,
|
|
64399
67387
|
unwrapType,
|
|
64400
67388
|
wrapType
|
|
64401
67389
|
});
|