houdini 2.0.0-next.0 → 2.0.0-next.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/build/cmd-cjs/index.js +127 -43
- package/build/cmd-esm/index.js +127 -43
- package/build/codegen/generators/runtime/pluginRuntime.d.ts +3 -0
- package/build/codegen-cjs/index.js +86 -29
- package/build/codegen-esm/index.js +86 -29
- package/build/lib/config.d.ts +3 -0
- package/build/lib/introspection.d.ts +1 -1
- package/build/lib-cjs/index.js +75 -38
- package/build/lib-esm/index.js +75 -38
- package/build/runtime/lib/config.d.ts +7 -0
- package/build/runtime-cjs/cache/cache.js +36 -29
- package/build/runtime-cjs/lib/config.d.ts +7 -0
- package/build/runtime-esm/cache/cache.js +36 -29
- package/build/runtime-esm/lib/config.d.ts +7 -0
- package/build/test-cjs/index.js +64 -32
- package/build/test-esm/index.js +64 -32
- package/build/vite-cjs/index.js +127 -39
- package/build/vite-esm/index.js +127 -39
- package/package.json +1 -1
package/build/vite-esm/index.js
CHANGED
|
@@ -72461,7 +72461,7 @@ function fixResponseChunkedTransferBadEnding(request, errorCallback) {
|
|
|
72461
72461
|
}
|
|
72462
72462
|
|
|
72463
72463
|
// src/lib/introspection.ts
|
|
72464
|
-
async function pullSchema(url, fetchTimeout, schemaPath, headers,
|
|
72464
|
+
async function pullSchema(url, fetchTimeout, schemaPath, headers, writeToDisk = true) {
|
|
72465
72465
|
let content = "";
|
|
72466
72466
|
try {
|
|
72467
72467
|
const fetchWithTimeout = (url2, timeoutMs, options) => {
|
|
@@ -72499,8 +72499,15 @@ async function pullSchema(url, fetchTimeout, schemaPath, headers, skipWriting) {
|
|
|
72499
72499
|
} else {
|
|
72500
72500
|
fileData = JSON.stringify(jsonSchema);
|
|
72501
72501
|
}
|
|
72502
|
-
if (
|
|
72503
|
-
|
|
72502
|
+
if (writeToDisk) {
|
|
72503
|
+
try {
|
|
72504
|
+
await writeFile(schemaPath, fileData);
|
|
72505
|
+
} catch (e2) {
|
|
72506
|
+
console.warn(
|
|
72507
|
+
`\u26A0\uFE0F Couldn't write your pulled schema to disk: ${e2.message}
|
|
72508
|
+
If this is expected, please set watchSchema.writePolledSchema to false in your config file.`
|
|
72509
|
+
);
|
|
72510
|
+
}
|
|
72504
72511
|
}
|
|
72505
72512
|
return fileData;
|
|
72506
72513
|
} catch (e2) {
|
|
@@ -74983,20 +74990,21 @@ var CacheInternal = class {
|
|
|
74983
74990
|
} else if (Array.isArray(value) && // make typescript happy
|
|
74984
74991
|
(typeof previousValue === "undefined" || previousValue === null || Array.isArray(previousValue))) {
|
|
74985
74992
|
let oldIDs = [...previousValue || []];
|
|
74986
|
-
|
|
74987
|
-
|
|
74988
|
-
|
|
74989
|
-
|
|
74990
|
-
|
|
74991
|
-
|
|
74992
|
-
|
|
74993
|
-
|
|
74994
|
-
|
|
74995
|
-
|
|
74996
|
-
|
|
74997
|
-
|
|
74998
|
-
|
|
74999
|
-
|
|
74993
|
+
if (updates?.includes("append") || updates?.includes("prepend")) {
|
|
74994
|
+
oldIDs = oldIDs.filter((id) => {
|
|
74995
|
+
for (const layer2 of this.storage.data) {
|
|
74996
|
+
for (const operation of Object.values(layer2.operations)) {
|
|
74997
|
+
if (operation.fields?.[key])
|
|
74998
|
+
for (const listOperation of operation.fields[key]) {
|
|
74999
|
+
if ("id" in listOperation && listOperation.id === id) {
|
|
75000
|
+
return false;
|
|
75001
|
+
}
|
|
75002
|
+
}
|
|
75003
|
+
}
|
|
75004
|
+
}
|
|
75005
|
+
return true;
|
|
75006
|
+
});
|
|
75007
|
+
}
|
|
75000
75008
|
let linkedIDs = [];
|
|
75001
75009
|
const { newIDs, nestedIDs } = this.extractNestedListIDs({
|
|
75002
75010
|
value,
|
|
@@ -75015,39 +75023,45 @@ var CacheInternal = class {
|
|
|
75015
75023
|
layer.writeLink(parent2, key, linkedIDs);
|
|
75016
75024
|
};
|
|
75017
75025
|
if (applyUpdates && updates) {
|
|
75018
|
-
|
|
75019
|
-
const
|
|
75020
|
-
for (const id of
|
|
75026
|
+
const filterIDs = (keep, insert) => {
|
|
75027
|
+
const existingIDs = /* @__PURE__ */ new Set();
|
|
75028
|
+
for (const id of keep) {
|
|
75021
75029
|
if (!id) {
|
|
75022
75030
|
continue;
|
|
75023
75031
|
}
|
|
75024
75032
|
const { value: node } = this.storage.get(id, "node");
|
|
75025
|
-
if (
|
|
75033
|
+
if (!node) {
|
|
75026
75034
|
continue;
|
|
75027
75035
|
}
|
|
75028
|
-
|
|
75036
|
+
const nodeID = this.storage.get(node, "id");
|
|
75037
|
+
if (!nodeID) {
|
|
75029
75038
|
continue;
|
|
75030
75039
|
}
|
|
75031
|
-
|
|
75040
|
+
existingIDs.add(nodeID.value);
|
|
75032
75041
|
}
|
|
75033
|
-
|
|
75042
|
+
return insert.filter((id) => {
|
|
75034
75043
|
if (!id) {
|
|
75035
75044
|
return true;
|
|
75036
75045
|
}
|
|
75037
|
-
const { value:
|
|
75038
|
-
|
|
75039
|
-
|
|
75040
|
-
return false;
|
|
75046
|
+
const { value: node } = this.storage.get(id, "node");
|
|
75047
|
+
if (!node) {
|
|
75048
|
+
return true;
|
|
75041
75049
|
}
|
|
75042
|
-
|
|
75050
|
+
const nodeID = this.storage.get(node, "id");
|
|
75051
|
+
if (!nodeID) {
|
|
75052
|
+
return true;
|
|
75053
|
+
}
|
|
75054
|
+
return !existingIDs.has(nodeID.value);
|
|
75043
75055
|
});
|
|
75044
|
-
}
|
|
75056
|
+
};
|
|
75045
75057
|
for (const update of applyUpdates) {
|
|
75046
75058
|
if (update !== "replace" && !updates.includes(update)) {
|
|
75047
75059
|
continue;
|
|
75048
75060
|
}
|
|
75049
75061
|
if (update === "prepend") {
|
|
75050
|
-
linkedIDs = newIDs.concat(
|
|
75062
|
+
linkedIDs = newIDs.concat(
|
|
75063
|
+
filterIDs(newIDs, oldIDs)
|
|
75064
|
+
);
|
|
75051
75065
|
if (layer?.optimistic) {
|
|
75052
75066
|
action = () => {
|
|
75053
75067
|
for (const id of newIDs) {
|
|
@@ -75058,7 +75072,7 @@ var CacheInternal = class {
|
|
|
75058
75072
|
};
|
|
75059
75073
|
}
|
|
75060
75074
|
} else if (update === "append") {
|
|
75061
|
-
linkedIDs = oldIDs.concat(newIDs);
|
|
75075
|
+
linkedIDs = filterIDs(newIDs, oldIDs).concat(newIDs);
|
|
75062
75076
|
if (layer?.optimistic) {
|
|
75063
75077
|
action = () => {
|
|
75064
75078
|
for (const id of newIDs) {
|
|
@@ -75726,6 +75740,7 @@ var Config = class {
|
|
|
75726
75740
|
routesDir;
|
|
75727
75741
|
schemaPollInterval;
|
|
75728
75742
|
schemaPollTimeout;
|
|
75743
|
+
schemaPollWriteToDisk = false;
|
|
75729
75744
|
schemaPollHeaders;
|
|
75730
75745
|
pluginMode = false;
|
|
75731
75746
|
plugins = [];
|
|
@@ -75802,6 +75817,7 @@ var Config = class {
|
|
|
75802
75817
|
this.routesDir = join2(this.projectRoot, "src", "routes");
|
|
75803
75818
|
this.schemaPollInterval = watchSchema?.interval === void 0 ? 2e3 : watchSchema.interval;
|
|
75804
75819
|
this.schemaPollTimeout = watchSchema?.timeout ?? 3e4;
|
|
75820
|
+
this.schemaPollWriteToDisk = watchSchema?.writePolledSchema ?? true;
|
|
75805
75821
|
this.schemaPollHeaders = watchSchema?.headers ?? {};
|
|
75806
75822
|
this.rootDir = join2(this.projectRoot, this.runtimeDir);
|
|
75807
75823
|
this.persistedQueriesPath = persistedQueriesPath ?? join2(this.rootDir, "persisted_queries.json");
|
|
@@ -75834,11 +75850,17 @@ var Config = class {
|
|
|
75834
75850
|
const include = [`src/**/*{${extensions.join(",")}}`];
|
|
75835
75851
|
for (const plugin2 of this.plugins) {
|
|
75836
75852
|
const runtimeDir = this.pluginRuntimeSource(plugin2);
|
|
75837
|
-
|
|
75853
|
+
const staticDir = this.pluginStaticRuntimeSource(plugin2);
|
|
75854
|
+
if (!runtimeDir && !staticDir) {
|
|
75838
75855
|
continue;
|
|
75839
75856
|
}
|
|
75840
|
-
const
|
|
75841
|
-
|
|
75857
|
+
for (const dir of [runtimeDir, staticDir]) {
|
|
75858
|
+
if (!dir) {
|
|
75859
|
+
continue;
|
|
75860
|
+
}
|
|
75861
|
+
const includePath = relative(this.projectRoot, dir);
|
|
75862
|
+
include.push(`${includePath}/**/*{${extensions.join(",")}}`);
|
|
75863
|
+
}
|
|
75842
75864
|
}
|
|
75843
75865
|
return include;
|
|
75844
75866
|
}
|
|
@@ -75892,6 +75914,15 @@ var Config = class {
|
|
|
75892
75914
|
typeof plugin2.includeRuntime === "string" ? plugin2.includeRuntime : plugin2.includeRuntime?.[this.module]
|
|
75893
75915
|
);
|
|
75894
75916
|
}
|
|
75917
|
+
pluginStaticRuntimeSource(plugin2) {
|
|
75918
|
+
if (!plugin2.staticRuntime) {
|
|
75919
|
+
return null;
|
|
75920
|
+
}
|
|
75921
|
+
return join2(
|
|
75922
|
+
dirname(plugin2.filepath),
|
|
75923
|
+
typeof plugin2.staticRuntime === "string" ? plugin2.staticRuntime : plugin2.staticRuntime?.[this.module]
|
|
75924
|
+
);
|
|
75925
|
+
}
|
|
75895
75926
|
async sourceFiles() {
|
|
75896
75927
|
return [
|
|
75897
75928
|
...new Set(
|
|
@@ -76088,6 +76119,9 @@ var Config = class {
|
|
|
76088
76119
|
pluginRuntimeDirectory(name) {
|
|
76089
76120
|
return join2(this.pluginDirectory(name), "runtime");
|
|
76090
76121
|
}
|
|
76122
|
+
pluginStaticRuntimeDirectory(name) {
|
|
76123
|
+
return join2(this.pluginDirectory(name), "static");
|
|
76124
|
+
}
|
|
76091
76125
|
get pluginRootDirectory() {
|
|
76092
76126
|
return houdini_mode.is_testing ? "../../../" : join2(this.rootDir, "plugins");
|
|
76093
76127
|
}
|
|
@@ -76465,17 +76499,20 @@ async function getConfig({
|
|
|
76465
76499
|
if (!_config.localSchema && _config.schemaPath && !_config.schema) {
|
|
76466
76500
|
let schemaOk = true;
|
|
76467
76501
|
if (apiURL) {
|
|
76468
|
-
if (glob2.hasMagic(_config.schemaPath)) {
|
|
76502
|
+
if (glob2.hasMagic(_config.schemaPath) && _config.schemaPollWriteToDisk) {
|
|
76469
76503
|
console.log(
|
|
76470
76504
|
`\u26A0\uFE0F Your houdini configuration contains an apiUrl and a path pointing to multiple files.
|
|
76471
|
-
This will prevent your schema from being
|
|
76505
|
+
This will prevent your schema from being written to disk. If this is expected, please set the writePolledSchema value to false.`
|
|
76472
76506
|
);
|
|
76507
|
+
_config.schemaPollWriteToDisk = false;
|
|
76473
76508
|
} else if (!await readFile(_config.schemaPath)) {
|
|
76474
76509
|
console.log("\u231B Pulling schema from api");
|
|
76475
76510
|
schemaOk = await pullSchema(
|
|
76476
76511
|
apiURL,
|
|
76477
76512
|
_config.schemaPollTimeout,
|
|
76478
|
-
_config.schemaPath
|
|
76513
|
+
_config.schemaPath,
|
|
76514
|
+
{},
|
|
76515
|
+
_config.schemaPollWriteToDisk
|
|
76479
76516
|
) !== null;
|
|
76480
76517
|
}
|
|
76481
76518
|
}
|
|
@@ -79809,6 +79846,50 @@ function moduleStatments(config2) {
|
|
|
79809
79846
|
exportStarStatement
|
|
79810
79847
|
};
|
|
79811
79848
|
}
|
|
79849
|
+
async function generateStaticRuntimes({ config: config2 }) {
|
|
79850
|
+
if (houdini_mode.is_testing) {
|
|
79851
|
+
return;
|
|
79852
|
+
}
|
|
79853
|
+
const { importStatement, exportDefaultStatement, exportStarStatement } = moduleStatments(config2);
|
|
79854
|
+
await Promise.all(
|
|
79855
|
+
config2.plugins.filter((plugin2) => plugin2.staticRuntime).map(async (plugin2) => {
|
|
79856
|
+
const runtime_path = config2.pluginStaticRuntimeSource(plugin2);
|
|
79857
|
+
if (!runtime_path) {
|
|
79858
|
+
return;
|
|
79859
|
+
}
|
|
79860
|
+
try {
|
|
79861
|
+
await stat(runtime_path);
|
|
79862
|
+
} catch {
|
|
79863
|
+
throw new HoudiniError({
|
|
79864
|
+
message: "Cannot find runtime to generate for " + plugin2.name,
|
|
79865
|
+
description: "Maybe it was bundled?"
|
|
79866
|
+
});
|
|
79867
|
+
}
|
|
79868
|
+
const pluginDir = config2.pluginStaticRuntimeDirectory(plugin2.name);
|
|
79869
|
+
let transformMap = plugin2.transformRuntime ?? {};
|
|
79870
|
+
if (transformMap && typeof transformMap === "function") {
|
|
79871
|
+
transformMap = transformMap([], { config: config2 });
|
|
79872
|
+
}
|
|
79873
|
+
await mkdirp(pluginDir);
|
|
79874
|
+
await recursiveCopy(
|
|
79875
|
+
runtime_path,
|
|
79876
|
+
pluginDir,
|
|
79877
|
+
Object.fromEntries(
|
|
79878
|
+
Object.entries(transformMap).map(([key, value]) => [
|
|
79879
|
+
join2(runtime_path, key),
|
|
79880
|
+
(content) => value({
|
|
79881
|
+
config: config2,
|
|
79882
|
+
content,
|
|
79883
|
+
importStatement,
|
|
79884
|
+
exportDefaultStatement,
|
|
79885
|
+
exportStarStatement
|
|
79886
|
+
})
|
|
79887
|
+
])
|
|
79888
|
+
)
|
|
79889
|
+
);
|
|
79890
|
+
})
|
|
79891
|
+
);
|
|
79892
|
+
}
|
|
79812
79893
|
async function generatePluginRuntimes({
|
|
79813
79894
|
config: config2,
|
|
79814
79895
|
docs
|
|
@@ -81410,6 +81491,11 @@ async function writeIndexFile2(config2, docs) {
|
|
|
81410
81491
|
module: relative2(config2.pluginRuntimeDirectory(plugin2.name))
|
|
81411
81492
|
});
|
|
81412
81493
|
}
|
|
81494
|
+
if (plugin2.staticRuntime) {
|
|
81495
|
+
body += exportStar({
|
|
81496
|
+
module: relative2(config2.pluginStaticRuntimeDirectory(plugin2.name))
|
|
81497
|
+
});
|
|
81498
|
+
}
|
|
81413
81499
|
}
|
|
81414
81500
|
await fs_exports.writeFile(path_exports.join(config2.rootDir, "index.js"), body);
|
|
81415
81501
|
}
|
|
@@ -85327,6 +85413,7 @@ async function componentFields2(config2, docs) {
|
|
|
85327
85413
|
|
|
85328
85414
|
// src/codegen/index.ts
|
|
85329
85415
|
async function compile(config2) {
|
|
85416
|
+
await generateStaticRuntimes({ config: config2 });
|
|
85330
85417
|
const documents = await collectDocuments(config2);
|
|
85331
85418
|
return await runPipeline2(config2, documents);
|
|
85332
85419
|
}
|
|
@@ -85938,7 +86025,8 @@ function watch_remote_schema(opts = {}) {
|
|
|
85938
86025
|
apiURL,
|
|
85939
86026
|
config2.schemaPollTimeout,
|
|
85940
86027
|
config2.schemaPath ?? path_exports.resolve(process.cwd(), "schema.json"),
|
|
85941
|
-
await config2.pullHeaders()
|
|
86028
|
+
await config2.pullHeaders(),
|
|
86029
|
+
config2.schemaPollWriteToDisk
|
|
85942
86030
|
);
|
|
85943
86031
|
nbPullError = schemaState ? 0 : nbPullError + 1;
|
|
85944
86032
|
} catch (e2) {
|