houdini 1.0.0-next.9 → 1.0.0
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 +2281 -105
- package/build/cmd-esm/index.js +2281 -105
- package/build/codegen/generators/runtime/runtimeConfig.d.ts +7 -0
- package/build/codegen/utils/flattenSelections.d.ts +1 -1
- package/build/codegen-cjs/index.js +2876 -674
- package/build/codegen-esm/index.js +2876 -674
- 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 +2258 -82
- package/build/test-esm/index.js +2258 -82
- package/build/vite/houdini.d.ts +2 -0
- package/build/vite-cjs/index.js +2284 -106
- package/build/vite-esm/index.js +2284 -106
- package/package.json +2 -2
package/build/cmd-esm/index.js
CHANGED
|
@@ -22424,42 +22424,42 @@ var require_node = __commonJS({
|
|
|
22424
22424
|
return Link2;
|
|
22425
22425
|
}(events_1.EventEmitter);
|
|
22426
22426
|
exports.Link = Link;
|
|
22427
|
-
var
|
|
22428
|
-
function
|
|
22427
|
+
var File4 = function() {
|
|
22428
|
+
function File5(link, node, flags, fd) {
|
|
22429
22429
|
this.position = 0;
|
|
22430
22430
|
this.link = link;
|
|
22431
22431
|
this.node = node;
|
|
22432
22432
|
this.flags = flags;
|
|
22433
22433
|
this.fd = fd;
|
|
22434
22434
|
}
|
|
22435
|
-
|
|
22435
|
+
File5.prototype.getString = function(encoding) {
|
|
22436
22436
|
if (encoding === void 0) {
|
|
22437
22437
|
encoding = "utf8";
|
|
22438
22438
|
}
|
|
22439
22439
|
return this.node.getString();
|
|
22440
22440
|
};
|
|
22441
|
-
|
|
22441
|
+
File5.prototype.setString = function(str) {
|
|
22442
22442
|
this.node.setString(str);
|
|
22443
22443
|
};
|
|
22444
|
-
|
|
22444
|
+
File5.prototype.getBuffer = function() {
|
|
22445
22445
|
return this.node.getBuffer();
|
|
22446
22446
|
};
|
|
22447
|
-
|
|
22447
|
+
File5.prototype.setBuffer = function(buf) {
|
|
22448
22448
|
this.node.setBuffer(buf);
|
|
22449
22449
|
};
|
|
22450
|
-
|
|
22450
|
+
File5.prototype.getSize = function() {
|
|
22451
22451
|
return this.node.getSize();
|
|
22452
22452
|
};
|
|
22453
|
-
|
|
22453
|
+
File5.prototype.truncate = function(len) {
|
|
22454
22454
|
this.node.truncate(len);
|
|
22455
22455
|
};
|
|
22456
|
-
|
|
22456
|
+
File5.prototype.seekTo = function(position) {
|
|
22457
22457
|
this.position = position;
|
|
22458
22458
|
};
|
|
22459
|
-
|
|
22459
|
+
File5.prototype.stats = function() {
|
|
22460
22460
|
return Stats_1.default.build(this.node);
|
|
22461
22461
|
};
|
|
22462
|
-
|
|
22462
|
+
File5.prototype.write = function(buf, offset, length, position) {
|
|
22463
22463
|
if (offset === void 0) {
|
|
22464
22464
|
offset = 0;
|
|
22465
22465
|
}
|
|
@@ -22474,7 +22474,7 @@ var require_node = __commonJS({
|
|
|
22474
22474
|
this.position = position + bytes;
|
|
22475
22475
|
return bytes;
|
|
22476
22476
|
};
|
|
22477
|
-
|
|
22477
|
+
File5.prototype.read = function(buf, offset, length, position) {
|
|
22478
22478
|
if (offset === void 0) {
|
|
22479
22479
|
offset = 0;
|
|
22480
22480
|
}
|
|
@@ -22487,15 +22487,15 @@ var require_node = __commonJS({
|
|
|
22487
22487
|
this.position = position + bytes;
|
|
22488
22488
|
return bytes;
|
|
22489
22489
|
};
|
|
22490
|
-
|
|
22490
|
+
File5.prototype.chmod = function(perm) {
|
|
22491
22491
|
this.node.chmod(perm);
|
|
22492
22492
|
};
|
|
22493
|
-
|
|
22493
|
+
File5.prototype.chown = function(uid, gid) {
|
|
22494
22494
|
this.node.chown(uid, gid);
|
|
22495
22495
|
};
|
|
22496
|
-
return
|
|
22496
|
+
return File5;
|
|
22497
22497
|
}();
|
|
22498
|
-
exports.File =
|
|
22498
|
+
exports.File = File4;
|
|
22499
22499
|
}
|
|
22500
22500
|
});
|
|
22501
22501
|
|
|
@@ -23181,20 +23181,20 @@ var require_volume = __commonJS({
|
|
|
23181
23181
|
}
|
|
23182
23182
|
function flattenJSON(nestedJSON) {
|
|
23183
23183
|
var flatJSON = {};
|
|
23184
|
-
function
|
|
23184
|
+
function flatten2(pathPrefix, node) {
|
|
23185
23185
|
for (var path2 in node) {
|
|
23186
23186
|
var contentOrNode = node[path2];
|
|
23187
23187
|
var joinedPath = join3(pathPrefix, path2);
|
|
23188
23188
|
if (typeof contentOrNode === "string") {
|
|
23189
23189
|
flatJSON[joinedPath] = contentOrNode;
|
|
23190
23190
|
} else if (typeof contentOrNode === "object" && contentOrNode !== null && Object.keys(contentOrNode).length > 0) {
|
|
23191
|
-
|
|
23191
|
+
flatten2(joinedPath, contentOrNode);
|
|
23192
23192
|
} else {
|
|
23193
23193
|
flatJSON[joinedPath] = null;
|
|
23194
23194
|
}
|
|
23195
23195
|
}
|
|
23196
23196
|
}
|
|
23197
|
-
|
|
23197
|
+
flatten2("", nestedJSON);
|
|
23198
23198
|
return flatJSON;
|
|
23199
23199
|
}
|
|
23200
23200
|
var Volume = function() {
|
|
@@ -28604,9 +28604,9 @@ var require_streams = __commonJS({
|
|
|
28604
28604
|
}
|
|
28605
28605
|
}
|
|
28606
28606
|
try {
|
|
28607
|
-
const { Blob:
|
|
28608
|
-
if (
|
|
28609
|
-
|
|
28607
|
+
const { Blob: Blob4 } = __require("buffer");
|
|
28608
|
+
if (Blob4 && !Blob4.prototype.stream) {
|
|
28609
|
+
Blob4.prototype.stream = function name(params) {
|
|
28610
28610
|
let position = 0;
|
|
28611
28611
|
const blob = this;
|
|
28612
28612
|
return new ReadableStream({
|
|
@@ -28657,12 +28657,12 @@ async function* toIterator(parts, clone2 = true) {
|
|
|
28657
28657
|
}
|
|
28658
28658
|
}
|
|
28659
28659
|
}
|
|
28660
|
-
var import_streams, POOL_SIZE, _Blob,
|
|
28660
|
+
var import_streams, POOL_SIZE, _Blob, Blob3, fetch_blob_default;
|
|
28661
28661
|
var init_fetch_blob = __esm({
|
|
28662
28662
|
"../../node_modules/.pnpm/fetch-blob@3.2.0/node_modules/fetch-blob/index.js"() {
|
|
28663
28663
|
import_streams = __toESM(require_streams(), 1);
|
|
28664
28664
|
POOL_SIZE = 65536;
|
|
28665
|
-
_Blob = class
|
|
28665
|
+
_Blob = class Blob2 {
|
|
28666
28666
|
#parts = [];
|
|
28667
28667
|
#type = "";
|
|
28668
28668
|
#size = 0;
|
|
@@ -28686,7 +28686,7 @@ var init_fetch_blob = __esm({
|
|
|
28686
28686
|
part = new Uint8Array(element.buffer.slice(element.byteOffset, element.byteOffset + element.byteLength));
|
|
28687
28687
|
} else if (element instanceof ArrayBuffer) {
|
|
28688
28688
|
part = new Uint8Array(element.slice(0));
|
|
28689
|
-
} else if (element instanceof
|
|
28689
|
+
} else if (element instanceof Blob2) {
|
|
28690
28690
|
part = element;
|
|
28691
28691
|
} else {
|
|
28692
28692
|
part = encoder.encode(`${element}`);
|
|
@@ -28765,7 +28765,7 @@ var init_fetch_blob = __esm({
|
|
|
28765
28765
|
relativeStart = 0;
|
|
28766
28766
|
}
|
|
28767
28767
|
}
|
|
28768
|
-
const blob = new
|
|
28768
|
+
const blob = new Blob2([], { type: String(type).toLowerCase() });
|
|
28769
28769
|
blob.#size = span;
|
|
28770
28770
|
blob.#parts = blobParts;
|
|
28771
28771
|
return blob;
|
|
@@ -28782,17 +28782,17 @@ var init_fetch_blob = __esm({
|
|
|
28782
28782
|
type: { enumerable: true },
|
|
28783
28783
|
slice: { enumerable: true }
|
|
28784
28784
|
});
|
|
28785
|
-
|
|
28786
|
-
fetch_blob_default =
|
|
28785
|
+
Blob3 = _Blob;
|
|
28786
|
+
fetch_blob_default = Blob3;
|
|
28787
28787
|
}
|
|
28788
28788
|
});
|
|
28789
28789
|
|
|
28790
28790
|
// ../../node_modules/.pnpm/fetch-blob@3.2.0/node_modules/fetch-blob/file.js
|
|
28791
|
-
var _File,
|
|
28791
|
+
var _File, File3, file_default;
|
|
28792
28792
|
var init_file = __esm({
|
|
28793
28793
|
"../../node_modules/.pnpm/fetch-blob@3.2.0/node_modules/fetch-blob/file.js"() {
|
|
28794
28794
|
init_fetch_blob();
|
|
28795
|
-
_File = class
|
|
28795
|
+
_File = class File2 extends fetch_blob_default {
|
|
28796
28796
|
#lastModified = 0;
|
|
28797
28797
|
#name = "";
|
|
28798
28798
|
constructor(fileBits, fileName, options = {}) {
|
|
@@ -28821,8 +28821,8 @@ var init_file = __esm({
|
|
|
28821
28821
|
return !!object && object instanceof fetch_blob_default && /^(File)$/.test(object[Symbol.toStringTag]);
|
|
28822
28822
|
}
|
|
28823
28823
|
};
|
|
28824
|
-
|
|
28825
|
-
file_default =
|
|
28824
|
+
File3 = _File;
|
|
28825
|
+
file_default = File3;
|
|
28826
28826
|
}
|
|
28827
28827
|
});
|
|
28828
28828
|
|
|
@@ -28840,7 +28840,7 @@ Content-Type: ${v.type || "application/octet-stream"}\r
|
|
|
28840
28840
|
c.push(`--${b}--`);
|
|
28841
28841
|
return new B(c, { type: "multipart/form-data; boundary=" + b });
|
|
28842
28842
|
}
|
|
28843
|
-
var t, i, h, r, m, f, e, x,
|
|
28843
|
+
var t, i, h, r, m, f, e, x, FormData2;
|
|
28844
28844
|
var init_esm_min = __esm({
|
|
28845
28845
|
"../../node_modules/.pnpm/formdata-polyfill@4.0.10/node_modules/formdata-polyfill/esm.min.js"() {
|
|
28846
28846
|
init_fetch_blob();
|
|
@@ -28855,7 +28855,7 @@ var init_esm_min = __esm({
|
|
|
28855
28855
|
throw new TypeError(`Failed to execute '${n}' on 'FormData': ${e2} arguments required, but only ${a.length} present.`);
|
|
28856
28856
|
}
|
|
28857
28857
|
};
|
|
28858
|
-
|
|
28858
|
+
FormData2 = class FormData3 {
|
|
28859
28859
|
#d = [];
|
|
28860
28860
|
constructor(...a) {
|
|
28861
28861
|
if (a.length)
|
|
@@ -29021,7 +29021,7 @@ async function toFormData(Body2, ct) {
|
|
|
29021
29021
|
let contentType;
|
|
29022
29022
|
let filename;
|
|
29023
29023
|
const entryChunks = [];
|
|
29024
|
-
const formData = new
|
|
29024
|
+
const formData = new FormData2();
|
|
29025
29025
|
const onPartData = (ui8a) => {
|
|
29026
29026
|
entryValue += decoder.decode(ui8a, { stream: true });
|
|
29027
29027
|
};
|
|
@@ -68328,7 +68328,18 @@ var graphql2 = __toESM(require_graphql2(), 1);
|
|
|
68328
68328
|
var import_minimatch = __toESM(require_minimatch(), 1);
|
|
68329
68329
|
import { fileURLToPath, pathToFileURL } from "node:url";
|
|
68330
68330
|
|
|
68331
|
+
// src/runtime/imports/config.ts
|
|
68332
|
+
var config_default = {};
|
|
68333
|
+
|
|
68334
|
+
// src/runtime/imports/pluginConfig.ts
|
|
68335
|
+
var configs = [];
|
|
68336
|
+
var pluginConfig_default = configs;
|
|
68337
|
+
|
|
68331
68338
|
// src/runtime/lib/config.ts
|
|
68339
|
+
var mockConfig = null;
|
|
68340
|
+
function getMockConfig() {
|
|
68341
|
+
return mockConfig;
|
|
68342
|
+
}
|
|
68332
68343
|
function defaultConfigValues(file) {
|
|
68333
68344
|
return {
|
|
68334
68345
|
defaultKeys: ["id"],
|
|
@@ -68356,12 +68367,150 @@ function computeID(configFile, type, data) {
|
|
|
68356
68367
|
}
|
|
68357
68368
|
return id.slice(0, -2);
|
|
68358
68369
|
}
|
|
68370
|
+
var _configFile = null;
|
|
68371
|
+
function getCurrentConfig() {
|
|
68372
|
+
const mockConfig2 = getMockConfig();
|
|
68373
|
+
if (mockConfig2) {
|
|
68374
|
+
return mockConfig2;
|
|
68375
|
+
}
|
|
68376
|
+
if (_configFile) {
|
|
68377
|
+
return _configFile;
|
|
68378
|
+
}
|
|
68379
|
+
let configFile = defaultConfigValues(config_default);
|
|
68380
|
+
for (const pluginConfig of pluginConfig_default) {
|
|
68381
|
+
configFile = pluginConfig(configFile);
|
|
68382
|
+
}
|
|
68383
|
+
_configFile = configFile;
|
|
68384
|
+
return configFile;
|
|
68385
|
+
}
|
|
68386
|
+
|
|
68387
|
+
// src/runtime/lib/deepEquals.ts
|
|
68388
|
+
function deepEquals(objA, objB, map = /* @__PURE__ */ new WeakMap()) {
|
|
68389
|
+
if (Object.is(objA, objB))
|
|
68390
|
+
return true;
|
|
68391
|
+
if (objA instanceof Date && objB instanceof Date) {
|
|
68392
|
+
return objA.getTime() === objB.getTime();
|
|
68393
|
+
}
|
|
68394
|
+
if (objA instanceof RegExp && objB instanceof RegExp) {
|
|
68395
|
+
return objA.toString() === objB.toString();
|
|
68396
|
+
}
|
|
68397
|
+
if (typeof objA !== "object" || objA === null || typeof objB !== "object" || objB === null) {
|
|
68398
|
+
return false;
|
|
68399
|
+
}
|
|
68400
|
+
if (map.get(objA) === objB)
|
|
68401
|
+
return true;
|
|
68402
|
+
map.set(objA, objB);
|
|
68403
|
+
const keysA = Reflect.ownKeys(objA);
|
|
68404
|
+
const keysB = Reflect.ownKeys(objB);
|
|
68405
|
+
if (keysA.length !== keysB.length) {
|
|
68406
|
+
return false;
|
|
68407
|
+
}
|
|
68408
|
+
for (let i2 = 0; i2 < keysA.length; i2++) {
|
|
68409
|
+
if (!Reflect.has(objB, keysA[i2]) || !deepEquals(objA[keysA[i2]], objB[keysA[i2]], map)) {
|
|
68410
|
+
return false;
|
|
68411
|
+
}
|
|
68412
|
+
}
|
|
68413
|
+
return true;
|
|
68414
|
+
}
|
|
68415
|
+
|
|
68416
|
+
// src/runtime/lib/selection.ts
|
|
68417
|
+
function getFieldsForType(selection2, __typename) {
|
|
68418
|
+
let targetSelection = selection2.fields || {};
|
|
68419
|
+
if (selection2.abstractFields && __typename) {
|
|
68420
|
+
const mappedType = selection2.abstractFields.typeMap[__typename];
|
|
68421
|
+
if (mappedType) {
|
|
68422
|
+
targetSelection = selection2.abstractFields.fields[mappedType];
|
|
68423
|
+
} else if (selection2.abstractFields.fields[__typename]) {
|
|
68424
|
+
targetSelection = selection2.abstractFields.fields[__typename];
|
|
68425
|
+
}
|
|
68426
|
+
}
|
|
68427
|
+
return targetSelection;
|
|
68428
|
+
}
|
|
68429
|
+
|
|
68430
|
+
// src/runtime/lib/scalars.ts
|
|
68431
|
+
async function marshalSelection({
|
|
68432
|
+
selection: selection2,
|
|
68433
|
+
data
|
|
68434
|
+
}) {
|
|
68435
|
+
const config2 = getCurrentConfig();
|
|
68436
|
+
if (data === null || typeof data === "undefined") {
|
|
68437
|
+
return data;
|
|
68438
|
+
}
|
|
68439
|
+
if (Array.isArray(data)) {
|
|
68440
|
+
return await Promise.all(data.map((val) => marshalSelection({ selection: selection2, data: val })));
|
|
68441
|
+
}
|
|
68442
|
+
const targetSelection = getFieldsForType(selection2, data["__typename"]);
|
|
68443
|
+
return Object.fromEntries(
|
|
68444
|
+
await Promise.all(
|
|
68445
|
+
Object.entries(data).map(async ([fieldName, value]) => {
|
|
68446
|
+
const { type, selection: selection3 } = targetSelection[fieldName];
|
|
68447
|
+
if (!type) {
|
|
68448
|
+
return [fieldName, value];
|
|
68449
|
+
}
|
|
68450
|
+
if (selection3) {
|
|
68451
|
+
return [fieldName, await marshalSelection({ selection: selection3, data: value })];
|
|
68452
|
+
}
|
|
68453
|
+
if (config2.scalars?.[type]) {
|
|
68454
|
+
const marshalFn = config2.scalars[type].marshal;
|
|
68455
|
+
if (!marshalFn) {
|
|
68456
|
+
throw new Error(
|
|
68457
|
+
`scalar type ${type} is missing a \`marshal\` function. see https://github.com/AlecAivazis/houdini#%EF%B8%8Fcustom-scalars`
|
|
68458
|
+
);
|
|
68459
|
+
}
|
|
68460
|
+
if (Array.isArray(value)) {
|
|
68461
|
+
return [fieldName, value.map(marshalFn)];
|
|
68462
|
+
}
|
|
68463
|
+
return [fieldName, marshalFn(value)];
|
|
68464
|
+
}
|
|
68465
|
+
return [fieldName, value];
|
|
68466
|
+
})
|
|
68467
|
+
)
|
|
68468
|
+
);
|
|
68469
|
+
}
|
|
68359
68470
|
|
|
68360
68471
|
// src/runtime/lib/types.ts
|
|
68361
|
-
var
|
|
68362
|
-
|
|
68363
|
-
|
|
68364
|
-
|
|
68472
|
+
var CachePolicy = {
|
|
68473
|
+
CacheOrNetwork: "CacheOrNetwork",
|
|
68474
|
+
CacheOnly: "CacheOnly",
|
|
68475
|
+
NetworkOnly: "NetworkOnly",
|
|
68476
|
+
CacheAndNetwork: "CacheAndNetwork"
|
|
68477
|
+
};
|
|
68478
|
+
var ArtifactKind = {
|
|
68479
|
+
Query: "HoudiniQuery",
|
|
68480
|
+
Subscription: "HoudiniSubscription",
|
|
68481
|
+
Mutation: "HoudiniMutation",
|
|
68482
|
+
Fragment: "HoudiniFragment"
|
|
68483
|
+
};
|
|
68484
|
+
var CompiledFragmentKind = ArtifactKind.Fragment;
|
|
68485
|
+
var CompiledMutationKind = ArtifactKind.Mutation;
|
|
68486
|
+
var CompiledQueryKind = ArtifactKind.Query;
|
|
68487
|
+
var CompiledSubscriptionKind = ArtifactKind.Subscription;
|
|
68488
|
+
var RefetchUpdateMode = {
|
|
68489
|
+
append: "append",
|
|
68490
|
+
prepend: "prepend",
|
|
68491
|
+
replace: "replace"
|
|
68492
|
+
};
|
|
68493
|
+
var DataSource = {
|
|
68494
|
+
Cache: "cache",
|
|
68495
|
+
Network: "network",
|
|
68496
|
+
Ssr: "ssr"
|
|
68497
|
+
};
|
|
68498
|
+
|
|
68499
|
+
// src/runtime/lib/key.ts
|
|
68500
|
+
var computeKey = ({ field, args }) => {
|
|
68501
|
+
const keys = Object.keys(args ?? {});
|
|
68502
|
+
keys.sort();
|
|
68503
|
+
return args && keys.length > 0 ? `${field}(${keys.map((key) => `${key}: ${stringifyObjectWithNoQuotesOnKeys(args[key])}`).join(", ")})` : field;
|
|
68504
|
+
};
|
|
68505
|
+
var stringifyObjectWithNoQuotesOnKeys = (obj_from_json) => {
|
|
68506
|
+
if (Array.isArray(obj_from_json)) {
|
|
68507
|
+
return `[${obj_from_json.map((obj) => `${stringifyObjectWithNoQuotesOnKeys(obj)}`).join(", ")}]`;
|
|
68508
|
+
}
|
|
68509
|
+
if (typeof obj_from_json !== "object" || obj_from_json instanceof Date || obj_from_json === null) {
|
|
68510
|
+
return JSON.stringify(obj_from_json).replace(/"([^"]+)":/g, "$1: ");
|
|
68511
|
+
}
|
|
68512
|
+
return `{${Object.keys(obj_from_json).map((key) => `${key}: ${stringifyObjectWithNoQuotesOnKeys(obj_from_json[key])}`).join(", ")}}`;
|
|
68513
|
+
};
|
|
68365
68514
|
|
|
68366
68515
|
// src/lib/constants.ts
|
|
68367
68516
|
var siteURL = "https://houdinigraphql.com";
|
|
@@ -68807,7 +68956,7 @@ var Body = class {
|
|
|
68807
68956
|
} else if (ArrayBuffer.isView(body)) {
|
|
68808
68957
|
body = Buffer2.from(body.buffer, body.byteOffset, body.byteLength);
|
|
68809
68958
|
} else if (body instanceof Stream) {
|
|
68810
|
-
} else if (body instanceof
|
|
68959
|
+
} else if (body instanceof FormData2) {
|
|
68811
68960
|
body = formDataToBlob(body);
|
|
68812
68961
|
boundary = body.type.split("=")[1];
|
|
68813
68962
|
} else {
|
|
@@ -68847,7 +68996,7 @@ var Body = class {
|
|
|
68847
68996
|
async formData() {
|
|
68848
68997
|
const ct = this.headers.get("content-type");
|
|
68849
68998
|
if (ct.startsWith("application/x-www-form-urlencoded")) {
|
|
68850
|
-
const formData = new
|
|
68999
|
+
const formData = new FormData2();
|
|
68851
69000
|
const parameters = new URLSearchParams(await this.text());
|
|
68852
69001
|
for (const [name, value] of parameters) {
|
|
68853
69002
|
formData.append(name, value);
|
|
@@ -68973,7 +69122,7 @@ var extractContentType = (body, request) => {
|
|
|
68973
69122
|
if (Buffer2.isBuffer(body) || types.isAnyArrayBuffer(body) || ArrayBuffer.isView(body)) {
|
|
68974
69123
|
return null;
|
|
68975
69124
|
}
|
|
68976
|
-
if (body instanceof
|
|
69125
|
+
if (body instanceof FormData2) {
|
|
68977
69126
|
return `multipart/form-data; boundary=${request[INTERNALS].boundary}`;
|
|
68978
69127
|
}
|
|
68979
69128
|
if (body && typeof body.getBoundary === "function") {
|
|
@@ -69940,14 +70089,2002 @@ function plugin(name, hooks) {
|
|
|
69940
70089
|
return data;
|
|
69941
70090
|
}
|
|
69942
70091
|
|
|
70092
|
+
// src/runtime/lib/flatten.ts
|
|
70093
|
+
function flatten(source) {
|
|
70094
|
+
if (!source) {
|
|
70095
|
+
return [];
|
|
70096
|
+
}
|
|
70097
|
+
return source.reduce((acc, element) => {
|
|
70098
|
+
if (!element) {
|
|
70099
|
+
return acc;
|
|
70100
|
+
}
|
|
70101
|
+
if (Array.isArray(element)) {
|
|
70102
|
+
return acc.concat(flatten(element));
|
|
70103
|
+
}
|
|
70104
|
+
return acc.concat(element);
|
|
70105
|
+
}, []);
|
|
70106
|
+
}
|
|
70107
|
+
|
|
70108
|
+
// src/runtime/cache/gc.ts
|
|
70109
|
+
var GarbageCollector = class {
|
|
70110
|
+
cache;
|
|
70111
|
+
lifetimes = /* @__PURE__ */ new Map();
|
|
70112
|
+
get cacheBufferSize() {
|
|
70113
|
+
return this.cache._internal_unstable.config.cacheBufferSize ?? 10;
|
|
70114
|
+
}
|
|
70115
|
+
constructor(cache) {
|
|
70116
|
+
this.cache = cache;
|
|
70117
|
+
}
|
|
70118
|
+
resetLifetime(id, field) {
|
|
70119
|
+
if (!this.lifetimes.get(id)) {
|
|
70120
|
+
this.lifetimes.set(id, /* @__PURE__ */ new Map());
|
|
70121
|
+
}
|
|
70122
|
+
this.lifetimes.get(id).set(field, 0);
|
|
70123
|
+
}
|
|
70124
|
+
tick() {
|
|
70125
|
+
const dt_tick = Date.now().valueOf();
|
|
70126
|
+
const config_max_time = this.cache._internal_unstable.config.defaultLifetime;
|
|
70127
|
+
for (const [id, fieldMap] of this.lifetimes.entries()) {
|
|
70128
|
+
for (const [field, lifetime] of fieldMap.entries()) {
|
|
70129
|
+
if (this.cache._internal_unstable.subscriptions.get(id, field).length > 0) {
|
|
70130
|
+
continue;
|
|
70131
|
+
}
|
|
70132
|
+
fieldMap.set(field, lifetime + 1);
|
|
70133
|
+
if (fieldMap.get(field) > this.cacheBufferSize) {
|
|
70134
|
+
this.cache._internal_unstable.storage.deleteField(id, field);
|
|
70135
|
+
this.cache._internal_unstable.lists.deleteField(id, field);
|
|
70136
|
+
fieldMap.delete(field);
|
|
70137
|
+
if ([...fieldMap.keys()].length === 0) {
|
|
70138
|
+
this.lifetimes.delete(id);
|
|
70139
|
+
}
|
|
70140
|
+
this.cache._internal_unstable.staleManager.delete(id, field);
|
|
70141
|
+
}
|
|
70142
|
+
if (config_max_time && config_max_time > 0) {
|
|
70143
|
+
const dt_valueOf = this.cache.getFieldTime(id, field);
|
|
70144
|
+
if (dt_valueOf && dt_tick - dt_valueOf > config_max_time) {
|
|
70145
|
+
this.cache._internal_unstable.staleManager.markFieldStale(id, field);
|
|
70146
|
+
}
|
|
70147
|
+
}
|
|
70148
|
+
}
|
|
70149
|
+
}
|
|
70150
|
+
}
|
|
70151
|
+
};
|
|
70152
|
+
|
|
70153
|
+
// src/runtime/cache/lists.ts
|
|
70154
|
+
var ListManager = class {
|
|
70155
|
+
rootID;
|
|
70156
|
+
cache;
|
|
70157
|
+
constructor(cache, rootID2) {
|
|
70158
|
+
this.rootID = rootID2;
|
|
70159
|
+
this.cache = cache;
|
|
70160
|
+
}
|
|
70161
|
+
lists = /* @__PURE__ */ new Map();
|
|
70162
|
+
listsByField = /* @__PURE__ */ new Map();
|
|
70163
|
+
get(listName, id, allLists) {
|
|
70164
|
+
const matches = this.lists.get(listName);
|
|
70165
|
+
if (!matches || matches.size === 0) {
|
|
70166
|
+
return null;
|
|
70167
|
+
}
|
|
70168
|
+
if (allLists) {
|
|
70169
|
+
return new ListCollection(
|
|
70170
|
+
Array.from(matches, ([key, value]) => [...value.lists]).flat()
|
|
70171
|
+
);
|
|
70172
|
+
}
|
|
70173
|
+
const head = [...matches.values()][0];
|
|
70174
|
+
const { recordType } = head.lists[0];
|
|
70175
|
+
const parentID = id ? this.cache._internal_unstable.id(recordType || "", id) : this.rootID;
|
|
70176
|
+
if (matches?.size === 1) {
|
|
70177
|
+
if (!id) {
|
|
70178
|
+
return head;
|
|
70179
|
+
}
|
|
70180
|
+
return parentID === Array.from(matches.keys())[0] ? head : null;
|
|
70181
|
+
}
|
|
70182
|
+
if (!id) {
|
|
70183
|
+
console.error(
|
|
70184
|
+
`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 `
|
|
70185
|
+
);
|
|
70186
|
+
return null;
|
|
70187
|
+
}
|
|
70188
|
+
return this.lists.get(listName)?.get(parentID);
|
|
70189
|
+
}
|
|
70190
|
+
remove(listName, id) {
|
|
70191
|
+
this.lists.get(listName)?.delete(id || this.rootID);
|
|
70192
|
+
}
|
|
70193
|
+
add(list) {
|
|
70194
|
+
if (!this.lists.has(list.name)) {
|
|
70195
|
+
this.lists.set(list.name, /* @__PURE__ */ new Map());
|
|
70196
|
+
}
|
|
70197
|
+
const name = list.name;
|
|
70198
|
+
const parentID = list.recordID || this.rootID;
|
|
70199
|
+
if (this.lists.get(name)?.get(parentID)?.includes(list.key)) {
|
|
70200
|
+
return;
|
|
70201
|
+
}
|
|
70202
|
+
if (!this.lists.has(name)) {
|
|
70203
|
+
this.lists.set(name, /* @__PURE__ */ new Map());
|
|
70204
|
+
}
|
|
70205
|
+
if (!this.lists.get(name).has(parentID)) {
|
|
70206
|
+
this.lists.get(name).set(parentID, new ListCollection([]));
|
|
70207
|
+
}
|
|
70208
|
+
if (!this.listsByField.has(parentID)) {
|
|
70209
|
+
this.listsByField.set(parentID, /* @__PURE__ */ new Map());
|
|
70210
|
+
}
|
|
70211
|
+
if (!this.listsByField.get(parentID).has(list.key)) {
|
|
70212
|
+
this.listsByField.get(parentID)?.set(list.key, []);
|
|
70213
|
+
}
|
|
70214
|
+
const handler = new List({ ...list, manager: this });
|
|
70215
|
+
this.lists.get(list.name).get(parentID).lists.push(handler);
|
|
70216
|
+
this.listsByField.get(parentID).get(list.key).push(handler);
|
|
70217
|
+
}
|
|
70218
|
+
removeIDFromAllLists(id) {
|
|
70219
|
+
for (const fieldMap of this.lists.values()) {
|
|
70220
|
+
for (const list of fieldMap.values()) {
|
|
70221
|
+
list.removeID(id);
|
|
70222
|
+
}
|
|
70223
|
+
}
|
|
70224
|
+
}
|
|
70225
|
+
deleteField(parentID, field) {
|
|
70226
|
+
if (!this.listsByField.get(parentID)?.has(field)) {
|
|
70227
|
+
return;
|
|
70228
|
+
}
|
|
70229
|
+
for (const list of this.listsByField.get(parentID).get(field)) {
|
|
70230
|
+
this.lists.get(list.name)?.get(list.recordID)?.deleteListWithKey(field);
|
|
70231
|
+
if (this.lists.get(list.name)?.get(list.recordID)?.lists.length === 0) {
|
|
70232
|
+
this.lists.get(list.name)?.delete(list.recordID);
|
|
70233
|
+
}
|
|
70234
|
+
}
|
|
70235
|
+
this.listsByField.get(parentID).delete(field);
|
|
70236
|
+
}
|
|
70237
|
+
};
|
|
70238
|
+
var List = class {
|
|
70239
|
+
recordID;
|
|
70240
|
+
recordType;
|
|
70241
|
+
key;
|
|
70242
|
+
type;
|
|
70243
|
+
cache;
|
|
70244
|
+
selection;
|
|
70245
|
+
_when;
|
|
70246
|
+
filters;
|
|
70247
|
+
name;
|
|
70248
|
+
connection;
|
|
70249
|
+
manager;
|
|
70250
|
+
abstract;
|
|
70251
|
+
constructor({
|
|
70252
|
+
name,
|
|
70253
|
+
recordID,
|
|
70254
|
+
recordType,
|
|
70255
|
+
key,
|
|
70256
|
+
listType,
|
|
70257
|
+
selection: selection2,
|
|
70258
|
+
when,
|
|
70259
|
+
filters,
|
|
70260
|
+
connection,
|
|
70261
|
+
manager,
|
|
70262
|
+
abstract
|
|
70263
|
+
}) {
|
|
70264
|
+
this.recordID = recordID || rootID;
|
|
70265
|
+
this.recordType = recordType;
|
|
70266
|
+
this.key = key;
|
|
70267
|
+
this.type = listType;
|
|
70268
|
+
this.cache = manager.cache;
|
|
70269
|
+
this.selection = selection2;
|
|
70270
|
+
this._when = when;
|
|
70271
|
+
this.filters = filters;
|
|
70272
|
+
this.name = name;
|
|
70273
|
+
this.connection = connection;
|
|
70274
|
+
this.manager = manager;
|
|
70275
|
+
this.abstract = abstract;
|
|
70276
|
+
}
|
|
70277
|
+
when(when) {
|
|
70278
|
+
return this.manager.lists.get(this.name).get(this.recordID).when(when);
|
|
70279
|
+
}
|
|
70280
|
+
append(selection2, data, variables = {}) {
|
|
70281
|
+
return this.addToList(selection2, data, variables, "last");
|
|
70282
|
+
}
|
|
70283
|
+
prepend(selection2, data, variables = {}) {
|
|
70284
|
+
return this.addToList(selection2, data, variables, "first");
|
|
70285
|
+
}
|
|
70286
|
+
addToList(selection2, data, variables = {}, where) {
|
|
70287
|
+
const listType = this.listType(data);
|
|
70288
|
+
const dataID = this.cache._internal_unstable.id(listType, data);
|
|
70289
|
+
if (!this.validateWhen() || !dataID) {
|
|
70290
|
+
return;
|
|
70291
|
+
}
|
|
70292
|
+
let insertSelection = selection2;
|
|
70293
|
+
let insertData = data;
|
|
70294
|
+
if (this.connection) {
|
|
70295
|
+
insertSelection = {
|
|
70296
|
+
fields: {
|
|
70297
|
+
newEntry: {
|
|
70298
|
+
keyRaw: this.key,
|
|
70299
|
+
type: "Connection",
|
|
70300
|
+
selection: {
|
|
70301
|
+
fields: {
|
|
70302
|
+
edges: {
|
|
70303
|
+
keyRaw: "edges",
|
|
70304
|
+
type: "ConnectionEdge",
|
|
70305
|
+
updates: ["append", "prepend"],
|
|
70306
|
+
selection: {
|
|
70307
|
+
fields: {
|
|
70308
|
+
node: {
|
|
70309
|
+
type: listType,
|
|
70310
|
+
keyRaw: "node",
|
|
70311
|
+
selection: {
|
|
70312
|
+
...selection2,
|
|
70313
|
+
fields: {
|
|
70314
|
+
...selection2.fields,
|
|
70315
|
+
__typename: {
|
|
70316
|
+
keyRaw: "__typename",
|
|
70317
|
+
type: "String"
|
|
70318
|
+
}
|
|
70319
|
+
}
|
|
70320
|
+
}
|
|
70321
|
+
}
|
|
70322
|
+
}
|
|
70323
|
+
}
|
|
70324
|
+
}
|
|
70325
|
+
}
|
|
70326
|
+
}
|
|
70327
|
+
}
|
|
70328
|
+
}
|
|
70329
|
+
};
|
|
70330
|
+
insertData = {
|
|
70331
|
+
newEntry: {
|
|
70332
|
+
edges: [{ node: { ...data, __typename: listType } }]
|
|
70333
|
+
}
|
|
70334
|
+
};
|
|
70335
|
+
} else {
|
|
70336
|
+
insertSelection = {
|
|
70337
|
+
fields: {
|
|
70338
|
+
newEntries: {
|
|
70339
|
+
keyRaw: this.key,
|
|
70340
|
+
type: listType,
|
|
70341
|
+
updates: ["append", "prepend"],
|
|
70342
|
+
selection: {
|
|
70343
|
+
...selection2,
|
|
70344
|
+
fields: {
|
|
70345
|
+
...selection2.fields,
|
|
70346
|
+
__typename: {
|
|
70347
|
+
keyRaw: "__typename",
|
|
70348
|
+
type: "String"
|
|
70349
|
+
}
|
|
70350
|
+
}
|
|
70351
|
+
}
|
|
70352
|
+
}
|
|
70353
|
+
}
|
|
70354
|
+
};
|
|
70355
|
+
insertData = {
|
|
70356
|
+
newEntries: [{ ...data, __typename: listType }]
|
|
70357
|
+
};
|
|
70358
|
+
}
|
|
70359
|
+
this.cache.write({
|
|
70360
|
+
selection: insertSelection,
|
|
70361
|
+
data: insertData,
|
|
70362
|
+
variables,
|
|
70363
|
+
parent: this.recordID,
|
|
70364
|
+
applyUpdates: [where === "first" ? "prepend" : "append"]
|
|
70365
|
+
});
|
|
70366
|
+
}
|
|
70367
|
+
removeID(id, variables = {}) {
|
|
70368
|
+
if (!this.validateWhen()) {
|
|
70369
|
+
return;
|
|
70370
|
+
}
|
|
70371
|
+
let parentID = this.recordID;
|
|
70372
|
+
let targetID = id;
|
|
70373
|
+
let targetKey = this.key;
|
|
70374
|
+
if (this.connection) {
|
|
70375
|
+
const { value: embeddedConnection } = this.cache._internal_unstable.storage.get(
|
|
70376
|
+
this.recordID,
|
|
70377
|
+
this.key
|
|
70378
|
+
);
|
|
70379
|
+
if (!embeddedConnection) {
|
|
70380
|
+
return;
|
|
70381
|
+
}
|
|
70382
|
+
const embeddedConnectionID = embeddedConnection;
|
|
70383
|
+
const { value: edges } = this.cache._internal_unstable.storage.get(
|
|
70384
|
+
embeddedConnectionID,
|
|
70385
|
+
"edges"
|
|
70386
|
+
);
|
|
70387
|
+
for (const edge of flatten(edges) || []) {
|
|
70388
|
+
if (!edge) {
|
|
70389
|
+
continue;
|
|
70390
|
+
}
|
|
70391
|
+
const edgeID = edge;
|
|
70392
|
+
const { value: nodeID } = this.cache._internal_unstable.storage.get(edgeID, "node");
|
|
70393
|
+
if (!nodeID) {
|
|
70394
|
+
continue;
|
|
70395
|
+
}
|
|
70396
|
+
if (nodeID === id) {
|
|
70397
|
+
targetID = edgeID;
|
|
70398
|
+
}
|
|
70399
|
+
}
|
|
70400
|
+
parentID = embeddedConnectionID;
|
|
70401
|
+
targetKey = "edges";
|
|
70402
|
+
}
|
|
70403
|
+
let value = this.cache._internal_unstable.storage.get(parentID, targetKey).value;
|
|
70404
|
+
if (!value || !value.includes(targetID)) {
|
|
70405
|
+
return;
|
|
70406
|
+
}
|
|
70407
|
+
const subscribers = this.cache._internal_unstable.subscriptions.get(this.recordID, this.key);
|
|
70408
|
+
this.cache._internal_unstable.subscriptions.remove(
|
|
70409
|
+
targetID,
|
|
70410
|
+
this.connection ? this.selection.fields.edges.selection : this.selection,
|
|
70411
|
+
subscribers.map((sub) => sub[0]),
|
|
70412
|
+
variables
|
|
70413
|
+
);
|
|
70414
|
+
this.cache._internal_unstable.storage.remove(parentID, targetKey, targetID);
|
|
70415
|
+
for (const [spec] of subscribers) {
|
|
70416
|
+
spec.set(
|
|
70417
|
+
this.cache._internal_unstable.getSelection({
|
|
70418
|
+
parent: spec.parentID || this.manager.rootID,
|
|
70419
|
+
selection: spec.selection,
|
|
70420
|
+
variables: spec.variables?.() || {}
|
|
70421
|
+
}).data
|
|
70422
|
+
);
|
|
70423
|
+
}
|
|
70424
|
+
return true;
|
|
70425
|
+
}
|
|
70426
|
+
remove(data, variables = {}) {
|
|
70427
|
+
const targetID = this.cache._internal_unstable.id(this.listType(data), data);
|
|
70428
|
+
if (!targetID) {
|
|
70429
|
+
return;
|
|
70430
|
+
}
|
|
70431
|
+
return this.removeID(targetID, variables);
|
|
70432
|
+
}
|
|
70433
|
+
listType(data) {
|
|
70434
|
+
return data.__typename || this.type;
|
|
70435
|
+
}
|
|
70436
|
+
validateWhen(when) {
|
|
70437
|
+
let filters = when || this._when;
|
|
70438
|
+
let ok = true;
|
|
70439
|
+
if (filters) {
|
|
70440
|
+
const targets = this.filters;
|
|
70441
|
+
if (filters.must && targets) {
|
|
70442
|
+
ok = Object.entries(filters.must).reduce(
|
|
70443
|
+
(prev, [key, value]) => Boolean(prev && targets[key] == value),
|
|
70444
|
+
ok
|
|
70445
|
+
);
|
|
70446
|
+
}
|
|
70447
|
+
if (filters.must_not) {
|
|
70448
|
+
ok = !targets || Object.entries(filters.must_not).reduce(
|
|
70449
|
+
(prev, [key, value]) => Boolean(prev && targets[key] != value),
|
|
70450
|
+
ok
|
|
70451
|
+
);
|
|
70452
|
+
}
|
|
70453
|
+
}
|
|
70454
|
+
return ok;
|
|
70455
|
+
}
|
|
70456
|
+
toggleElement(selection2, data, variables = {}, where) {
|
|
70457
|
+
if (!this.remove(data, variables)) {
|
|
70458
|
+
this.addToList(selection2, data, variables, where);
|
|
70459
|
+
}
|
|
70460
|
+
}
|
|
70461
|
+
*[Symbol.iterator]() {
|
|
70462
|
+
let entries = [];
|
|
70463
|
+
let value = this.cache._internal_unstable.storage.get(this.recordID, this.key).value;
|
|
70464
|
+
if (!this.connection) {
|
|
70465
|
+
entries = flatten(value);
|
|
70466
|
+
} else {
|
|
70467
|
+
entries = this.cache._internal_unstable.storage.get(value, "edges").value;
|
|
70468
|
+
}
|
|
70469
|
+
for (let record2 of entries) {
|
|
70470
|
+
yield record2;
|
|
70471
|
+
}
|
|
70472
|
+
}
|
|
70473
|
+
};
|
|
70474
|
+
var ListCollection = class {
|
|
70475
|
+
lists = [];
|
|
70476
|
+
constructor(lists) {
|
|
70477
|
+
this.lists = lists;
|
|
70478
|
+
}
|
|
70479
|
+
get selection() {
|
|
70480
|
+
return this.lists[0].selection;
|
|
70481
|
+
}
|
|
70482
|
+
append(...args) {
|
|
70483
|
+
this.lists.forEach((list) => list.append(...args));
|
|
70484
|
+
}
|
|
70485
|
+
prepend(...args) {
|
|
70486
|
+
this.lists.forEach((list) => list.prepend(...args));
|
|
70487
|
+
}
|
|
70488
|
+
addToList(...args) {
|
|
70489
|
+
this.lists.forEach((list) => list.addToList(...args));
|
|
70490
|
+
}
|
|
70491
|
+
removeID(...args) {
|
|
70492
|
+
this.lists.forEach((list) => list.removeID(...args));
|
|
70493
|
+
}
|
|
70494
|
+
remove(...args) {
|
|
70495
|
+
this.lists.forEach((list) => list.remove(...args));
|
|
70496
|
+
}
|
|
70497
|
+
toggleElement(...args) {
|
|
70498
|
+
this.lists.forEach((list) => list.toggleElement(...args));
|
|
70499
|
+
}
|
|
70500
|
+
when(when) {
|
|
70501
|
+
return new ListCollection(
|
|
70502
|
+
this.lists.filter((list) => {
|
|
70503
|
+
return list.validateWhen(when);
|
|
70504
|
+
})
|
|
70505
|
+
);
|
|
70506
|
+
}
|
|
70507
|
+
includes(key) {
|
|
70508
|
+
return !!this.lists.find((list) => list.key === key);
|
|
70509
|
+
}
|
|
70510
|
+
deleteListWithKey(key) {
|
|
70511
|
+
return this.lists = this.lists.filter((list) => list.key !== key);
|
|
70512
|
+
}
|
|
70513
|
+
*[Symbol.iterator]() {
|
|
70514
|
+
for (let list of this.lists) {
|
|
70515
|
+
for (const entry of list) {
|
|
70516
|
+
yield entry;
|
|
70517
|
+
}
|
|
70518
|
+
}
|
|
70519
|
+
}
|
|
70520
|
+
};
|
|
70521
|
+
|
|
70522
|
+
// src/runtime/cache/schema.ts
|
|
70523
|
+
var SchemaManager = class {
|
|
70524
|
+
cache;
|
|
70525
|
+
fieldTypes = {};
|
|
70526
|
+
constructor(cache) {
|
|
70527
|
+
this.cache = cache;
|
|
70528
|
+
}
|
|
70529
|
+
setFieldType({
|
|
70530
|
+
parent,
|
|
70531
|
+
key,
|
|
70532
|
+
type,
|
|
70533
|
+
nullable = false,
|
|
70534
|
+
link
|
|
70535
|
+
}) {
|
|
70536
|
+
let parensIndex = key.indexOf("(");
|
|
70537
|
+
if (parensIndex !== -1) {
|
|
70538
|
+
key = key.substring(0, parensIndex);
|
|
70539
|
+
}
|
|
70540
|
+
if (parent === rootID) {
|
|
70541
|
+
parent = "Query";
|
|
70542
|
+
} else if (parent.includes(":")) {
|
|
70543
|
+
parent = parent.substring(0, parent.indexOf(":"));
|
|
70544
|
+
}
|
|
70545
|
+
if (!this.fieldTypes[parent]) {
|
|
70546
|
+
this.fieldTypes[parent] = {};
|
|
70547
|
+
}
|
|
70548
|
+
this.fieldTypes[parent][key] = {
|
|
70549
|
+
type,
|
|
70550
|
+
nullable,
|
|
70551
|
+
link: !!link
|
|
70552
|
+
};
|
|
70553
|
+
}
|
|
70554
|
+
fieldType(type, field) {
|
|
70555
|
+
return this.fieldTypes[type]?.[field] || null;
|
|
70556
|
+
}
|
|
70557
|
+
get config() {
|
|
70558
|
+
return this.cache._internal_unstable.config;
|
|
70559
|
+
}
|
|
70560
|
+
};
|
|
70561
|
+
|
|
70562
|
+
// src/runtime/cache/staleManager.ts
|
|
70563
|
+
var StaleManager = class {
|
|
70564
|
+
cache;
|
|
70565
|
+
fieldsTime = /* @__PURE__ */ new Map();
|
|
70566
|
+
constructor(cache) {
|
|
70567
|
+
this.cache = cache;
|
|
70568
|
+
}
|
|
70569
|
+
#initMapId = (id) => {
|
|
70570
|
+
if (!this.fieldsTime.get(id)) {
|
|
70571
|
+
this.fieldsTime.set(id, /* @__PURE__ */ new Map());
|
|
70572
|
+
}
|
|
70573
|
+
};
|
|
70574
|
+
getFieldTime(id, field) {
|
|
70575
|
+
return this.fieldsTime.get(id)?.get(field);
|
|
70576
|
+
}
|
|
70577
|
+
setFieldTimeToNow(id, field) {
|
|
70578
|
+
this.#initMapId(id);
|
|
70579
|
+
this.fieldsTime.get(id)?.set(field, new Date().valueOf());
|
|
70580
|
+
}
|
|
70581
|
+
markFieldStale(id, field) {
|
|
70582
|
+
this.#initMapId(id);
|
|
70583
|
+
this.fieldsTime.get(id)?.set(field, null);
|
|
70584
|
+
}
|
|
70585
|
+
markAllStale() {
|
|
70586
|
+
for (const [id, fieldMap] of this.fieldsTime.entries()) {
|
|
70587
|
+
for (const [field] of fieldMap.entries()) {
|
|
70588
|
+
this.markFieldStale(id, field);
|
|
70589
|
+
}
|
|
70590
|
+
}
|
|
70591
|
+
}
|
|
70592
|
+
markRecordStale(id) {
|
|
70593
|
+
const fieldsTimeOfType = this.fieldsTime.get(id);
|
|
70594
|
+
if (fieldsTimeOfType) {
|
|
70595
|
+
for (const [field] of fieldsTimeOfType.entries()) {
|
|
70596
|
+
this.markFieldStale(id, field);
|
|
70597
|
+
}
|
|
70598
|
+
}
|
|
70599
|
+
}
|
|
70600
|
+
markTypeStale(type) {
|
|
70601
|
+
for (const [id, fieldMap] of this.fieldsTime.entries()) {
|
|
70602
|
+
if (id.startsWith(`${type}:`)) {
|
|
70603
|
+
for (const [field] of fieldMap.entries()) {
|
|
70604
|
+
this.markFieldStale(id, field);
|
|
70605
|
+
}
|
|
70606
|
+
}
|
|
70607
|
+
}
|
|
70608
|
+
}
|
|
70609
|
+
markTypeFieldStale(type, field, when) {
|
|
70610
|
+
const key = computeKey({ field, args: when });
|
|
70611
|
+
for (const [id, fieldMap] of this.fieldsTime.entries()) {
|
|
70612
|
+
if (id.startsWith(`${type}:`)) {
|
|
70613
|
+
for (const local_field of fieldMap.keys()) {
|
|
70614
|
+
if (local_field === key) {
|
|
70615
|
+
this.markFieldStale(id, field);
|
|
70616
|
+
}
|
|
70617
|
+
}
|
|
70618
|
+
}
|
|
70619
|
+
}
|
|
70620
|
+
}
|
|
70621
|
+
delete(id, field) {
|
|
70622
|
+
if (this.fieldsTime.has(id)) {
|
|
70623
|
+
this.fieldsTime.get(id)?.delete(field);
|
|
70624
|
+
if (this.fieldsTime.get(id)?.size === 0) {
|
|
70625
|
+
this.fieldsTime.delete(id);
|
|
70626
|
+
}
|
|
70627
|
+
}
|
|
70628
|
+
}
|
|
70629
|
+
};
|
|
70630
|
+
|
|
70631
|
+
// src/runtime/cache/storage.ts
|
|
70632
|
+
var InMemoryStorage = class {
|
|
70633
|
+
data;
|
|
70634
|
+
idCount = 0;
|
|
70635
|
+
rank = 0;
|
|
70636
|
+
constructor() {
|
|
70637
|
+
this.data = [];
|
|
70638
|
+
}
|
|
70639
|
+
get layerCount() {
|
|
70640
|
+
return this.data.length;
|
|
70641
|
+
}
|
|
70642
|
+
get nextRank() {
|
|
70643
|
+
return this.rank++;
|
|
70644
|
+
}
|
|
70645
|
+
createLayer(optimistic = false) {
|
|
70646
|
+
const layer = new Layer(this.idCount++);
|
|
70647
|
+
layer.optimistic = optimistic;
|
|
70648
|
+
this.data.push(layer);
|
|
70649
|
+
return layer;
|
|
70650
|
+
}
|
|
70651
|
+
insert(id, field, location, target) {
|
|
70652
|
+
return this.topLayer.insert(id, field, location, target);
|
|
70653
|
+
}
|
|
70654
|
+
remove(id, field, target) {
|
|
70655
|
+
return this.topLayer.remove(id, field, target);
|
|
70656
|
+
}
|
|
70657
|
+
delete(id) {
|
|
70658
|
+
return this.topLayer.delete(id);
|
|
70659
|
+
}
|
|
70660
|
+
deleteField(id, field) {
|
|
70661
|
+
return this.topLayer.deleteField(id, field);
|
|
70662
|
+
}
|
|
70663
|
+
getLayer(id) {
|
|
70664
|
+
for (const layer of this.data) {
|
|
70665
|
+
if (layer.id === id) {
|
|
70666
|
+
return layer;
|
|
70667
|
+
}
|
|
70668
|
+
}
|
|
70669
|
+
throw new Error("Could not find layer with id: " + id);
|
|
70670
|
+
}
|
|
70671
|
+
replaceID(replacement) {
|
|
70672
|
+
for (const layer of this.data) {
|
|
70673
|
+
layer.replaceID(replacement);
|
|
70674
|
+
}
|
|
70675
|
+
}
|
|
70676
|
+
get(id, field) {
|
|
70677
|
+
const operations = {
|
|
70678
|
+
[OperationKind.insert]: {
|
|
70679
|
+
[OperationLocation.start]: [],
|
|
70680
|
+
[OperationLocation.end]: []
|
|
70681
|
+
},
|
|
70682
|
+
[OperationKind.remove]: /* @__PURE__ */ new Set()
|
|
70683
|
+
};
|
|
70684
|
+
const layerIDs = [];
|
|
70685
|
+
for (let i2 = this.data.length - 1; i2 >= 0; i2--) {
|
|
70686
|
+
const layer = this.data[i2];
|
|
70687
|
+
const [layerValue, kind] = layer.get(id, field);
|
|
70688
|
+
const layerOperations = layer.getOperations(id, field) || [];
|
|
70689
|
+
layer.deletedIDs.forEach((v) => {
|
|
70690
|
+
if (layer.operations[v]?.undoDeletesInList?.includes(field)) {
|
|
70691
|
+
return;
|
|
70692
|
+
}
|
|
70693
|
+
operations.remove.add(v);
|
|
70694
|
+
});
|
|
70695
|
+
if (typeof layerValue === "undefined" && layerOperations.length === 0) {
|
|
70696
|
+
if (layer.deletedIDs.size > 0) {
|
|
70697
|
+
layerIDs.push(layer.id);
|
|
70698
|
+
}
|
|
70699
|
+
continue;
|
|
70700
|
+
}
|
|
70701
|
+
if (typeof layerValue !== "undefined" && !Array.isArray(layerValue)) {
|
|
70702
|
+
return {
|
|
70703
|
+
value: layerValue,
|
|
70704
|
+
kind,
|
|
70705
|
+
displayLayers: [layer.id]
|
|
70706
|
+
};
|
|
70707
|
+
}
|
|
70708
|
+
layerIDs.push(layer.id);
|
|
70709
|
+
if (layerOperations.length > 0) {
|
|
70710
|
+
for (const op of layerOperations) {
|
|
70711
|
+
if (isRemoveOperation(op)) {
|
|
70712
|
+
operations.remove.add(op.id);
|
|
70713
|
+
}
|
|
70714
|
+
if (isInsertOperation(op)) {
|
|
70715
|
+
operations.insert[op.location].unshift(op.id);
|
|
70716
|
+
}
|
|
70717
|
+
if (isDeleteOperation(op)) {
|
|
70718
|
+
return {
|
|
70719
|
+
value: void 0,
|
|
70720
|
+
kind: "unknown",
|
|
70721
|
+
displayLayers: []
|
|
70722
|
+
};
|
|
70723
|
+
}
|
|
70724
|
+
}
|
|
70725
|
+
}
|
|
70726
|
+
if (typeof layerValue === "undefined") {
|
|
70727
|
+
continue;
|
|
70728
|
+
}
|
|
70729
|
+
if (!operations.remove.size && !operations.insert.start.length && !operations.insert.end.length) {
|
|
70730
|
+
return { value: layerValue, displayLayers: layerIDs, kind: "link" };
|
|
70731
|
+
}
|
|
70732
|
+
return {
|
|
70733
|
+
value: [...operations.insert.start, ...layerValue, ...operations.insert.end].filter(
|
|
70734
|
+
(value) => !operations.remove.has(value)
|
|
70735
|
+
),
|
|
70736
|
+
displayLayers: layerIDs,
|
|
70737
|
+
kind
|
|
70738
|
+
};
|
|
70739
|
+
}
|
|
70740
|
+
return {
|
|
70741
|
+
value: void 0,
|
|
70742
|
+
kind: "unknown",
|
|
70743
|
+
displayLayers: []
|
|
70744
|
+
};
|
|
70745
|
+
}
|
|
70746
|
+
writeLink(id, field, value) {
|
|
70747
|
+
return this.topLayer.writeLink(id, field, value);
|
|
70748
|
+
}
|
|
70749
|
+
writeField(id, field, value) {
|
|
70750
|
+
return this.topLayer.writeField(id, field, value);
|
|
70751
|
+
}
|
|
70752
|
+
resolveLayer(id) {
|
|
70753
|
+
let startingIndex = null;
|
|
70754
|
+
for (const [index, layer] of this.data.entries()) {
|
|
70755
|
+
if (layer.id !== id) {
|
|
70756
|
+
continue;
|
|
70757
|
+
}
|
|
70758
|
+
startingIndex = index - 1;
|
|
70759
|
+
this.data[index].optimistic = false;
|
|
70760
|
+
break;
|
|
70761
|
+
}
|
|
70762
|
+
if (startingIndex === null) {
|
|
70763
|
+
throw new Error("could not find layer with id: " + id);
|
|
70764
|
+
}
|
|
70765
|
+
if (startingIndex === -1) {
|
|
70766
|
+
startingIndex = 0;
|
|
70767
|
+
}
|
|
70768
|
+
if (this.data[startingIndex].optimistic) {
|
|
70769
|
+
startingIndex++;
|
|
70770
|
+
}
|
|
70771
|
+
const baseLayer = this.data[startingIndex];
|
|
70772
|
+
let layerIndex = startingIndex;
|
|
70773
|
+
while (layerIndex < this.data.length) {
|
|
70774
|
+
const layer = this.data[layerIndex++];
|
|
70775
|
+
if (layer.optimistic) {
|
|
70776
|
+
layerIndex--;
|
|
70777
|
+
break;
|
|
70778
|
+
}
|
|
70779
|
+
baseLayer.writeLayer(layer);
|
|
70780
|
+
}
|
|
70781
|
+
this.data.splice(startingIndex + 1, layerIndex - startingIndex - 1);
|
|
70782
|
+
}
|
|
70783
|
+
get topLayer() {
|
|
70784
|
+
if (this.data.length === 0) {
|
|
70785
|
+
this.createLayer();
|
|
70786
|
+
}
|
|
70787
|
+
if (this.data[this.data.length - 1]?.optimistic) {
|
|
70788
|
+
this.createLayer();
|
|
70789
|
+
}
|
|
70790
|
+
return this.data[this.data.length - 1];
|
|
70791
|
+
}
|
|
70792
|
+
};
|
|
70793
|
+
var Layer = class {
|
|
70794
|
+
id;
|
|
70795
|
+
optimistic = false;
|
|
70796
|
+
fields = {};
|
|
70797
|
+
links = {};
|
|
70798
|
+
operations = {};
|
|
70799
|
+
deletedIDs = /* @__PURE__ */ new Set();
|
|
70800
|
+
constructor(id) {
|
|
70801
|
+
this.id = id;
|
|
70802
|
+
}
|
|
70803
|
+
get(id, field) {
|
|
70804
|
+
if (typeof this.links[id]?.[field] !== "undefined") {
|
|
70805
|
+
return [this.links[id][field], "link"];
|
|
70806
|
+
}
|
|
70807
|
+
return [this.fields[id]?.[field], "scalar"];
|
|
70808
|
+
}
|
|
70809
|
+
getOperations(id, field) {
|
|
70810
|
+
if (this.operations[id]?.deleted) {
|
|
70811
|
+
return [
|
|
70812
|
+
{
|
|
70813
|
+
kind: OperationKind.delete,
|
|
70814
|
+
target: id
|
|
70815
|
+
}
|
|
70816
|
+
];
|
|
70817
|
+
}
|
|
70818
|
+
if (this.operations[id]?.fields?.[field]) {
|
|
70819
|
+
return this.operations[id].fields[field];
|
|
70820
|
+
}
|
|
70821
|
+
}
|
|
70822
|
+
writeField(id, field, value) {
|
|
70823
|
+
this.fields[id] = {
|
|
70824
|
+
...this.fields[id],
|
|
70825
|
+
[field]: value
|
|
70826
|
+
};
|
|
70827
|
+
return this.id;
|
|
70828
|
+
}
|
|
70829
|
+
writeLink(id, field, value) {
|
|
70830
|
+
const valueList = Array.isArray(value) ? value : [value];
|
|
70831
|
+
for (const value2 of flatten(valueList)) {
|
|
70832
|
+
if (!value2) {
|
|
70833
|
+
continue;
|
|
70834
|
+
}
|
|
70835
|
+
const fieldOperations = this.operations[id]?.fields[field];
|
|
70836
|
+
if (this.operations[value2]?.deleted || this.deletedIDs.has(value2)) {
|
|
70837
|
+
this.operations[value2] = {
|
|
70838
|
+
...this.operations[value2],
|
|
70839
|
+
undoDeletesInList: [...this.operations[id]?.undoDeletesInList || [], field]
|
|
70840
|
+
};
|
|
70841
|
+
} else if (value2 && fieldOperations?.length > 0) {
|
|
70842
|
+
this.operations[id].fields[field] = fieldOperations.filter(
|
|
70843
|
+
(op) => op.kind !== "remove" || op.id !== value2
|
|
70844
|
+
);
|
|
70845
|
+
}
|
|
70846
|
+
}
|
|
70847
|
+
this.links[id] = {
|
|
70848
|
+
...this.links[id],
|
|
70849
|
+
[field]: value
|
|
70850
|
+
};
|
|
70851
|
+
return this.id;
|
|
70852
|
+
}
|
|
70853
|
+
isDisplayLayer(displayLayers) {
|
|
70854
|
+
return displayLayers.length === 0 || displayLayers.includes(this.id) || Math.max(...displayLayers) < this.id;
|
|
70855
|
+
}
|
|
70856
|
+
clear() {
|
|
70857
|
+
this.links = {};
|
|
70858
|
+
this.fields = {};
|
|
70859
|
+
this.operations = {};
|
|
70860
|
+
this.deletedIDs = /* @__PURE__ */ new Set();
|
|
70861
|
+
}
|
|
70862
|
+
replaceID({ from, to }) {
|
|
70863
|
+
this.fields[to] = this.fields[from];
|
|
70864
|
+
this.links[to] = this.links[from];
|
|
70865
|
+
this.operations[to] = this.operations[from] || { fields: {} };
|
|
70866
|
+
if (this.deletedIDs.has(from)) {
|
|
70867
|
+
this.deletedIDs.add(to);
|
|
70868
|
+
}
|
|
70869
|
+
}
|
|
70870
|
+
removeUndefinedFields() {
|
|
70871
|
+
for (const [id, fields] of Object.entries(this.fields)) {
|
|
70872
|
+
for (const [field, value] of Object.entries(fields)) {
|
|
70873
|
+
if (typeof value === "undefined") {
|
|
70874
|
+
try {
|
|
70875
|
+
delete this.fields[id][field];
|
|
70876
|
+
} catch {
|
|
70877
|
+
}
|
|
70878
|
+
try {
|
|
70879
|
+
delete this.links[id][field];
|
|
70880
|
+
} catch {
|
|
70881
|
+
}
|
|
70882
|
+
}
|
|
70883
|
+
}
|
|
70884
|
+
if (Object.keys(fields || {}).length === 0) {
|
|
70885
|
+
delete this.fields[id];
|
|
70886
|
+
}
|
|
70887
|
+
if (Object.keys(this.links[id] || {}).length === 0) {
|
|
70888
|
+
delete this.links[id];
|
|
70889
|
+
}
|
|
70890
|
+
}
|
|
70891
|
+
}
|
|
70892
|
+
delete(id) {
|
|
70893
|
+
this.operations = {
|
|
70894
|
+
...this.operations,
|
|
70895
|
+
[id]: {
|
|
70896
|
+
...this.operations[id],
|
|
70897
|
+
deleted: true,
|
|
70898
|
+
undoDeletesInList: []
|
|
70899
|
+
}
|
|
70900
|
+
};
|
|
70901
|
+
this.deletedIDs.add(id);
|
|
70902
|
+
}
|
|
70903
|
+
deleteField(id, field) {
|
|
70904
|
+
this.fields[id] = {
|
|
70905
|
+
...this.fields[id],
|
|
70906
|
+
[field]: void 0
|
|
70907
|
+
};
|
|
70908
|
+
}
|
|
70909
|
+
insert(id, field, where, target) {
|
|
70910
|
+
this.addFieldOperation(id, field, {
|
|
70911
|
+
kind: OperationKind.insert,
|
|
70912
|
+
id: target,
|
|
70913
|
+
location: where
|
|
70914
|
+
});
|
|
70915
|
+
}
|
|
70916
|
+
remove(id, field, target) {
|
|
70917
|
+
this.addFieldOperation(id, field, {
|
|
70918
|
+
kind: OperationKind.remove,
|
|
70919
|
+
id: target
|
|
70920
|
+
});
|
|
70921
|
+
}
|
|
70922
|
+
writeLayer(layer) {
|
|
70923
|
+
if (layer.id === this.id) {
|
|
70924
|
+
return;
|
|
70925
|
+
}
|
|
70926
|
+
for (const [id, ops] of Object.entries(layer.operations)) {
|
|
70927
|
+
const fields = {};
|
|
70928
|
+
for (const opMap of [this.operations[id], layer.operations[id]].filter(Boolean)) {
|
|
70929
|
+
for (const [fieldName, operations] of Object.entries(opMap.fields || {})) {
|
|
70930
|
+
fields[fieldName] = [...fields[fieldName] || [], ...operations];
|
|
70931
|
+
}
|
|
70932
|
+
}
|
|
70933
|
+
if (Object.keys(fields).length > 0) {
|
|
70934
|
+
this.operations[id] = {
|
|
70935
|
+
...this.operations[id],
|
|
70936
|
+
fields
|
|
70937
|
+
};
|
|
70938
|
+
}
|
|
70939
|
+
if (ops?.deleted) {
|
|
70940
|
+
delete this.fields[id];
|
|
70941
|
+
delete this.links[id];
|
|
70942
|
+
}
|
|
70943
|
+
}
|
|
70944
|
+
for (const [id, values] of Object.entries(layer.fields)) {
|
|
70945
|
+
if (!values) {
|
|
70946
|
+
continue;
|
|
70947
|
+
}
|
|
70948
|
+
for (const [field, value] of Object.entries(values)) {
|
|
70949
|
+
this.writeField(id, field, value);
|
|
70950
|
+
}
|
|
70951
|
+
}
|
|
70952
|
+
for (const [id, values] of Object.entries(layer.links)) {
|
|
70953
|
+
if (!values) {
|
|
70954
|
+
continue;
|
|
70955
|
+
}
|
|
70956
|
+
for (const [field, value] of Object.entries(values)) {
|
|
70957
|
+
this.writeLink(id, field, value);
|
|
70958
|
+
}
|
|
70959
|
+
}
|
|
70960
|
+
layer.deletedIDs.forEach((v) => this.deletedIDs.add(v));
|
|
70961
|
+
}
|
|
70962
|
+
addFieldOperation(id, field, operation) {
|
|
70963
|
+
this.operations = {
|
|
70964
|
+
...this.operations,
|
|
70965
|
+
[id]: {
|
|
70966
|
+
...this.operations[id],
|
|
70967
|
+
fields: {
|
|
70968
|
+
[field]: [...this.operations[id]?.fields[field] || [], operation]
|
|
70969
|
+
}
|
|
70970
|
+
}
|
|
70971
|
+
};
|
|
70972
|
+
}
|
|
70973
|
+
};
|
|
70974
|
+
function isDeleteOperation(value) {
|
|
70975
|
+
return !!value && value.kind === OperationKind.delete;
|
|
70976
|
+
}
|
|
70977
|
+
function isInsertOperation(value) {
|
|
70978
|
+
return !!value && value.kind === OperationKind.insert;
|
|
70979
|
+
}
|
|
70980
|
+
function isRemoveOperation(value) {
|
|
70981
|
+
return !!value && value.kind === OperationKind.remove;
|
|
70982
|
+
}
|
|
70983
|
+
var OperationLocation = {
|
|
70984
|
+
start: "start",
|
|
70985
|
+
end: "end"
|
|
70986
|
+
};
|
|
70987
|
+
var OperationKind = {
|
|
70988
|
+
delete: "delete",
|
|
70989
|
+
insert: "insert",
|
|
70990
|
+
remove: "remove"
|
|
70991
|
+
};
|
|
70992
|
+
|
|
70993
|
+
// src/runtime/cache/stuff.ts
|
|
70994
|
+
function evaluateKey(key, variables = {}) {
|
|
70995
|
+
let evaluated = "";
|
|
70996
|
+
let varName = "";
|
|
70997
|
+
let inString = false;
|
|
70998
|
+
for (const char of key) {
|
|
70999
|
+
if (varName) {
|
|
71000
|
+
if (varChars.includes(char)) {
|
|
71001
|
+
varName += char;
|
|
71002
|
+
continue;
|
|
71003
|
+
}
|
|
71004
|
+
const value = variables[varName.slice(1)];
|
|
71005
|
+
evaluated += typeof value !== "undefined" ? JSON.stringify(value) : "undefined";
|
|
71006
|
+
varName = "";
|
|
71007
|
+
}
|
|
71008
|
+
if (char === "$" && !inString) {
|
|
71009
|
+
varName = "$";
|
|
71010
|
+
continue;
|
|
71011
|
+
}
|
|
71012
|
+
if (char === '"') {
|
|
71013
|
+
inString = !inString;
|
|
71014
|
+
}
|
|
71015
|
+
evaluated += char;
|
|
71016
|
+
}
|
|
71017
|
+
return evaluated;
|
|
71018
|
+
}
|
|
71019
|
+
var varChars = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ_0123456789";
|
|
71020
|
+
|
|
71021
|
+
// src/runtime/cache/subscription.ts
|
|
71022
|
+
var InMemorySubscriptions = class {
|
|
71023
|
+
cache;
|
|
71024
|
+
constructor(cache) {
|
|
71025
|
+
this.cache = cache;
|
|
71026
|
+
}
|
|
71027
|
+
subscribers = {};
|
|
71028
|
+
referenceCounts = {};
|
|
71029
|
+
keyVersions = {};
|
|
71030
|
+
add({
|
|
71031
|
+
parent,
|
|
71032
|
+
spec,
|
|
71033
|
+
selection: selection2,
|
|
71034
|
+
variables,
|
|
71035
|
+
parentType
|
|
71036
|
+
}) {
|
|
71037
|
+
const __typename = this.cache._internal_unstable.storage.get(parent, "__typename").value;
|
|
71038
|
+
let targetSelection = getFieldsForType(selection2, __typename);
|
|
71039
|
+
for (const fieldSelection of Object.values(targetSelection || {})) {
|
|
71040
|
+
const { keyRaw, selection: innerSelection, type, list, filters } = fieldSelection;
|
|
71041
|
+
const key = evaluateKey(keyRaw, variables);
|
|
71042
|
+
let targetSelection2;
|
|
71043
|
+
if (innerSelection) {
|
|
71044
|
+
const __typename2 = this.cache._internal_unstable.storage.get(parent, "__typename").value;
|
|
71045
|
+
targetSelection2 = getFieldsForType(innerSelection, __typename2);
|
|
71046
|
+
}
|
|
71047
|
+
this.addFieldSubscription({
|
|
71048
|
+
id: parent,
|
|
71049
|
+
key,
|
|
71050
|
+
selection: [spec, targetSelection2],
|
|
71051
|
+
type
|
|
71052
|
+
});
|
|
71053
|
+
if (list) {
|
|
71054
|
+
this.registerList({
|
|
71055
|
+
list,
|
|
71056
|
+
filters,
|
|
71057
|
+
id: parent,
|
|
71058
|
+
key,
|
|
71059
|
+
variables,
|
|
71060
|
+
selection: innerSelection,
|
|
71061
|
+
parentType: parentType || spec.rootType
|
|
71062
|
+
});
|
|
71063
|
+
}
|
|
71064
|
+
if (innerSelection) {
|
|
71065
|
+
const { value: linkedRecord } = this.cache._internal_unstable.storage.get(
|
|
71066
|
+
parent,
|
|
71067
|
+
key
|
|
71068
|
+
);
|
|
71069
|
+
let children = !Array.isArray(linkedRecord) ? [linkedRecord] : flatten(linkedRecord) || [];
|
|
71070
|
+
for (const child of children) {
|
|
71071
|
+
if (!child) {
|
|
71072
|
+
continue;
|
|
71073
|
+
}
|
|
71074
|
+
this.add({
|
|
71075
|
+
parent: child,
|
|
71076
|
+
spec,
|
|
71077
|
+
selection: innerSelection,
|
|
71078
|
+
variables,
|
|
71079
|
+
parentType: type
|
|
71080
|
+
});
|
|
71081
|
+
}
|
|
71082
|
+
}
|
|
71083
|
+
}
|
|
71084
|
+
}
|
|
71085
|
+
addFieldSubscription({
|
|
71086
|
+
id,
|
|
71087
|
+
key,
|
|
71088
|
+
selection: selection2,
|
|
71089
|
+
type
|
|
71090
|
+
}) {
|
|
71091
|
+
const spec = selection2[0];
|
|
71092
|
+
if (!this.subscribers[id]) {
|
|
71093
|
+
this.subscribers[id] = {};
|
|
71094
|
+
}
|
|
71095
|
+
if (!this.subscribers[id][key]) {
|
|
71096
|
+
this.subscribers[id][key] = [];
|
|
71097
|
+
}
|
|
71098
|
+
if (!this.keyVersions[key]) {
|
|
71099
|
+
this.keyVersions[key] = /* @__PURE__ */ new Set();
|
|
71100
|
+
}
|
|
71101
|
+
this.keyVersions[key].add(key);
|
|
71102
|
+
if (!this.subscribers[id][key].map(([{ set }]) => set).includes(spec.set)) {
|
|
71103
|
+
this.subscribers[id][key].push([spec, selection2[1]]);
|
|
71104
|
+
}
|
|
71105
|
+
if (!this.referenceCounts[id]) {
|
|
71106
|
+
this.referenceCounts[id] = {};
|
|
71107
|
+
}
|
|
71108
|
+
if (!this.referenceCounts[id][key]) {
|
|
71109
|
+
this.referenceCounts[id][key] = /* @__PURE__ */ new Map();
|
|
71110
|
+
}
|
|
71111
|
+
const counts = this.referenceCounts[id][key];
|
|
71112
|
+
counts.set(spec.set, (counts.get(spec.set) || 0) + 1);
|
|
71113
|
+
this.cache._internal_unstable.lifetimes.resetLifetime(id, key);
|
|
71114
|
+
const { selection: innerSelection } = selection2[1]?.[key] ?? {};
|
|
71115
|
+
}
|
|
71116
|
+
registerList({
|
|
71117
|
+
list,
|
|
71118
|
+
id,
|
|
71119
|
+
key,
|
|
71120
|
+
parentType,
|
|
71121
|
+
selection: selection2,
|
|
71122
|
+
filters,
|
|
71123
|
+
variables
|
|
71124
|
+
}) {
|
|
71125
|
+
this.cache._internal_unstable.lists.add({
|
|
71126
|
+
name: list.name,
|
|
71127
|
+
connection: list.connection,
|
|
71128
|
+
recordID: id,
|
|
71129
|
+
recordType: this.cache._internal_unstable.storage.get(id, "__typename")?.value || parentType,
|
|
71130
|
+
listType: list.type,
|
|
71131
|
+
key,
|
|
71132
|
+
selection: selection2,
|
|
71133
|
+
filters: Object.entries(filters || {}).reduce((acc, [key2, { kind, value }]) => {
|
|
71134
|
+
return {
|
|
71135
|
+
...acc,
|
|
71136
|
+
[key2]: kind !== "Variable" ? value : variables[value]
|
|
71137
|
+
};
|
|
71138
|
+
}, {})
|
|
71139
|
+
});
|
|
71140
|
+
}
|
|
71141
|
+
addMany({
|
|
71142
|
+
parent,
|
|
71143
|
+
variables,
|
|
71144
|
+
subscribers,
|
|
71145
|
+
parentType
|
|
71146
|
+
}) {
|
|
71147
|
+
for (const [spec, targetSelection] of subscribers) {
|
|
71148
|
+
for (const selection2 of Object.values(targetSelection ?? {})) {
|
|
71149
|
+
const {
|
|
71150
|
+
type: linkedType,
|
|
71151
|
+
keyRaw,
|
|
71152
|
+
selection: innerSelection,
|
|
71153
|
+
list,
|
|
71154
|
+
filters
|
|
71155
|
+
} = selection2;
|
|
71156
|
+
const key = evaluateKey(keyRaw, variables);
|
|
71157
|
+
const fieldSelection = innerSelection ? getFieldsForType(innerSelection, parentType) : void 0;
|
|
71158
|
+
this.addFieldSubscription({
|
|
71159
|
+
id: parent,
|
|
71160
|
+
key,
|
|
71161
|
+
selection: [spec, fieldSelection],
|
|
71162
|
+
type: linkedType
|
|
71163
|
+
});
|
|
71164
|
+
if (list) {
|
|
71165
|
+
this.registerList({
|
|
71166
|
+
list,
|
|
71167
|
+
filters,
|
|
71168
|
+
id: parent,
|
|
71169
|
+
key,
|
|
71170
|
+
variables,
|
|
71171
|
+
selection: innerSelection,
|
|
71172
|
+
parentType: parentType || spec.rootType
|
|
71173
|
+
});
|
|
71174
|
+
}
|
|
71175
|
+
const childSelection = selection2.selection;
|
|
71176
|
+
if (childSelection) {
|
|
71177
|
+
const { value: link } = this.cache._internal_unstable.storage.get(parent, key);
|
|
71178
|
+
const children = !Array.isArray(link) ? [link] : flatten(link);
|
|
71179
|
+
for (const linkedRecord of children) {
|
|
71180
|
+
if (!linkedRecord) {
|
|
71181
|
+
continue;
|
|
71182
|
+
}
|
|
71183
|
+
const __typename = this.cache._internal_unstable.storage.get(
|
|
71184
|
+
linkedRecord,
|
|
71185
|
+
"__typename"
|
|
71186
|
+
).value;
|
|
71187
|
+
let targetSelection2 = getFieldsForType(childSelection, __typename);
|
|
71188
|
+
this.addMany({
|
|
71189
|
+
parent: linkedRecord,
|
|
71190
|
+
variables,
|
|
71191
|
+
subscribers: subscribers.map(([sub]) => [sub, targetSelection2]),
|
|
71192
|
+
parentType: linkedType
|
|
71193
|
+
});
|
|
71194
|
+
}
|
|
71195
|
+
}
|
|
71196
|
+
}
|
|
71197
|
+
}
|
|
71198
|
+
}
|
|
71199
|
+
get(id, field) {
|
|
71200
|
+
return this.subscribers[id]?.[field] || [];
|
|
71201
|
+
}
|
|
71202
|
+
remove(id, selection2, targets, variables, visited = []) {
|
|
71203
|
+
visited.push(id);
|
|
71204
|
+
const linkedIDs = [];
|
|
71205
|
+
const __typename = this.cache._internal_unstable.storage.get(id, "__typename").value;
|
|
71206
|
+
let targetSelection = getFieldsForType(selection2, __typename);
|
|
71207
|
+
for (const fieldSelection of Object.values(targetSelection || {})) {
|
|
71208
|
+
const key = evaluateKey(fieldSelection.keyRaw, variables);
|
|
71209
|
+
this.removeSubscribers(id, key, targets);
|
|
71210
|
+
if (!fieldSelection.selection) {
|
|
71211
|
+
continue;
|
|
71212
|
+
}
|
|
71213
|
+
const { value: previousValue } = this.cache._internal_unstable.storage.get(id, key);
|
|
71214
|
+
const links = !Array.isArray(previousValue) ? [previousValue] : flatten(previousValue);
|
|
71215
|
+
for (const link of links) {
|
|
71216
|
+
if (link !== null) {
|
|
71217
|
+
linkedIDs.push([link, fieldSelection.selection || {}]);
|
|
71218
|
+
}
|
|
71219
|
+
}
|
|
71220
|
+
}
|
|
71221
|
+
for (const [linkedRecordID, linkFields] of linkedIDs) {
|
|
71222
|
+
this.remove(linkedRecordID, linkFields, targets, visited);
|
|
71223
|
+
}
|
|
71224
|
+
}
|
|
71225
|
+
removeSubscribers(id, fieldName, specs) {
|
|
71226
|
+
let targets = [];
|
|
71227
|
+
for (const spec of specs) {
|
|
71228
|
+
if (!this.referenceCounts[id]?.[fieldName]?.has(spec.set)) {
|
|
71229
|
+
continue;
|
|
71230
|
+
}
|
|
71231
|
+
const counts = this.referenceCounts[id][fieldName];
|
|
71232
|
+
const newVal = (counts.get(spec.set) || 0) - 1;
|
|
71233
|
+
counts.set(spec.set, newVal);
|
|
71234
|
+
if (newVal <= 0) {
|
|
71235
|
+
targets.push(spec.set);
|
|
71236
|
+
counts.delete(spec.set);
|
|
71237
|
+
}
|
|
71238
|
+
}
|
|
71239
|
+
if (this.subscribers[id]) {
|
|
71240
|
+
this.subscribers[id][fieldName] = this.get(id, fieldName).filter(
|
|
71241
|
+
([{ set }]) => !targets.includes(set)
|
|
71242
|
+
);
|
|
71243
|
+
}
|
|
71244
|
+
}
|
|
71245
|
+
removeAllSubscribers(id, targets, visited = []) {
|
|
71246
|
+
visited.push(id);
|
|
71247
|
+
for (const field of Object.keys(this.subscribers[id] || [])) {
|
|
71248
|
+
const subscribers = targets || this.subscribers[id][field].map(([spec]) => spec);
|
|
71249
|
+
this.removeSubscribers(id, field, subscribers);
|
|
71250
|
+
const { value, kind } = this.cache._internal_unstable.storage.get(id, field);
|
|
71251
|
+
if (kind === "scalar") {
|
|
71252
|
+
continue;
|
|
71253
|
+
}
|
|
71254
|
+
const nextTargets = Array.isArray(value) ? flatten(value) : [value];
|
|
71255
|
+
for (const id2 of nextTargets) {
|
|
71256
|
+
if (visited.includes(id2)) {
|
|
71257
|
+
continue;
|
|
71258
|
+
}
|
|
71259
|
+
this.removeAllSubscribers(id2, subscribers, visited);
|
|
71260
|
+
}
|
|
71261
|
+
}
|
|
71262
|
+
}
|
|
71263
|
+
};
|
|
71264
|
+
|
|
71265
|
+
// src/runtime/cache/cache.ts
|
|
71266
|
+
var Cache = class {
|
|
71267
|
+
_internal_unstable;
|
|
71268
|
+
constructor(config2) {
|
|
71269
|
+
this._internal_unstable = new CacheInternal({
|
|
71270
|
+
cache: this,
|
|
71271
|
+
storage: new InMemoryStorage(),
|
|
71272
|
+
subscriptions: new InMemorySubscriptions(this),
|
|
71273
|
+
lists: new ListManager(this, rootID),
|
|
71274
|
+
lifetimes: new GarbageCollector(this),
|
|
71275
|
+
staleManager: new StaleManager(this),
|
|
71276
|
+
schema: new SchemaManager(this)
|
|
71277
|
+
});
|
|
71278
|
+
if (config2) {
|
|
71279
|
+
this.setConfig(defaultConfigValues(config2));
|
|
71280
|
+
}
|
|
71281
|
+
}
|
|
71282
|
+
write({
|
|
71283
|
+
layer: layerID,
|
|
71284
|
+
notifySubscribers = [],
|
|
71285
|
+
...args
|
|
71286
|
+
}) {
|
|
71287
|
+
const layer = layerID ? this._internal_unstable.storage.getLayer(layerID) : this._internal_unstable.storage.topLayer;
|
|
71288
|
+
const subscribers = this._internal_unstable.writeSelection({ ...args, layer }).map((sub) => sub[0]);
|
|
71289
|
+
const notified = [];
|
|
71290
|
+
for (const spec of subscribers.concat(notifySubscribers)) {
|
|
71291
|
+
if (!notified.includes(spec.set)) {
|
|
71292
|
+
notified.push(spec.set);
|
|
71293
|
+
spec.set(
|
|
71294
|
+
this._internal_unstable.getSelection({
|
|
71295
|
+
parent: spec.parentID || rootID,
|
|
71296
|
+
selection: spec.selection,
|
|
71297
|
+
variables: spec.variables?.() || {}
|
|
71298
|
+
}).data
|
|
71299
|
+
);
|
|
71300
|
+
}
|
|
71301
|
+
}
|
|
71302
|
+
return subscribers;
|
|
71303
|
+
}
|
|
71304
|
+
read(...args) {
|
|
71305
|
+
const { data, partial, stale, hasData } = this._internal_unstable.getSelection(...args);
|
|
71306
|
+
if (!hasData) {
|
|
71307
|
+
return { data: null, partial: false, stale: false };
|
|
71308
|
+
}
|
|
71309
|
+
return {
|
|
71310
|
+
data,
|
|
71311
|
+
partial,
|
|
71312
|
+
stale
|
|
71313
|
+
};
|
|
71314
|
+
}
|
|
71315
|
+
subscribe(spec, variables = {}) {
|
|
71316
|
+
return this._internal_unstable.subscriptions.add({
|
|
71317
|
+
parent: spec.parentID || rootID,
|
|
71318
|
+
spec,
|
|
71319
|
+
selection: spec.selection,
|
|
71320
|
+
variables
|
|
71321
|
+
});
|
|
71322
|
+
}
|
|
71323
|
+
unsubscribe(spec, variables = {}) {
|
|
71324
|
+
return this._internal_unstable.subscriptions.remove(
|
|
71325
|
+
spec.parentID || rootID,
|
|
71326
|
+
spec.selection,
|
|
71327
|
+
[spec],
|
|
71328
|
+
variables
|
|
71329
|
+
);
|
|
71330
|
+
}
|
|
71331
|
+
list(name, parentID, allLists) {
|
|
71332
|
+
const handler = this._internal_unstable.lists.get(name, parentID, allLists);
|
|
71333
|
+
if (!handler) {
|
|
71334
|
+
throw new Error(
|
|
71335
|
+
`Cannot find list with name: ${name}${parentID ? " under parent " + parentID : ""}. Is it possible that the query is not mounted?`
|
|
71336
|
+
);
|
|
71337
|
+
}
|
|
71338
|
+
return handler;
|
|
71339
|
+
}
|
|
71340
|
+
delete(id) {
|
|
71341
|
+
this._internal_unstable.subscriptions.removeAllSubscribers(id);
|
|
71342
|
+
this._internal_unstable.lists.removeIDFromAllLists(id);
|
|
71343
|
+
this._internal_unstable.storage.delete(id);
|
|
71344
|
+
}
|
|
71345
|
+
setConfig(config2) {
|
|
71346
|
+
this._internal_unstable.setConfig(config2);
|
|
71347
|
+
}
|
|
71348
|
+
markTypeStale(options) {
|
|
71349
|
+
if (!options) {
|
|
71350
|
+
this._internal_unstable.staleManager.markAllStale();
|
|
71351
|
+
} else if (!options.field) {
|
|
71352
|
+
this._internal_unstable.staleManager.markTypeStale(options.type);
|
|
71353
|
+
} else {
|
|
71354
|
+
this._internal_unstable.staleManager.markTypeFieldStale(
|
|
71355
|
+
options.type,
|
|
71356
|
+
options.field,
|
|
71357
|
+
options.when
|
|
71358
|
+
);
|
|
71359
|
+
}
|
|
71360
|
+
}
|
|
71361
|
+
markRecordStale(id, options) {
|
|
71362
|
+
if (options.field) {
|
|
71363
|
+
const key = computeKey({ field: options.field, args: options.when ?? {} });
|
|
71364
|
+
this._internal_unstable.staleManager.markFieldStale(id, key);
|
|
71365
|
+
} else {
|
|
71366
|
+
this._internal_unstable.staleManager.markRecordStale(id);
|
|
71367
|
+
}
|
|
71368
|
+
}
|
|
71369
|
+
getFieldTime(id, field) {
|
|
71370
|
+
return this._internal_unstable.staleManager.getFieldTime(id, field);
|
|
71371
|
+
}
|
|
71372
|
+
};
|
|
71373
|
+
var CacheInternal = class {
|
|
71374
|
+
_disabled = false;
|
|
71375
|
+
config = defaultConfigValues({
|
|
71376
|
+
plugins: {
|
|
71377
|
+
"houdini-svelte": {
|
|
71378
|
+
client: ""
|
|
71379
|
+
}
|
|
71380
|
+
}
|
|
71381
|
+
});
|
|
71382
|
+
storage;
|
|
71383
|
+
subscriptions;
|
|
71384
|
+
lists;
|
|
71385
|
+
cache;
|
|
71386
|
+
lifetimes;
|
|
71387
|
+
staleManager;
|
|
71388
|
+
schema;
|
|
71389
|
+
constructor({
|
|
71390
|
+
storage,
|
|
71391
|
+
subscriptions,
|
|
71392
|
+
lists,
|
|
71393
|
+
cache,
|
|
71394
|
+
lifetimes,
|
|
71395
|
+
staleManager,
|
|
71396
|
+
schema
|
|
71397
|
+
}) {
|
|
71398
|
+
this.storage = storage;
|
|
71399
|
+
this.subscriptions = subscriptions;
|
|
71400
|
+
this.lists = lists;
|
|
71401
|
+
this.cache = cache;
|
|
71402
|
+
this.lifetimes = lifetimes;
|
|
71403
|
+
this.staleManager = staleManager;
|
|
71404
|
+
this.schema = schema;
|
|
71405
|
+
this._disabled = typeof globalThis.window === "undefined";
|
|
71406
|
+
try {
|
|
71407
|
+
if (process.env.HOUDINI_TEST === "true") {
|
|
71408
|
+
this._disabled = false;
|
|
71409
|
+
}
|
|
71410
|
+
} catch {
|
|
71411
|
+
}
|
|
71412
|
+
}
|
|
71413
|
+
setConfig(config2) {
|
|
71414
|
+
this.config = config2;
|
|
71415
|
+
}
|
|
71416
|
+
writeSelection({
|
|
71417
|
+
data,
|
|
71418
|
+
selection: selection2,
|
|
71419
|
+
variables = {},
|
|
71420
|
+
parent = rootID,
|
|
71421
|
+
applyUpdates,
|
|
71422
|
+
layer,
|
|
71423
|
+
toNotify = [],
|
|
71424
|
+
forceNotify,
|
|
71425
|
+
forceStale
|
|
71426
|
+
}) {
|
|
71427
|
+
if (this._disabled) {
|
|
71428
|
+
return [];
|
|
71429
|
+
}
|
|
71430
|
+
let targetSelection = getFieldsForType(selection2, data["__typename"]);
|
|
71431
|
+
for (const [field, value] of Object.entries(data)) {
|
|
71432
|
+
if (!selection2 || !targetSelection[field]) {
|
|
71433
|
+
throw new Error(
|
|
71434
|
+
"Could not find field listing in selection for " + field + " @ " + JSON.stringify(selection2)
|
|
71435
|
+
);
|
|
71436
|
+
}
|
|
71437
|
+
let {
|
|
71438
|
+
type: linkedType,
|
|
71439
|
+
keyRaw,
|
|
71440
|
+
selection: fieldSelection,
|
|
71441
|
+
operations,
|
|
71442
|
+
abstract: isAbstract,
|
|
71443
|
+
updates,
|
|
71444
|
+
nullable
|
|
71445
|
+
} = targetSelection[field];
|
|
71446
|
+
const key = evaluateKey(keyRaw, variables);
|
|
71447
|
+
this.schema.setFieldType({
|
|
71448
|
+
parent,
|
|
71449
|
+
key: keyRaw,
|
|
71450
|
+
type: linkedType,
|
|
71451
|
+
nullable,
|
|
71452
|
+
link: !!fieldSelection
|
|
71453
|
+
});
|
|
71454
|
+
const currentSubscribers = this.subscriptions.get(parent, key);
|
|
71455
|
+
const specs = currentSubscribers.map((sub) => sub[0]);
|
|
71456
|
+
const { value: previousValue, displayLayers } = this.storage.get(parent, key);
|
|
71457
|
+
const displayLayer = layer.isDisplayLayer(displayLayers);
|
|
71458
|
+
if (displayLayer) {
|
|
71459
|
+
this.lifetimes.resetLifetime(parent, key);
|
|
71460
|
+
if (forceStale) {
|
|
71461
|
+
this.staleManager.markFieldStale(parent, key);
|
|
71462
|
+
} else {
|
|
71463
|
+
this.staleManager.setFieldTimeToNow(parent, key);
|
|
71464
|
+
}
|
|
71465
|
+
}
|
|
71466
|
+
if (!fieldSelection) {
|
|
71467
|
+
let newValue = value;
|
|
71468
|
+
if (updates && applyUpdates && Array.isArray(value)) {
|
|
71469
|
+
for (const update of applyUpdates) {
|
|
71470
|
+
if (!updates.includes(update)) {
|
|
71471
|
+
continue;
|
|
71472
|
+
}
|
|
71473
|
+
if (update === "append") {
|
|
71474
|
+
newValue = (previousValue || []).concat(value);
|
|
71475
|
+
} else if (update === "prepend") {
|
|
71476
|
+
newValue = value.concat(previousValue || []);
|
|
71477
|
+
}
|
|
71478
|
+
}
|
|
71479
|
+
}
|
|
71480
|
+
if (updates && applyUpdates?.includes("prepend") && ["endCursor", "hasNextPage"].includes(key)) {
|
|
71481
|
+
newValue = previousValue;
|
|
71482
|
+
} else if (updates && applyUpdates?.includes("append") && ["startCursor", "hasPreviousPage"].includes(key)) {
|
|
71483
|
+
newValue = previousValue;
|
|
71484
|
+
}
|
|
71485
|
+
const valueChanged = !deepEquals(newValue, previousValue);
|
|
71486
|
+
if (displayLayer && (valueChanged || forceNotify)) {
|
|
71487
|
+
toNotify.push(...currentSubscribers);
|
|
71488
|
+
}
|
|
71489
|
+
layer.writeField(parent, key, newValue);
|
|
71490
|
+
} else if (value === null) {
|
|
71491
|
+
if (previousValue === null) {
|
|
71492
|
+
continue;
|
|
71493
|
+
}
|
|
71494
|
+
const previousLinks = flatten([previousValue]);
|
|
71495
|
+
for (const link of previousLinks) {
|
|
71496
|
+
this.subscriptions.remove(link, fieldSelection, specs, variables);
|
|
71497
|
+
}
|
|
71498
|
+
layer.writeLink(parent, key, null);
|
|
71499
|
+
toNotify.push(...currentSubscribers);
|
|
71500
|
+
} else if (value instanceof Object && !Array.isArray(value)) {
|
|
71501
|
+
if (isAbstract) {
|
|
71502
|
+
if (!value.__typename) {
|
|
71503
|
+
throw new Error(
|
|
71504
|
+
"Encountered interface type without __typename in the payload"
|
|
71505
|
+
);
|
|
71506
|
+
}
|
|
71507
|
+
linkedType = value.__typename;
|
|
71508
|
+
}
|
|
71509
|
+
const embedded = this.idFields(linkedType)?.filter(
|
|
71510
|
+
(field2) => typeof value[field2] === "undefined"
|
|
71511
|
+
).length > 0;
|
|
71512
|
+
let linkedID = null;
|
|
71513
|
+
if (value !== null) {
|
|
71514
|
+
linkedID = !embedded ? this.id(linkedType, value) : `${parent}.${key}`;
|
|
71515
|
+
}
|
|
71516
|
+
let linkChange = linkedID !== previousValue;
|
|
71517
|
+
layer.writeLink(parent, key, linkedID);
|
|
71518
|
+
if (linkedID && displayLayer && (linkChange || forceNotify)) {
|
|
71519
|
+
if (previousValue && typeof previousValue === "string") {
|
|
71520
|
+
this.subscriptions.remove(previousValue, fieldSelection, specs, variables);
|
|
71521
|
+
}
|
|
71522
|
+
this.subscriptions.addMany({
|
|
71523
|
+
parent: linkedID,
|
|
71524
|
+
subscribers: currentSubscribers,
|
|
71525
|
+
variables,
|
|
71526
|
+
parentType: linkedType
|
|
71527
|
+
});
|
|
71528
|
+
toNotify.push(...currentSubscribers);
|
|
71529
|
+
}
|
|
71530
|
+
if (linkedID) {
|
|
71531
|
+
this.writeSelection({
|
|
71532
|
+
selection: fieldSelection,
|
|
71533
|
+
parent: linkedID,
|
|
71534
|
+
data: value,
|
|
71535
|
+
variables,
|
|
71536
|
+
toNotify,
|
|
71537
|
+
applyUpdates,
|
|
71538
|
+
layer,
|
|
71539
|
+
forceNotify
|
|
71540
|
+
});
|
|
71541
|
+
}
|
|
71542
|
+
} else if (Array.isArray(value) && (typeof previousValue === "undefined" || Array.isArray(previousValue))) {
|
|
71543
|
+
let oldIDs = [...previousValue || []];
|
|
71544
|
+
const emptyEdges = !updates ? [] : oldIDs.map((id) => {
|
|
71545
|
+
if (!id) {
|
|
71546
|
+
return "";
|
|
71547
|
+
}
|
|
71548
|
+
const { value: cursorField } = this.storage.get(id, "cursor");
|
|
71549
|
+
if (cursorField) {
|
|
71550
|
+
return "";
|
|
71551
|
+
}
|
|
71552
|
+
const { value: node } = this.storage.get(id, "node");
|
|
71553
|
+
if (!node) {
|
|
71554
|
+
return "";
|
|
71555
|
+
}
|
|
71556
|
+
return node;
|
|
71557
|
+
});
|
|
71558
|
+
let linkedIDs = [];
|
|
71559
|
+
const { newIDs, nestedIDs } = this.extractNestedListIDs({
|
|
71560
|
+
value,
|
|
71561
|
+
abstract: Boolean(isAbstract),
|
|
71562
|
+
specs: toNotify,
|
|
71563
|
+
applyUpdates,
|
|
71564
|
+
recordID: parent,
|
|
71565
|
+
key,
|
|
71566
|
+
linkedType,
|
|
71567
|
+
variables,
|
|
71568
|
+
fields: fieldSelection,
|
|
71569
|
+
layer,
|
|
71570
|
+
forceNotify
|
|
71571
|
+
});
|
|
71572
|
+
if (applyUpdates && updates) {
|
|
71573
|
+
if (key === "edges") {
|
|
71574
|
+
const newNodeIDs = [];
|
|
71575
|
+
for (const id of newIDs) {
|
|
71576
|
+
if (!id) {
|
|
71577
|
+
continue;
|
|
71578
|
+
}
|
|
71579
|
+
const { value: node } = this.storage.get(id, "node");
|
|
71580
|
+
if (typeof node !== "string") {
|
|
71581
|
+
continue;
|
|
71582
|
+
}
|
|
71583
|
+
if (!node || !this.storage.get(node, "__typename")) {
|
|
71584
|
+
continue;
|
|
71585
|
+
}
|
|
71586
|
+
newNodeIDs.push(node);
|
|
71587
|
+
}
|
|
71588
|
+
oldIDs = oldIDs.filter((id) => {
|
|
71589
|
+
if (!id) {
|
|
71590
|
+
return true;
|
|
71591
|
+
}
|
|
71592
|
+
const { value: value2 } = this.storage.get(id, "node");
|
|
71593
|
+
const node = value2;
|
|
71594
|
+
if (newNodeIDs.includes(node) && emptyEdges.includes(node)) {
|
|
71595
|
+
return false;
|
|
71596
|
+
}
|
|
71597
|
+
return true;
|
|
71598
|
+
});
|
|
71599
|
+
}
|
|
71600
|
+
for (const update of applyUpdates) {
|
|
71601
|
+
if (update !== "replace" && !updates.includes(update)) {
|
|
71602
|
+
continue;
|
|
71603
|
+
}
|
|
71604
|
+
if (update === "prepend") {
|
|
71605
|
+
linkedIDs = newIDs.concat(oldIDs);
|
|
71606
|
+
} else if (update === "append") {
|
|
71607
|
+
linkedIDs = oldIDs.concat(newIDs);
|
|
71608
|
+
} else if (update === "replace") {
|
|
71609
|
+
linkedIDs = newIDs;
|
|
71610
|
+
}
|
|
71611
|
+
}
|
|
71612
|
+
} else {
|
|
71613
|
+
linkedIDs = nestedIDs;
|
|
71614
|
+
}
|
|
71615
|
+
const contentChanged = !deepEquals(linkedIDs, oldIDs);
|
|
71616
|
+
if (contentChanged || forceNotify) {
|
|
71617
|
+
toNotify.push(...currentSubscribers);
|
|
71618
|
+
}
|
|
71619
|
+
for (const lostID of oldIDs) {
|
|
71620
|
+
if (linkedIDs.includes(lostID) || !lostID) {
|
|
71621
|
+
continue;
|
|
71622
|
+
}
|
|
71623
|
+
this.subscriptions.remove(lostID, fieldSelection, specs, variables);
|
|
71624
|
+
}
|
|
71625
|
+
if (contentChanged || oldIDs.length === 0 && newIDs.length === 0) {
|
|
71626
|
+
layer.writeLink(parent, key, linkedIDs);
|
|
71627
|
+
}
|
|
71628
|
+
for (const id of newIDs.filter((id2) => !oldIDs.includes(id2))) {
|
|
71629
|
+
if (id == null) {
|
|
71630
|
+
continue;
|
|
71631
|
+
}
|
|
71632
|
+
this.subscriptions.addMany({
|
|
71633
|
+
parent: id,
|
|
71634
|
+
subscribers: currentSubscribers,
|
|
71635
|
+
variables,
|
|
71636
|
+
parentType: linkedType
|
|
71637
|
+
});
|
|
71638
|
+
}
|
|
71639
|
+
}
|
|
71640
|
+
for (const operation of operations || []) {
|
|
71641
|
+
let parentID;
|
|
71642
|
+
if (operation.parentID) {
|
|
71643
|
+
if (operation.parentID.kind !== "Variable") {
|
|
71644
|
+
parentID = operation.parentID.value;
|
|
71645
|
+
} else {
|
|
71646
|
+
const id = variables[operation.parentID.value];
|
|
71647
|
+
if (typeof id !== "string") {
|
|
71648
|
+
throw new Error("parentID value must be a string");
|
|
71649
|
+
}
|
|
71650
|
+
parentID = id;
|
|
71651
|
+
}
|
|
71652
|
+
}
|
|
71653
|
+
if (operation.list && !this.lists.get(operation.list, parentID, operation.target === "all")) {
|
|
71654
|
+
continue;
|
|
71655
|
+
}
|
|
71656
|
+
const targets = Array.isArray(value) ? value : [value];
|
|
71657
|
+
for (const target of targets) {
|
|
71658
|
+
if (operation.action === "insert" && target instanceof Object && fieldSelection && operation.list) {
|
|
71659
|
+
this.cache.list(operation.list, parentID, operation.target === "all").when(operation.when).addToList(
|
|
71660
|
+
fieldSelection,
|
|
71661
|
+
target,
|
|
71662
|
+
variables,
|
|
71663
|
+
operation.position || "last"
|
|
71664
|
+
);
|
|
71665
|
+
} else if (operation.action === "remove" && target instanceof Object && fieldSelection && operation.list) {
|
|
71666
|
+
this.cache.list(operation.list, parentID, operation.target === "all").when(operation.when).remove(target, variables);
|
|
71667
|
+
} else if (operation.action === "delete" && operation.type) {
|
|
71668
|
+
if (typeof target !== "string") {
|
|
71669
|
+
throw new Error("Cannot delete a record with a non-string ID");
|
|
71670
|
+
}
|
|
71671
|
+
const targetID = this.id(operation.type, target);
|
|
71672
|
+
if (!targetID) {
|
|
71673
|
+
continue;
|
|
71674
|
+
}
|
|
71675
|
+
this.cache.delete(targetID);
|
|
71676
|
+
} else if (operation.action === "toggle" && target instanceof Object && fieldSelection && operation.list) {
|
|
71677
|
+
this.cache.list(operation.list, parentID, operation.target === "all").when(operation.when).toggleElement(
|
|
71678
|
+
fieldSelection,
|
|
71679
|
+
target,
|
|
71680
|
+
variables,
|
|
71681
|
+
operation.position || "last"
|
|
71682
|
+
);
|
|
71683
|
+
}
|
|
71684
|
+
}
|
|
71685
|
+
}
|
|
71686
|
+
}
|
|
71687
|
+
return toNotify;
|
|
71688
|
+
}
|
|
71689
|
+
getSelection({
|
|
71690
|
+
selection: selection2,
|
|
71691
|
+
parent = rootID,
|
|
71692
|
+
variables,
|
|
71693
|
+
stepsFromConnection = null
|
|
71694
|
+
}) {
|
|
71695
|
+
if (parent === null) {
|
|
71696
|
+
return { data: null, partial: false, stale: false, hasData: true };
|
|
71697
|
+
}
|
|
71698
|
+
const target = {};
|
|
71699
|
+
let hasData = false;
|
|
71700
|
+
let partial = false;
|
|
71701
|
+
let cascadeNull = false;
|
|
71702
|
+
let stale = false;
|
|
71703
|
+
const typename = this.storage.get(parent, "__typename").value;
|
|
71704
|
+
let targetSelection = getFieldsForType(selection2, typename);
|
|
71705
|
+
for (const [
|
|
71706
|
+
attributeName,
|
|
71707
|
+
{ type, keyRaw, selection: fieldSelection, nullable, list }
|
|
71708
|
+
] of Object.entries(targetSelection)) {
|
|
71709
|
+
const key = evaluateKey(keyRaw, variables);
|
|
71710
|
+
const { value } = this.storage.get(parent, key);
|
|
71711
|
+
const dt_field = this.staleManager.getFieldTime(parent, key);
|
|
71712
|
+
if (dt_field === null) {
|
|
71713
|
+
stale = true;
|
|
71714
|
+
}
|
|
71715
|
+
let nextStep = stepsFromConnection;
|
|
71716
|
+
if (nextStep !== null) {
|
|
71717
|
+
if (nextStep >= 2) {
|
|
71718
|
+
nextStep = null;
|
|
71719
|
+
} else {
|
|
71720
|
+
nextStep += 1;
|
|
71721
|
+
}
|
|
71722
|
+
}
|
|
71723
|
+
if (list?.connection) {
|
|
71724
|
+
nextStep = 0;
|
|
71725
|
+
}
|
|
71726
|
+
const embeddedCursor = key === "cursor" && stepsFromConnection === 1;
|
|
71727
|
+
if (typeof value === "undefined" && !embeddedCursor) {
|
|
71728
|
+
partial = true;
|
|
71729
|
+
}
|
|
71730
|
+
if (typeof value === "undefined" || value === null) {
|
|
71731
|
+
target[attributeName] = null;
|
|
71732
|
+
if (typeof value !== "undefined") {
|
|
71733
|
+
hasData = true;
|
|
71734
|
+
}
|
|
71735
|
+
} else if (!fieldSelection) {
|
|
71736
|
+
const fnUnmarshal = this.config?.scalars?.[type]?.unmarshal;
|
|
71737
|
+
if (fnUnmarshal) {
|
|
71738
|
+
target[attributeName] = fnUnmarshal(value);
|
|
71739
|
+
} else {
|
|
71740
|
+
target[attributeName] = value;
|
|
71741
|
+
}
|
|
71742
|
+
hasData = true;
|
|
71743
|
+
} else if (Array.isArray(value)) {
|
|
71744
|
+
const listValue = this.hydrateNestedList({
|
|
71745
|
+
fields: fieldSelection,
|
|
71746
|
+
variables,
|
|
71747
|
+
linkedList: value,
|
|
71748
|
+
stepsFromConnection: nextStep
|
|
71749
|
+
});
|
|
71750
|
+
target[attributeName] = listValue.data;
|
|
71751
|
+
if (listValue.partial) {
|
|
71752
|
+
partial = true;
|
|
71753
|
+
}
|
|
71754
|
+
if (listValue.stale) {
|
|
71755
|
+
stale = true;
|
|
71756
|
+
}
|
|
71757
|
+
if (listValue.hasData || value.length === 0) {
|
|
71758
|
+
hasData = true;
|
|
71759
|
+
}
|
|
71760
|
+
} else {
|
|
71761
|
+
const objectFields = this.getSelection({
|
|
71762
|
+
parent: value,
|
|
71763
|
+
selection: fieldSelection,
|
|
71764
|
+
variables,
|
|
71765
|
+
stepsFromConnection: nextStep
|
|
71766
|
+
});
|
|
71767
|
+
target[attributeName] = objectFields.data;
|
|
71768
|
+
if (objectFields.partial) {
|
|
71769
|
+
partial = true;
|
|
71770
|
+
}
|
|
71771
|
+
if (objectFields.stale) {
|
|
71772
|
+
stale = true;
|
|
71773
|
+
}
|
|
71774
|
+
if (objectFields.hasData) {
|
|
71775
|
+
hasData = true;
|
|
71776
|
+
}
|
|
71777
|
+
}
|
|
71778
|
+
if (target[attributeName] === null && !nullable && !embeddedCursor) {
|
|
71779
|
+
cascadeNull = true;
|
|
71780
|
+
}
|
|
71781
|
+
}
|
|
71782
|
+
return {
|
|
71783
|
+
data: cascadeNull ? null : target,
|
|
71784
|
+
partial: hasData && partial,
|
|
71785
|
+
stale: hasData && stale,
|
|
71786
|
+
hasData
|
|
71787
|
+
};
|
|
71788
|
+
}
|
|
71789
|
+
id(type, data) {
|
|
71790
|
+
const id = typeof data === "string" ? data : this.computeID(type, data);
|
|
71791
|
+
if (!id) {
|
|
71792
|
+
return null;
|
|
71793
|
+
}
|
|
71794
|
+
if (!type) {
|
|
71795
|
+
return id;
|
|
71796
|
+
}
|
|
71797
|
+
return type + ":" + id;
|
|
71798
|
+
}
|
|
71799
|
+
idFields(type) {
|
|
71800
|
+
return keyFieldsForType(this.config, type);
|
|
71801
|
+
}
|
|
71802
|
+
computeID(type, data) {
|
|
71803
|
+
return computeID(this.config, type, data);
|
|
71804
|
+
}
|
|
71805
|
+
hydrateNestedList({
|
|
71806
|
+
fields,
|
|
71807
|
+
variables,
|
|
71808
|
+
linkedList,
|
|
71809
|
+
stepsFromConnection
|
|
71810
|
+
}) {
|
|
71811
|
+
const result = [];
|
|
71812
|
+
let partialData = false;
|
|
71813
|
+
let stale = false;
|
|
71814
|
+
let hasValues = false;
|
|
71815
|
+
for (const entry of linkedList) {
|
|
71816
|
+
if (Array.isArray(entry)) {
|
|
71817
|
+
const nestedValue = this.hydrateNestedList({
|
|
71818
|
+
fields,
|
|
71819
|
+
variables,
|
|
71820
|
+
linkedList: entry,
|
|
71821
|
+
stepsFromConnection
|
|
71822
|
+
});
|
|
71823
|
+
result.push(nestedValue.data);
|
|
71824
|
+
if (nestedValue.partial) {
|
|
71825
|
+
partialData = true;
|
|
71826
|
+
}
|
|
71827
|
+
continue;
|
|
71828
|
+
}
|
|
71829
|
+
if (entry === null) {
|
|
71830
|
+
result.push(entry);
|
|
71831
|
+
continue;
|
|
71832
|
+
}
|
|
71833
|
+
const {
|
|
71834
|
+
data,
|
|
71835
|
+
partial,
|
|
71836
|
+
stale: local_stale,
|
|
71837
|
+
hasData
|
|
71838
|
+
} = this.getSelection({
|
|
71839
|
+
parent: entry,
|
|
71840
|
+
selection: fields,
|
|
71841
|
+
variables,
|
|
71842
|
+
stepsFromConnection
|
|
71843
|
+
});
|
|
71844
|
+
result.push(data);
|
|
71845
|
+
if (partial) {
|
|
71846
|
+
partialData = true;
|
|
71847
|
+
}
|
|
71848
|
+
if (local_stale) {
|
|
71849
|
+
stale = true;
|
|
71850
|
+
}
|
|
71851
|
+
if (hasData) {
|
|
71852
|
+
hasValues = true;
|
|
71853
|
+
}
|
|
71854
|
+
}
|
|
71855
|
+
return {
|
|
71856
|
+
data: result,
|
|
71857
|
+
partial: partialData,
|
|
71858
|
+
stale,
|
|
71859
|
+
hasData: hasValues
|
|
71860
|
+
};
|
|
71861
|
+
}
|
|
71862
|
+
extractNestedListIDs({
|
|
71863
|
+
value,
|
|
71864
|
+
abstract,
|
|
71865
|
+
recordID,
|
|
71866
|
+
key,
|
|
71867
|
+
linkedType,
|
|
71868
|
+
fields,
|
|
71869
|
+
variables,
|
|
71870
|
+
applyUpdates,
|
|
71871
|
+
specs,
|
|
71872
|
+
layer,
|
|
71873
|
+
forceNotify
|
|
71874
|
+
}) {
|
|
71875
|
+
const nestedIDs = [];
|
|
71876
|
+
const newIDs = [];
|
|
71877
|
+
for (const [i2, entry] of value.entries()) {
|
|
71878
|
+
if (Array.isArray(entry)) {
|
|
71879
|
+
const inner = this.extractNestedListIDs({
|
|
71880
|
+
value: entry,
|
|
71881
|
+
abstract,
|
|
71882
|
+
recordID,
|
|
71883
|
+
key,
|
|
71884
|
+
linkedType,
|
|
71885
|
+
fields,
|
|
71886
|
+
variables,
|
|
71887
|
+
applyUpdates,
|
|
71888
|
+
specs,
|
|
71889
|
+
layer,
|
|
71890
|
+
forceNotify
|
|
71891
|
+
});
|
|
71892
|
+
newIDs.push(...inner.newIDs);
|
|
71893
|
+
nestedIDs[i2] = inner.nestedIDs;
|
|
71894
|
+
continue;
|
|
71895
|
+
}
|
|
71896
|
+
if (entry === null || typeof entry === "undefined") {
|
|
71897
|
+
newIDs.push(null);
|
|
71898
|
+
nestedIDs[i2] = null;
|
|
71899
|
+
continue;
|
|
71900
|
+
}
|
|
71901
|
+
const entryObj = entry;
|
|
71902
|
+
let linkedID = `${recordID}.${key}[${this.storage.nextRank}]`;
|
|
71903
|
+
const embedded = this.idFields(linkedType)?.filter(
|
|
71904
|
+
(field) => typeof entry[field] === "undefined"
|
|
71905
|
+
).length > 0;
|
|
71906
|
+
const typename = entryObj.__typename;
|
|
71907
|
+
let innerType = linkedType;
|
|
71908
|
+
if (abstract) {
|
|
71909
|
+
if (!typename) {
|
|
71910
|
+
throw new Error("Encountered interface type without __typename in the payload");
|
|
71911
|
+
}
|
|
71912
|
+
innerType = typename;
|
|
71913
|
+
}
|
|
71914
|
+
if (!embedded) {
|
|
71915
|
+
const id = this.id(innerType, entry);
|
|
71916
|
+
if (id) {
|
|
71917
|
+
linkedID = id;
|
|
71918
|
+
} else {
|
|
71919
|
+
continue;
|
|
71920
|
+
}
|
|
71921
|
+
}
|
|
71922
|
+
this.writeSelection({
|
|
71923
|
+
root: rootID,
|
|
71924
|
+
selection: fields,
|
|
71925
|
+
parent: linkedID,
|
|
71926
|
+
data: entryObj,
|
|
71927
|
+
variables,
|
|
71928
|
+
toNotify: specs,
|
|
71929
|
+
applyUpdates,
|
|
71930
|
+
layer,
|
|
71931
|
+
forceNotify
|
|
71932
|
+
});
|
|
71933
|
+
newIDs.push(linkedID);
|
|
71934
|
+
nestedIDs[i2] = linkedID;
|
|
71935
|
+
}
|
|
71936
|
+
return { newIDs, nestedIDs };
|
|
71937
|
+
}
|
|
71938
|
+
collectGarbage() {
|
|
71939
|
+
this.lifetimes.tick();
|
|
71940
|
+
if (this.storage.layerCount === 1) {
|
|
71941
|
+
this.storage.topLayer.removeUndefinedFields();
|
|
71942
|
+
}
|
|
71943
|
+
}
|
|
71944
|
+
};
|
|
71945
|
+
var rootID = "_ROOT_";
|
|
71946
|
+
|
|
71947
|
+
// src/runtime/cache/index.ts
|
|
71948
|
+
var cache_default = new Cache();
|
|
71949
|
+
|
|
71950
|
+
// src/runtime/client/utils/documentPlugins.ts
|
|
71951
|
+
var documentPlugin = (kind, source) => {
|
|
71952
|
+
return () => {
|
|
71953
|
+
const sourceHandlers = source();
|
|
71954
|
+
const enterWrapper = (handler) => {
|
|
71955
|
+
return !handler ? void 0 : (ctx, handlers) => {
|
|
71956
|
+
if (ctx.artifact.kind !== kind) {
|
|
71957
|
+
return handlers.next(ctx);
|
|
71958
|
+
}
|
|
71959
|
+
return handler(ctx, handlers);
|
|
71960
|
+
};
|
|
71961
|
+
};
|
|
71962
|
+
const exitWrapper = (handler) => {
|
|
71963
|
+
return !handler ? void 0 : (ctx, handlers) => {
|
|
71964
|
+
if (ctx.artifact.kind !== kind) {
|
|
71965
|
+
return handlers.resolve(ctx);
|
|
71966
|
+
}
|
|
71967
|
+
return handler(ctx, handlers);
|
|
71968
|
+
};
|
|
71969
|
+
};
|
|
71970
|
+
return {
|
|
71971
|
+
start: enterWrapper(sourceHandlers.start),
|
|
71972
|
+
network: enterWrapper(sourceHandlers.network),
|
|
71973
|
+
afterNetwork: exitWrapper(sourceHandlers.afterNetwork),
|
|
71974
|
+
end: exitWrapper(sourceHandlers.end),
|
|
71975
|
+
catch: sourceHandlers.catch ? (ctx, handlers) => sourceHandlers.catch(ctx, handlers) : void 0,
|
|
71976
|
+
cleanup: (...args) => sourceHandlers.cleanup?.(...args)
|
|
71977
|
+
};
|
|
71978
|
+
};
|
|
71979
|
+
};
|
|
71980
|
+
|
|
71981
|
+
// src/runtime/client/plugins/query.ts
|
|
71982
|
+
var query = documentPlugin(ArtifactKind.Query, function() {
|
|
71983
|
+
let subscriptionSpec = null;
|
|
71984
|
+
let lastVariables = null;
|
|
71985
|
+
let artifactName = "";
|
|
71986
|
+
return {
|
|
71987
|
+
start(ctx, { next }) {
|
|
71988
|
+
ctx.variables = {
|
|
71989
|
+
...lastVariables,
|
|
71990
|
+
...ctx.variables
|
|
71991
|
+
};
|
|
71992
|
+
next(ctx);
|
|
71993
|
+
},
|
|
71994
|
+
end(ctx, { resolve: resolve2, marshalVariables, variablesChanged }) {
|
|
71995
|
+
if (variablesChanged(ctx)) {
|
|
71996
|
+
artifactName = ctx.artifact.name;
|
|
71997
|
+
if (subscriptionSpec) {
|
|
71998
|
+
cache_default.unsubscribe(subscriptionSpec, subscriptionSpec.variables?.() || {});
|
|
71999
|
+
}
|
|
72000
|
+
lastVariables = { ...marshalVariables(ctx) };
|
|
72001
|
+
subscriptionSpec = {
|
|
72002
|
+
rootType: ctx.artifact.rootType,
|
|
72003
|
+
selection: ctx.artifact.selection,
|
|
72004
|
+
variables: () => lastVariables,
|
|
72005
|
+
set: (newValue) => {
|
|
72006
|
+
resolve2(ctx, {
|
|
72007
|
+
data: newValue,
|
|
72008
|
+
errors: null,
|
|
72009
|
+
fetching: false,
|
|
72010
|
+
partial: false,
|
|
72011
|
+
stale: false,
|
|
72012
|
+
source: DataSource.Cache,
|
|
72013
|
+
variables: ctx.variables ?? {}
|
|
72014
|
+
});
|
|
72015
|
+
}
|
|
72016
|
+
};
|
|
72017
|
+
cache_default.subscribe(subscriptionSpec, lastVariables ?? {});
|
|
72018
|
+
}
|
|
72019
|
+
resolve2(ctx);
|
|
72020
|
+
},
|
|
72021
|
+
cleanup() {
|
|
72022
|
+
if (subscriptionSpec) {
|
|
72023
|
+
cache_default.unsubscribe(subscriptionSpec, subscriptionSpec.variables?.() ?? {});
|
|
72024
|
+
lastVariables = null;
|
|
72025
|
+
}
|
|
72026
|
+
}
|
|
72027
|
+
};
|
|
72028
|
+
});
|
|
72029
|
+
|
|
72030
|
+
// src/runtime/client/plugins/mutation.ts
|
|
72031
|
+
var mutation = documentPlugin(ArtifactKind.Mutation, () => {
|
|
72032
|
+
return {
|
|
72033
|
+
async start(ctx, { next, marshalVariables }) {
|
|
72034
|
+
const layer = cache_default._internal_unstable.storage.createLayer(true);
|
|
72035
|
+
const optimisticResponse = ctx.stuff.optimisticResponse;
|
|
72036
|
+
let toNotify = [];
|
|
72037
|
+
if (optimisticResponse) {
|
|
72038
|
+
toNotify = cache_default.write({
|
|
72039
|
+
selection: ctx.artifact.selection,
|
|
72040
|
+
data: await marshalSelection({
|
|
72041
|
+
selection: ctx.artifact.selection,
|
|
72042
|
+
data: optimisticResponse
|
|
72043
|
+
}),
|
|
72044
|
+
variables: marshalVariables(ctx),
|
|
72045
|
+
layer: layer.id
|
|
72046
|
+
});
|
|
72047
|
+
}
|
|
72048
|
+
ctx.cacheParams = {
|
|
72049
|
+
...ctx.cacheParams,
|
|
72050
|
+
layer,
|
|
72051
|
+
notifySubscribers: toNotify,
|
|
72052
|
+
forceNotify: true
|
|
72053
|
+
};
|
|
72054
|
+
next(ctx);
|
|
72055
|
+
},
|
|
72056
|
+
afterNetwork(ctx, { resolve: resolve2 }) {
|
|
72057
|
+
ctx.cacheParams?.layer?.clear();
|
|
72058
|
+
resolve2(ctx);
|
|
72059
|
+
},
|
|
72060
|
+
end(ctx, { resolve: resolve2, value }) {
|
|
72061
|
+
const hasErrors = value.errors && value.errors.length > 0;
|
|
72062
|
+
if (hasErrors) {
|
|
72063
|
+
ctx.cacheParams?.layer?.clear();
|
|
72064
|
+
}
|
|
72065
|
+
if (ctx.cacheParams?.layer) {
|
|
72066
|
+
cache_default._internal_unstable.storage.resolveLayer(ctx.cacheParams.layer.id);
|
|
72067
|
+
}
|
|
72068
|
+
resolve2(ctx);
|
|
72069
|
+
},
|
|
72070
|
+
catch(ctx, { error }) {
|
|
72071
|
+
if (ctx.cacheParams?.layer) {
|
|
72072
|
+
const { layer } = ctx.cacheParams;
|
|
72073
|
+
layer.clear();
|
|
72074
|
+
cache_default._internal_unstable.storage.resolveLayer(layer.id);
|
|
72075
|
+
}
|
|
72076
|
+
throw error;
|
|
72077
|
+
}
|
|
72078
|
+
};
|
|
72079
|
+
});
|
|
72080
|
+
|
|
69943
72081
|
// src/lib/types.ts
|
|
69944
|
-
var LogLevel =
|
|
69945
|
-
|
|
69946
|
-
|
|
69947
|
-
|
|
69948
|
-
|
|
69949
|
-
|
|
69950
|
-
})(LogLevel || {});
|
|
72082
|
+
var LogLevel = {
|
|
72083
|
+
Full: "full",
|
|
72084
|
+
Summary: "summary",
|
|
72085
|
+
ShortSummary: "short-summary",
|
|
72086
|
+
Quiet: "quiet"
|
|
72087
|
+
};
|
|
69951
72088
|
|
|
69952
72089
|
// src/lib/config.ts
|
|
69953
72090
|
var currentDir = global.__dirname || dirname(fileURLToPath(import.meta.url));
|
|
@@ -69998,7 +72135,7 @@ var Config = class {
|
|
|
69998
72135
|
scalars,
|
|
69999
72136
|
cacheBufferSize,
|
|
70000
72137
|
definitionsPath,
|
|
70001
|
-
defaultCachePolicy =
|
|
72138
|
+
defaultCachePolicy = CachePolicy.CacheOrNetwork,
|
|
70002
72139
|
defaultPartial = false,
|
|
70003
72140
|
defaultListPosition = "append",
|
|
70004
72141
|
defaultListTarget = null,
|
|
@@ -70020,7 +72157,7 @@ var Config = class {
|
|
|
70020
72157
|
Object.values(LogLevel)
|
|
70021
72158
|
)}`
|
|
70022
72159
|
);
|
|
70023
|
-
logLevel =
|
|
72160
|
+
logLevel = LogLevel.Summary;
|
|
70024
72161
|
}
|
|
70025
72162
|
this.schemaPath = schemaPath;
|
|
70026
72163
|
this.filepath = filepath;
|
|
@@ -70036,7 +72173,7 @@ var Config = class {
|
|
|
70036
72173
|
this.internalListPosition = defaultListPosition === "append" ? "last" : "first";
|
|
70037
72174
|
this.defaultListTarget = defaultListTarget;
|
|
70038
72175
|
this.definitionsFolder = definitionsPath;
|
|
70039
|
-
this.logLevel = (logLevel ||
|
|
72176
|
+
this.logLevel = (logLevel || LogLevel.Summary).toLowerCase();
|
|
70040
72177
|
this.defaultFragmentMasking = defaultFragmentMasking;
|
|
70041
72178
|
this.routesDir = join2(this.projectRoot, "src", "routes");
|
|
70042
72179
|
this.schemaPollInterval = watchSchema?.interval ?? 2e3;
|
|
@@ -70377,8 +72514,10 @@ var Config = class {
|
|
|
70377
72514
|
return node.name.value === "CachePolicy";
|
|
70378
72515
|
}
|
|
70379
72516
|
isInternalDirective(name) {
|
|
70380
|
-
const internalDirectives = this.#newSchemaInstance?.getDirectives().
|
|
70381
|
-
|
|
72517
|
+
const internalDirectives = this.#newSchemaInstance?.getDirectives().reduce((list, directive) => {
|
|
72518
|
+
return list.concat(directive.name);
|
|
72519
|
+
}, []) ?? [];
|
|
72520
|
+
return !defaultDirectives.includes(name) && (internalDirectives.includes(name) || this.isDeleteDirective(name));
|
|
70382
72521
|
}
|
|
70383
72522
|
isListFragment(name) {
|
|
70384
72523
|
return name.endsWith(this.insertFragmentSuffix) || name.endsWith(this.removeFragmentSuffix) || name.endsWith(this.toggleFragmentSuffix);
|
|
@@ -70485,7 +72624,13 @@ async function getConfig({
|
|
|
70485
72624
|
const plugins = pluginsNested.flat();
|
|
70486
72625
|
for (const plugin2 of plugins) {
|
|
70487
72626
|
if (plugin2.config) {
|
|
70488
|
-
|
|
72627
|
+
try {
|
|
72628
|
+
const configFactory = await import(plugin2.config);
|
|
72629
|
+
const newValue = typeof configFactory === "function" ? configFactory(configFile) : configFactory;
|
|
72630
|
+
configFile = deepMerge(configPath, configFile, newValue);
|
|
72631
|
+
} catch {
|
|
72632
|
+
console.log("could not load config file" + plugin2.config);
|
|
72633
|
+
}
|
|
70489
72634
|
}
|
|
70490
72635
|
}
|
|
70491
72636
|
_config = new Config({
|
|
@@ -70643,6 +72788,8 @@ async function loadSchemaFile(schemaPath) {
|
|
|
70643
72788
|
}
|
|
70644
72789
|
return graphql2.buildClientSchema(jsonContents);
|
|
70645
72790
|
}
|
|
72791
|
+
var emptySchema = graphql2.buildSchema("type Query { hello: String }");
|
|
72792
|
+
var defaultDirectives = emptySchema.getDirectives().map((dir) => dir.name);
|
|
70646
72793
|
|
|
70647
72794
|
// src/lib/graphql.ts
|
|
70648
72795
|
var graphql3 = __toESM(require_graphql2(), 1);
|
|
@@ -70659,7 +72806,7 @@ function getRootType(type) {
|
|
|
70659
72806
|
function hashDocument({
|
|
70660
72807
|
document
|
|
70661
72808
|
}) {
|
|
70662
|
-
const docString = typeof document === "string" ? document : document.
|
|
72809
|
+
const docString = typeof document === "string" ? document : document.originalString;
|
|
70663
72810
|
return crypto.createHash("sha256").update(docString ?? "").digest("hex");
|
|
70664
72811
|
}
|
|
70665
72812
|
function parentTypeFromAncestors(schema, filepath, ancestors) {
|
|
@@ -71206,7 +73353,13 @@ var FieldCollection = class {
|
|
|
71206
73353
|
if (fragment.selection.size === 0) {
|
|
71207
73354
|
return [];
|
|
71208
73355
|
}
|
|
71209
|
-
fragment.astNode
|
|
73356
|
+
fragment.astNode = {
|
|
73357
|
+
...fragment.astNode,
|
|
73358
|
+
selectionSet: {
|
|
73359
|
+
...fragment.astNode.selectionSet,
|
|
73360
|
+
selections: fragment.selection.toSelectionSet()
|
|
73361
|
+
}
|
|
73362
|
+
};
|
|
71210
73363
|
return [fragment.astNode];
|
|
71211
73364
|
}).concat(
|
|
71212
73365
|
Object.values(this.fields).map((field) => {
|
|
@@ -71430,7 +73583,7 @@ async function fragmentVariables(config2, documents) {
|
|
|
71430
73583
|
};
|
|
71431
73584
|
documents.push({
|
|
71432
73585
|
name: "generated::fragmentVariables",
|
|
71433
|
-
kind:
|
|
73586
|
+
kind: ArtifactKind.Fragment,
|
|
71434
73587
|
document: doc,
|
|
71435
73588
|
originalParsed: doc,
|
|
71436
73589
|
generateStore: false,
|
|
@@ -72351,7 +74504,7 @@ async function paginate(config2, documents) {
|
|
|
72351
74504
|
]
|
|
72352
74505
|
};
|
|
72353
74506
|
newDocs.push({
|
|
72354
|
-
kind:
|
|
74507
|
+
kind: ArtifactKind.Query,
|
|
72355
74508
|
filename: doc.filename,
|
|
72356
74509
|
name: refetchQueryName,
|
|
72357
74510
|
document: queryDoc,
|
|
@@ -72771,7 +74924,7 @@ async function addListFragments(config2, documents) {
|
|
|
72771
74924
|
config2.newDocuments += "\n" + generatedDoc.definitions.filter((c) => c.kind === "FragmentDefinition").map(graphql11.print).join("\n\n");
|
|
72772
74925
|
documents.push({
|
|
72773
74926
|
name: "generated::lists",
|
|
72774
|
-
kind:
|
|
74927
|
+
kind: ArtifactKind.Fragment,
|
|
72775
74928
|
generateArtifact: false,
|
|
72776
74929
|
generateStore: false,
|
|
72777
74930
|
document: generatedDoc,
|
|
@@ -73038,7 +75191,7 @@ function selection({
|
|
|
73038
75191
|
(directive) => directive.name.value === config2.paginateDirective
|
|
73039
75192
|
);
|
|
73040
75193
|
if (paginated && document.refetch && document.refetch.method === "offset") {
|
|
73041
|
-
fieldObj.updates = [
|
|
75194
|
+
fieldObj.updates = [RefetchUpdateMode.append];
|
|
73042
75195
|
}
|
|
73043
75196
|
let continueConnection = inConnection;
|
|
73044
75197
|
if ([
|
|
@@ -73048,7 +75201,7 @@ function selection({
|
|
|
73048
75201
|
"hasNextPage",
|
|
73049
75202
|
"hasPreviousPage"
|
|
73050
75203
|
].includes(attributeName) && inConnection && document.refetch) {
|
|
73051
|
-
fieldObj.updates = [
|
|
75204
|
+
fieldObj.updates = [RefetchUpdateMode.append, RefetchUpdateMode.prepend];
|
|
73052
75205
|
}
|
|
73053
75206
|
if (attributeName === "node" && inConnection) {
|
|
73054
75207
|
continueConnection = false;
|
|
@@ -73227,7 +75380,7 @@ function artifactGenerator(stats) {
|
|
|
73227
75380
|
);
|
|
73228
75381
|
let rootType = "";
|
|
73229
75382
|
let selectionSet;
|
|
73230
|
-
if (docKind !==
|
|
75383
|
+
if (docKind !== ArtifactKind.Fragment) {
|
|
73231
75384
|
const operation = operations[0];
|
|
73232
75385
|
if (operation.operation === "query") {
|
|
73233
75386
|
rootType = config2.schema.getQueryType()?.name;
|
|
@@ -73260,7 +75413,7 @@ function artifactGenerator(stats) {
|
|
|
73260
75413
|
let directive = fragments[0]?.directives?.find(
|
|
73261
75414
|
(directive2) => directive2.name.value === config2.argumentsDirective
|
|
73262
75415
|
);
|
|
73263
|
-
if (docKind ===
|
|
75416
|
+
if (docKind === ArtifactKind.Fragment && directive) {
|
|
73264
75417
|
inputs = fragmentArgumentsDefinitions(config2, doc.filename, fragments[0]);
|
|
73265
75418
|
}
|
|
73266
75419
|
const mergedSelection = flattenSelections({
|
|
@@ -73301,22 +75454,12 @@ function artifactGenerator(stats) {
|
|
|
73301
75454
|
document: doc
|
|
73302
75455
|
})
|
|
73303
75456
|
};
|
|
73304
|
-
|
|
73305
|
-
|
|
73306
|
-
|
|
73307
|
-
|
|
73308
|
-
|
|
73309
|
-
|
|
73310
|
-
const dataToAdd = plugin2.artifactData({ config: config2, document: doc }) ?? {};
|
|
73311
|
-
if (Object.keys(dataToAdd).length > 0) {
|
|
73312
|
-
result[plugin2.name] = dataToAdd;
|
|
73313
|
-
}
|
|
73314
|
-
return result;
|
|
73315
|
-
},
|
|
73316
|
-
{}
|
|
73317
|
-
);
|
|
73318
|
-
if (Object.keys(plugin_data).length > 0) {
|
|
73319
|
-
artifact.plugin_data = plugin_data;
|
|
75457
|
+
artifact.pluginData = {};
|
|
75458
|
+
for (const plugin2 of config2.plugins) {
|
|
75459
|
+
if (!plugin2.artifactData) {
|
|
75460
|
+
continue;
|
|
75461
|
+
}
|
|
75462
|
+
artifact.pluginData[plugin2.name] = plugin2.artifactData({ config: config2, document: doc }) ?? {};
|
|
73320
75463
|
}
|
|
73321
75464
|
if (inputs && inputs.length > 0) {
|
|
73322
75465
|
artifact.input = inputObject(config2, inputs);
|
|
@@ -73377,7 +75520,7 @@ function artifactGenerator(stats) {
|
|
|
73377
75520
|
return;
|
|
73378
75521
|
}
|
|
73379
75522
|
const match = existingArtifact && existingArtifact.match(/"HoudiniHash=(\w+)"/);
|
|
73380
|
-
if (match && match[1] !== hash
|
|
75523
|
+
if (match && match[1] !== artifact.hash) {
|
|
73381
75524
|
stats.changed.push(artifact.name);
|
|
73382
75525
|
}
|
|
73383
75526
|
stats.total.push(artifact.name);
|
|
@@ -73490,6 +75633,30 @@ async function generatePluginIndex({
|
|
|
73490
75633
|
]);
|
|
73491
75634
|
}
|
|
73492
75635
|
|
|
75636
|
+
// src/codegen/generators/runtime/runtimeConfig.ts
|
|
75637
|
+
async function injectConfig({
|
|
75638
|
+
config: config2,
|
|
75639
|
+
content,
|
|
75640
|
+
importStatement,
|
|
75641
|
+
exportStatement
|
|
75642
|
+
}) {
|
|
75643
|
+
const extraConfigs = config2.plugins.reduce((acc, plugin2) => {
|
|
75644
|
+
if (!plugin2.config) {
|
|
75645
|
+
return acc;
|
|
75646
|
+
}
|
|
75647
|
+
return [...acc, plugin2.config];
|
|
75648
|
+
}, []);
|
|
75649
|
+
return extraConfigs.length > 0 ? `
|
|
75650
|
+
${extraConfigs.map((plugin2, i2) => importStatement(plugin2, `plugin${i2}`))}
|
|
75651
|
+
|
|
75652
|
+
const plugins = [
|
|
75653
|
+
${extraConfigs.map((_, i2) => `plugin${i2}`).join(",\n")}
|
|
75654
|
+
]
|
|
75655
|
+
|
|
75656
|
+
${exportStatement("plugins")}
|
|
75657
|
+
` : content;
|
|
75658
|
+
}
|
|
75659
|
+
|
|
73493
75660
|
// src/codegen/generators/runtime/index.ts
|
|
73494
75661
|
async function runtimeGenerator(config2, docs) {
|
|
73495
75662
|
const importStatement = config2.module === "commonjs" ? importDefaultFrom : (where, as) => `import ${as} from '${where}'`;
|
|
@@ -73500,6 +75667,9 @@ async function runtimeGenerator(config2, docs) {
|
|
|
73500
75667
|
[path_exports.join(config2.runtimeSource, "lib", "constants.js")]: (content) => {
|
|
73501
75668
|
return content.replace("SITE_URL", siteURL);
|
|
73502
75669
|
},
|
|
75670
|
+
[path_exports.join(config2.runtimeSource, "imports", "pluginConfig.js")]: (content) => {
|
|
75671
|
+
return injectConfig({ config: config2, importStatement, exportStatement, content });
|
|
75672
|
+
},
|
|
73503
75673
|
[path_exports.join(config2.runtimeSource, "imports", "config.js")]: (content) => {
|
|
73504
75674
|
const configFilePath = path_exports.join(config2.runtimeDirectory, "imports", "config.js");
|
|
73505
75675
|
const relativePath = path_exports.relative(path_exports.dirname(configFilePath), config2.filepath);
|
|
@@ -74557,7 +76727,7 @@ function listDefinitions(config2, body, docs) {
|
|
|
74557
76727
|
function queryDefinitions(config2, body, docs, returnType) {
|
|
74558
76728
|
return AST12.tsTupleType(
|
|
74559
76729
|
docs.reduce((prev, doc) => {
|
|
74560
|
-
if (doc.kind !==
|
|
76730
|
+
if (doc.kind !== ArtifactKind.Query || !doc.generateStore) {
|
|
74561
76731
|
return prev;
|
|
74562
76732
|
}
|
|
74563
76733
|
const definition = doc.document.definitions.find(
|
|
@@ -74588,7 +76758,7 @@ function queryDefinitions(config2, body, docs, returnType) {
|
|
|
74588
76758
|
}
|
|
74589
76759
|
function fragmentListMap(config2, concreteTypes, body, docs, return_type) {
|
|
74590
76760
|
return docs.reduce((prev, doc) => {
|
|
74591
|
-
if (doc.kind !==
|
|
76761
|
+
if (doc.kind !== ArtifactKind.Fragment) {
|
|
74592
76762
|
return prev;
|
|
74593
76763
|
}
|
|
74594
76764
|
const definition = doc.document.definitions.find(
|
|
@@ -74727,13 +76897,19 @@ async function definitionsGenerator(config2) {
|
|
|
74727
76897
|
})
|
|
74728
76898
|
)
|
|
74729
76899
|
).code;
|
|
74730
|
-
const typeDefinitions2 =
|
|
74731
|
-
|
|
74732
|
-
|
|
74733
|
-
|
|
74734
|
-
|
|
74735
|
-
`
|
|
74736
|
-
|
|
76900
|
+
const typeDefinitions2 = `
|
|
76901
|
+
type ValuesOf<T> = T[keyof T]
|
|
76902
|
+
` + enums.sort((a, b) => a.name.value.localeCompare(b.name.value)).map((definition) => {
|
|
76903
|
+
const name = definition.name.value;
|
|
76904
|
+
const values = definition.values;
|
|
76905
|
+
return `
|
|
76906
|
+
export declare const ${name}: {
|
|
76907
|
+
${values?.map((value) => ` readonly ${value.name.value}: "${value.name.value}";`).join("\n")}
|
|
76908
|
+
}
|
|
76909
|
+
|
|
76910
|
+
export type ${name}$options = ValuesOf<typeof ${name}>
|
|
76911
|
+
`;
|
|
76912
|
+
}).join("");
|
|
74737
76913
|
const definitionsIndex = `
|
|
74738
76914
|
export * from './enums.js'
|
|
74739
76915
|
`;
|
|
@@ -74799,10 +76975,10 @@ var graphql22 = __toESM(require_graphql2(), 1);
|
|
|
74799
76975
|
async function graphqlExtensions(config2, documents) {
|
|
74800
76976
|
let internalSchema = `
|
|
74801
76977
|
enum CachePolicy {
|
|
74802
|
-
${
|
|
74803
|
-
${
|
|
74804
|
-
${
|
|
74805
|
-
${
|
|
76978
|
+
${CachePolicy.CacheAndNetwork}
|
|
76979
|
+
${CachePolicy.CacheOnly}
|
|
76980
|
+
${CachePolicy.CacheOrNetwork}
|
|
76981
|
+
${CachePolicy.NetworkOnly}
|
|
74806
76982
|
}
|
|
74807
76983
|
|
|
74808
76984
|
"""
|
|
@@ -75718,7 +77894,7 @@ function getAndVerifyNodeInterface(config2) {
|
|
|
75718
77894
|
var nbInvalidNodeFieldMessageDisplayed = 0;
|
|
75719
77895
|
function displayInvalidNodeFieldMessage(logLevel) {
|
|
75720
77896
|
if (nbInvalidNodeFieldMessageDisplayed === 0) {
|
|
75721
|
-
if (logLevel ===
|
|
77897
|
+
if (logLevel === LogLevel.Full) {
|
|
75722
77898
|
console.warn(invalidNodeFieldMessage);
|
|
75723
77899
|
} else {
|
|
75724
77900
|
console.warn(invalidNodeFieldMessageLight);
|
|
@@ -75886,7 +78062,7 @@ async function runPipeline2(config2, docs) {
|
|
|
75886
78062
|
}
|
|
75887
78063
|
const unchanged = artifactStats.total.length - artifactStats.changed.length - artifactStats.new.length - artifactStats.deleted.length;
|
|
75888
78064
|
const printMessage = !config2.pluginMode || unchanged !== artifactStats.total.length;
|
|
75889
|
-
if (!printMessage || config2.logLevel ===
|
|
78065
|
+
if (!printMessage || config2.logLevel === LogLevel.Quiet) {
|
|
75890
78066
|
if (error) {
|
|
75891
78067
|
throw error;
|
|
75892
78068
|
}
|
|
@@ -75900,14 +78076,14 @@ async function runPipeline2(config2, docs) {
|
|
|
75900
78076
|
}
|
|
75901
78077
|
if (artifactStats.total.length === 0) {
|
|
75902
78078
|
console.log(`\u{1F4A1} No operation found. If that's unexpected, please check your config.`);
|
|
75903
|
-
} else if (
|
|
78079
|
+
} else if (config2.logLevel == LogLevel.Summary || config2.logLevel == LogLevel.ShortSummary) {
|
|
75904
78080
|
if (unchanged > 0 && printMessage && !config2.pluginMode) {
|
|
75905
78081
|
console.log(`\u{1F4C3} Unchanged: ${unchanged}`);
|
|
75906
78082
|
}
|
|
75907
78083
|
logStyled("CREATED", artifactStats.new, config2.logLevel, config2.pluginMode);
|
|
75908
78084
|
logStyled("UPDATED", artifactStats.changed, config2.logLevel, config2.pluginMode);
|
|
75909
78085
|
logStyled("DELETED", artifactStats.deleted, config2.logLevel, config2.pluginMode);
|
|
75910
|
-
} else if (config2.logLevel ===
|
|
78086
|
+
} else if (config2.logLevel === LogLevel.Full) {
|
|
75911
78087
|
for (const artifact of artifactStats.total) {
|
|
75912
78088
|
let emoji = "\u{1F4C3}";
|
|
75913
78089
|
if (artifactStats.changed.includes(artifact)) {
|
|
@@ -76017,14 +78193,14 @@ async function processGraphQLDocument(config2, filepath, document) {
|
|
|
76017
78193
|
});
|
|
76018
78194
|
}
|
|
76019
78195
|
}
|
|
76020
|
-
let kind =
|
|
78196
|
+
let kind = ArtifactKind.Fragment;
|
|
76021
78197
|
if (operations.length === 1) {
|
|
76022
78198
|
if (operations[0].kind === "OperationDefinition" && operations[0].operation === "query") {
|
|
76023
|
-
kind =
|
|
78199
|
+
kind = ArtifactKind.Query;
|
|
76024
78200
|
} else if (operations[0].kind === "OperationDefinition" && operations[0].operation === "mutation") {
|
|
76025
|
-
kind =
|
|
78201
|
+
kind = ArtifactKind.Mutation;
|
|
76026
78202
|
} else if (operations[0].kind === "OperationDefinition" && operations[0].operation === "subscription") {
|
|
76027
|
-
kind =
|
|
78203
|
+
kind = ArtifactKind.Subscription;
|
|
76028
78204
|
}
|
|
76029
78205
|
}
|
|
76030
78206
|
return {
|
|
@@ -76069,7 +78245,7 @@ function logStyled(kind, stat3, logLevel, plugin2) {
|
|
|
76069
78245
|
}
|
|
76070
78246
|
}
|
|
76071
78247
|
console.log(msg.join(""));
|
|
76072
|
-
if (!plugin2 && logLevel ===
|
|
78248
|
+
if (!plugin2 && logLevel === LogLevel.Summary) {
|
|
76073
78249
|
for (const artifact of stat3.slice(0, nbToDisplay)) {
|
|
76074
78250
|
console.log(` ${artifact}`);
|
|
76075
78251
|
}
|
|
@@ -76512,8 +78688,8 @@ async function updatePackageJSON(targetPath) {
|
|
|
76512
78688
|
}
|
|
76513
78689
|
packageJSON.devDependencies = {
|
|
76514
78690
|
...packageJSON.devDependencies,
|
|
76515
|
-
houdini: "^1.0.0
|
|
76516
|
-
"houdini-svelte": "^1.0.0
|
|
78691
|
+
houdini: "^1.0.0",
|
|
78692
|
+
"houdini-svelte": "^1.0.0"
|
|
76517
78693
|
};
|
|
76518
78694
|
await fs_exports.writeFile(packagePath, JSON.stringify(packageJSON, null, 4));
|
|
76519
78695
|
}
|