houdini 1.5.2 → 1.5.4
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 +421 -547
- package/build/cmd-esm/index.js +271 -397
- package/build/codegen/generators/runtime/index.d.ts +2 -7
- package/build/codegen/generators/runtime/pluginRuntime.d.ts +8 -1
- package/build/codegen-cjs/index.js +389 -389
- package/build/codegen-esm/index.js +239 -239
- package/build/lib/config.d.ts +3 -1
- package/build/lib/router/conventions.d.ts +1 -1
- package/build/lib/router/manifest.d.ts +1 -1
- package/build/lib/typescript.d.ts +1 -1
- package/build/lib-cjs/index.js +668 -666
- package/build/lib-esm/index.js +668 -666
- package/build/test-cjs/index.js +401 -401
- package/build/test-esm/index.js +251 -251
- package/build/vite-cjs/index.js +744 -742
- package/build/vite-esm/index.js +634 -632
- package/package.json +1 -1
package/build/test-esm/index.js
CHANGED
|
@@ -52335,7 +52335,7 @@ async function runPipeline(config, pipeline, target) {
|
|
|
52335
52335
|
|
|
52336
52336
|
// src/lib/config.ts
|
|
52337
52337
|
var import_minimatch8 = __toESM(require_minimatch(), 1);
|
|
52338
|
-
import * as
|
|
52338
|
+
import * as graphql5 from "graphql";
|
|
52339
52339
|
import { fileURLToPath as fileURLToPath3, pathToFileURL } from "node:url";
|
|
52340
52340
|
|
|
52341
52341
|
// src/runtime/imports/config.ts
|
|
@@ -58242,10 +58242,219 @@ import * as graphql from "graphql";
|
|
|
58242
58242
|
|
|
58243
58243
|
// src/lib/router/manifest.ts
|
|
58244
58244
|
var t = __toESM(require_lib5(), 1);
|
|
58245
|
+
import * as graphql3 from "graphql";
|
|
58246
|
+
|
|
58247
|
+
// src/lib/graphql.ts
|
|
58245
58248
|
import * as graphql2 from "graphql";
|
|
58249
|
+
import crypto2 from "node:crypto";
|
|
58250
|
+
function getRootType(type) {
|
|
58251
|
+
if (graphql2.isNonNullType(type)) {
|
|
58252
|
+
return getRootType(type.ofType);
|
|
58253
|
+
}
|
|
58254
|
+
if (graphql2.isListType(type)) {
|
|
58255
|
+
return getRootType(type.ofType);
|
|
58256
|
+
}
|
|
58257
|
+
return type;
|
|
58258
|
+
}
|
|
58259
|
+
function hashOriginal({ document }) {
|
|
58260
|
+
return hashDocument(document.originalString);
|
|
58261
|
+
}
|
|
58262
|
+
function hashRaw({ document }) {
|
|
58263
|
+
return hashDocument(document.artifact?.raw);
|
|
58264
|
+
}
|
|
58265
|
+
function hashDocument(str) {
|
|
58266
|
+
return crypto2.createHash("sha256").update(str || "").digest("hex");
|
|
58267
|
+
}
|
|
58268
|
+
function parentField(ancestors) {
|
|
58269
|
+
return walkParentField([...ancestors].sort(() => -1));
|
|
58270
|
+
}
|
|
58271
|
+
function walkParentField(ancestors) {
|
|
58272
|
+
let head = ancestors.shift();
|
|
58273
|
+
if (Array.isArray(head) || head.kind === "SelectionSet") {
|
|
58274
|
+
return walkParentField(ancestors);
|
|
58275
|
+
}
|
|
58276
|
+
return head;
|
|
58277
|
+
}
|
|
58278
|
+
function parentTypeFromAncestors(schema, filepath, ancestors) {
|
|
58279
|
+
const parents = [...ancestors];
|
|
58280
|
+
parents.reverse();
|
|
58281
|
+
return walkAncestors(schema, filepath, parents);
|
|
58282
|
+
}
|
|
58283
|
+
function walkAncestors(schema, filepath, ancestors) {
|
|
58284
|
+
let head = ancestors.shift();
|
|
58285
|
+
if (Array.isArray(head)) {
|
|
58286
|
+
return walkAncestors(schema, filepath, ancestors);
|
|
58287
|
+
}
|
|
58288
|
+
if (!head) {
|
|
58289
|
+
throw new HoudiniError({ filepath, message: "Could not figure out type of field" });
|
|
58290
|
+
}
|
|
58291
|
+
if (head.kind === "OperationDefinition") {
|
|
58292
|
+
const operationType = {
|
|
58293
|
+
query: schema.getQueryType(),
|
|
58294
|
+
mutation: schema.getMutationType(),
|
|
58295
|
+
subscription: schema.getSubscriptionType()
|
|
58296
|
+
}[head.operation];
|
|
58297
|
+
if (!operationType) {
|
|
58298
|
+
throw new HoudiniError({ filepath, message: "Could not find operation type" });
|
|
58299
|
+
}
|
|
58300
|
+
return operationType;
|
|
58301
|
+
}
|
|
58302
|
+
if (head.kind === "FragmentDefinition") {
|
|
58303
|
+
const result = schema.getType(head.typeCondition.name.value);
|
|
58304
|
+
if (!result) {
|
|
58305
|
+
throw new HoudiniError({
|
|
58306
|
+
filepath,
|
|
58307
|
+
message: `Could not find definition for ${head.typeCondition.name.value} in the schema`
|
|
58308
|
+
});
|
|
58309
|
+
}
|
|
58310
|
+
return result;
|
|
58311
|
+
}
|
|
58312
|
+
if (head.kind === "FragmentSpread") {
|
|
58313
|
+
throw new Error("How the hell did this happen?");
|
|
58314
|
+
}
|
|
58315
|
+
const parent2 = walkAncestors(schema, filepath, ancestors);
|
|
58316
|
+
if (head.kind === "InlineFragment") {
|
|
58317
|
+
if (!head.typeCondition) {
|
|
58318
|
+
return parent2;
|
|
58319
|
+
}
|
|
58320
|
+
const wrapper = schema.getType(head.typeCondition.name.value);
|
|
58321
|
+
if (!wrapper) {
|
|
58322
|
+
throw new HoudiniError({
|
|
58323
|
+
filepath,
|
|
58324
|
+
message: "Could not find type with name: " + head.typeCondition.name.value
|
|
58325
|
+
});
|
|
58326
|
+
}
|
|
58327
|
+
return wrapper;
|
|
58328
|
+
}
|
|
58329
|
+
if (head.kind === "SelectionSet") {
|
|
58330
|
+
return parent2;
|
|
58331
|
+
}
|
|
58332
|
+
const field = parent2.getFields()[head.name.value];
|
|
58333
|
+
if (!field) {
|
|
58334
|
+
throw new HoudiniError({
|
|
58335
|
+
filepath,
|
|
58336
|
+
message: `Could not find definition of ${head.name.value} in ${parent2.toString()}`
|
|
58337
|
+
});
|
|
58338
|
+
}
|
|
58339
|
+
return getRootType(field.type);
|
|
58340
|
+
}
|
|
58341
|
+
function definitionFromAncestors(ancestors) {
|
|
58342
|
+
let parents = [...ancestors];
|
|
58343
|
+
parents.shift();
|
|
58344
|
+
let definition = parents.shift();
|
|
58345
|
+
while (Array.isArray(definition) && definition) {
|
|
58346
|
+
definition = parents.shift();
|
|
58347
|
+
}
|
|
58348
|
+
return { parents, definition };
|
|
58349
|
+
}
|
|
58350
|
+
function unwrapType(config, type, wrappers = [], convertRuntimeScalars) {
|
|
58351
|
+
if (type.kind === "NonNullType") {
|
|
58352
|
+
return unwrapType(config, type.type, [TypeWrapper.NonNull, ...wrappers]);
|
|
58353
|
+
}
|
|
58354
|
+
if (type instanceof graphql2.GraphQLNonNull) {
|
|
58355
|
+
return unwrapType(config, type.ofType, [TypeWrapper.NonNull, ...wrappers]);
|
|
58356
|
+
}
|
|
58357
|
+
if (wrappers[0] !== TypeWrapper.NonNull) {
|
|
58358
|
+
wrappers.unshift(TypeWrapper.Nullable);
|
|
58359
|
+
}
|
|
58360
|
+
if (type.kind === "ListType") {
|
|
58361
|
+
return unwrapType(config, type.type, [TypeWrapper.List, ...wrappers]);
|
|
58362
|
+
}
|
|
58363
|
+
if (type instanceof graphql2.GraphQLList) {
|
|
58364
|
+
return unwrapType(config, type.ofType, [TypeWrapper.List, ...wrappers]);
|
|
58365
|
+
}
|
|
58366
|
+
if (convertRuntimeScalars && config.configFile.features?.runtimeScalars?.[type.name.value]) {
|
|
58367
|
+
type = config.schema.getType(
|
|
58368
|
+
config.configFile.features?.runtimeScalars?.[type.name.value].type
|
|
58369
|
+
);
|
|
58370
|
+
}
|
|
58371
|
+
const namedType = config.schema.getType(type.name.value || type.name);
|
|
58372
|
+
if (!namedType) {
|
|
58373
|
+
throw new Error("Unknown type: " + type.name.value || type.name);
|
|
58374
|
+
}
|
|
58375
|
+
return { type: namedType, wrappers };
|
|
58376
|
+
}
|
|
58377
|
+
function wrapType({
|
|
58378
|
+
type,
|
|
58379
|
+
wrappers
|
|
58380
|
+
}) {
|
|
58381
|
+
const head = wrappers[0];
|
|
58382
|
+
const tail = wrappers.slice(1);
|
|
58383
|
+
let kind = graphql2.Kind.NAMED_TYPE;
|
|
58384
|
+
if (head === TypeWrapper.List) {
|
|
58385
|
+
kind = graphql2.Kind.LIST_TYPE;
|
|
58386
|
+
} else if (head === TypeWrapper.NonNull) {
|
|
58387
|
+
kind = graphql2.Kind.NON_NULL_TYPE;
|
|
58388
|
+
}
|
|
58389
|
+
if (kind === "NamedType") {
|
|
58390
|
+
return {
|
|
58391
|
+
kind,
|
|
58392
|
+
name: {
|
|
58393
|
+
kind: graphql2.Kind.NAME,
|
|
58394
|
+
value: type.name
|
|
58395
|
+
}
|
|
58396
|
+
};
|
|
58397
|
+
}
|
|
58398
|
+
return {
|
|
58399
|
+
kind,
|
|
58400
|
+
type: wrapType({ type, wrappers: tail })
|
|
58401
|
+
};
|
|
58402
|
+
}
|
|
58403
|
+
var TypeWrapper = /* @__PURE__ */ ((TypeWrapper2) => {
|
|
58404
|
+
TypeWrapper2["Nullable"] = "Nullable";
|
|
58405
|
+
TypeWrapper2["List"] = "List";
|
|
58406
|
+
TypeWrapper2["NonNull"] = "NonNull";
|
|
58407
|
+
return TypeWrapper2;
|
|
58408
|
+
})(TypeWrapper || {});
|
|
58409
|
+
|
|
58410
|
+
// src/lib/parse.ts
|
|
58411
|
+
var import_parser = __toESM(require_lib6(), 1);
|
|
58412
|
+
var import_recast = __toESM(require_main2(), 1);
|
|
58413
|
+
|
|
58414
|
+
// src/lib/deepMerge.ts
|
|
58415
|
+
var import_deepmerge = __toESM(require_cjs(), 1);
|
|
58416
|
+
function deepMerge2(filepath, ...targets) {
|
|
58417
|
+
try {
|
|
58418
|
+
if (targets.length === 1) {
|
|
58419
|
+
return targets[0];
|
|
58420
|
+
} else if (targets.length === 2) {
|
|
58421
|
+
return (0, import_deepmerge.default)(targets[0], targets[1], {
|
|
58422
|
+
arrayMerge: (source, update) => [...new Set(source.concat(update))]
|
|
58423
|
+
});
|
|
58424
|
+
}
|
|
58425
|
+
return deepMerge2(filepath, targets[0], deepMerge2(filepath, ...targets.slice(1)));
|
|
58426
|
+
} catch (e) {
|
|
58427
|
+
throw new HoudiniError({
|
|
58428
|
+
filepath,
|
|
58429
|
+
message: "could not merge: " + JSON.stringify(targets, null, 4),
|
|
58430
|
+
description: e.message
|
|
58431
|
+
});
|
|
58432
|
+
}
|
|
58433
|
+
}
|
|
58434
|
+
|
|
58435
|
+
// src/lib/parse.ts
|
|
58436
|
+
function parseJS(str, config) {
|
|
58437
|
+
const defaultConfig = {
|
|
58438
|
+
plugins: [
|
|
58439
|
+
"typescript",
|
|
58440
|
+
"importAssertions",
|
|
58441
|
+
"decorators-legacy",
|
|
58442
|
+
"explicitResourceManagement"
|
|
58443
|
+
],
|
|
58444
|
+
sourceType: "module"
|
|
58445
|
+
};
|
|
58446
|
+
return (0, import_parser.parse)(str || "", config ? deepMerge2("", defaultConfig, config) : defaultConfig).program;
|
|
58447
|
+
}
|
|
58448
|
+
async function printJS(script, options) {
|
|
58449
|
+
if (options?.pretty) {
|
|
58450
|
+
return (0, import_recast.prettyPrint)(script, options);
|
|
58451
|
+
} else {
|
|
58452
|
+
return (0, import_recast.print)(script, options);
|
|
58453
|
+
}
|
|
58454
|
+
}
|
|
58246
58455
|
|
|
58247
58456
|
// src/lib/router/server.ts
|
|
58248
|
-
import * as
|
|
58457
|
+
import * as graphql4 from "graphql";
|
|
58249
58458
|
|
|
58250
58459
|
// src/runtime/lib/flatten.ts
|
|
58251
58460
|
function flatten(source) {
|
|
@@ -60657,7 +60866,7 @@ var Config = class {
|
|
|
60657
60866
|
persistedQueriesPath
|
|
60658
60867
|
} = this.configFile;
|
|
60659
60868
|
if (typeof schema === "string") {
|
|
60660
|
-
this.schema =
|
|
60869
|
+
this.schema = graphql5.buildSchema(schema);
|
|
60661
60870
|
} else {
|
|
60662
60871
|
this.schema = schema;
|
|
60663
60872
|
}
|
|
@@ -60805,7 +61014,7 @@ var Config = class {
|
|
|
60805
61014
|
set newSchema(value) {
|
|
60806
61015
|
this.schemaString = value;
|
|
60807
61016
|
if (value) {
|
|
60808
|
-
this.#newSchemaInstance =
|
|
61017
|
+
this.#newSchemaInstance = graphql5.buildSchema(value);
|
|
60809
61018
|
} else {
|
|
60810
61019
|
this.#newSchemaInstance = null;
|
|
60811
61020
|
}
|
|
@@ -60895,21 +61104,21 @@ var Config = class {
|
|
|
60895
61104
|
}
|
|
60896
61105
|
documentName(document) {
|
|
60897
61106
|
const operation = document.definitions.find(
|
|
60898
|
-
({ kind }) => kind ===
|
|
61107
|
+
({ kind }) => kind === graphql5.Kind.OPERATION_DEFINITION
|
|
60899
61108
|
);
|
|
60900
61109
|
if (operation) {
|
|
60901
61110
|
if (!operation.name) {
|
|
60902
|
-
throw new Error("encountered operation with no name: " +
|
|
61111
|
+
throw new Error("encountered operation with no name: " + graphql5.print(document));
|
|
60903
61112
|
}
|
|
60904
61113
|
return operation.name.value;
|
|
60905
61114
|
}
|
|
60906
61115
|
const fragmentDefinitions = document.definitions.filter(
|
|
60907
|
-
({ kind }) => kind ===
|
|
61116
|
+
({ kind }) => kind === graphql5.Kind.FRAGMENT_DEFINITION
|
|
60908
61117
|
);
|
|
60909
61118
|
if (fragmentDefinitions.length) {
|
|
60910
61119
|
return fragmentDefinitions[0].name.value;
|
|
60911
61120
|
}
|
|
60912
|
-
throw new Error("Could not generate artifact name for document: " +
|
|
61121
|
+
throw new Error("Could not generate artifact name for document: " + graphql5.print(document));
|
|
60913
61122
|
}
|
|
60914
61123
|
isSelectionScalar(type) {
|
|
60915
61124
|
return ["String", "Boolean", "Float", "ID", "Int"].concat(Object.keys(this.scalars || {})).includes(type);
|
|
@@ -60929,8 +61138,8 @@ var Config = class {
|
|
|
60929
61138
|
relative(process.cwd(), filepath).replaceAll(sep2, "_").replace(".ts", ".js")
|
|
60930
61139
|
);
|
|
60931
61140
|
}
|
|
60932
|
-
excludeFile(filepath) {
|
|
60933
|
-
if (this.exclude.length > 0 && this.exclude.some((pattern) => (0, import_minimatch8.default)(filepath, pattern))) {
|
|
61141
|
+
excludeFile(filepath, { root = this.projectRoot }) {
|
|
61142
|
+
if (this.exclude.length > 0 && this.exclude.some((pattern) => (0, import_minimatch8.default)(filepath, join(root, pattern)))) {
|
|
60934
61143
|
return true;
|
|
60935
61144
|
}
|
|
60936
61145
|
for (const plugin2 of this.plugins) {
|
|
@@ -60959,7 +61168,7 @@ var Config = class {
|
|
|
60959
61168
|
if (!included && !this.include.some((pattern) => (0, import_minimatch8.default)(filepath, join(root, pattern)))) {
|
|
60960
61169
|
return false;
|
|
60961
61170
|
}
|
|
60962
|
-
return !this.excludeFile(filepath);
|
|
61171
|
+
return !this.excludeFile(filepath, { root });
|
|
60963
61172
|
}
|
|
60964
61173
|
pluginRuntimeDirectory(name) {
|
|
60965
61174
|
return join(this.pluginDirectory(name), "runtime");
|
|
@@ -61119,10 +61328,10 @@ var Config = class {
|
|
|
61119
61328
|
localDocumentData(document) {
|
|
61120
61329
|
let paginated = false;
|
|
61121
61330
|
let componentFields3 = [];
|
|
61122
|
-
const typeInfo = new
|
|
61123
|
-
|
|
61331
|
+
const typeInfo = new graphql5.TypeInfo(this.schema);
|
|
61332
|
+
graphql5.visit(
|
|
61124
61333
|
document,
|
|
61125
|
-
|
|
61334
|
+
graphql5.visitWithTypeInfo(typeInfo, {
|
|
61126
61335
|
Directive: (node) => {
|
|
61127
61336
|
if ([this.paginateDirective].includes(node.name.value)) {
|
|
61128
61337
|
paginated = true;
|
|
@@ -61259,218 +61468,9 @@ function findModule(pkg = "houdini", currentLocation) {
|
|
|
61259
61468
|
}
|
|
61260
61469
|
return locationFound;
|
|
61261
61470
|
}
|
|
61262
|
-
var emptySchema =
|
|
61471
|
+
var emptySchema = graphql5.buildSchema("type Query { hello: String }");
|
|
61263
61472
|
var defaultDirectives = emptySchema.getDirectives().map((dir) => dir.name);
|
|
61264
61473
|
|
|
61265
|
-
// src/lib/graphql.ts
|
|
61266
|
-
import * as graphql5 from "graphql";
|
|
61267
|
-
import crypto2 from "node:crypto";
|
|
61268
|
-
function getRootType(type) {
|
|
61269
|
-
if (graphql5.isNonNullType(type)) {
|
|
61270
|
-
return getRootType(type.ofType);
|
|
61271
|
-
}
|
|
61272
|
-
if (graphql5.isListType(type)) {
|
|
61273
|
-
return getRootType(type.ofType);
|
|
61274
|
-
}
|
|
61275
|
-
return type;
|
|
61276
|
-
}
|
|
61277
|
-
function hashOriginal({ document }) {
|
|
61278
|
-
return hashDocument(document.originalString);
|
|
61279
|
-
}
|
|
61280
|
-
function hashRaw({ document }) {
|
|
61281
|
-
return hashDocument(document.artifact?.raw);
|
|
61282
|
-
}
|
|
61283
|
-
function hashDocument(str) {
|
|
61284
|
-
return crypto2.createHash("sha256").update(str || "").digest("hex");
|
|
61285
|
-
}
|
|
61286
|
-
function parentField(ancestors) {
|
|
61287
|
-
return walkParentField([...ancestors].sort(() => -1));
|
|
61288
|
-
}
|
|
61289
|
-
function walkParentField(ancestors) {
|
|
61290
|
-
let head = ancestors.shift();
|
|
61291
|
-
if (Array.isArray(head) || head.kind === "SelectionSet") {
|
|
61292
|
-
return walkParentField(ancestors);
|
|
61293
|
-
}
|
|
61294
|
-
return head;
|
|
61295
|
-
}
|
|
61296
|
-
function parentTypeFromAncestors(schema, filepath, ancestors) {
|
|
61297
|
-
const parents = [...ancestors];
|
|
61298
|
-
parents.reverse();
|
|
61299
|
-
return walkAncestors(schema, filepath, parents);
|
|
61300
|
-
}
|
|
61301
|
-
function walkAncestors(schema, filepath, ancestors) {
|
|
61302
|
-
let head = ancestors.shift();
|
|
61303
|
-
if (Array.isArray(head)) {
|
|
61304
|
-
return walkAncestors(schema, filepath, ancestors);
|
|
61305
|
-
}
|
|
61306
|
-
if (!head) {
|
|
61307
|
-
throw new HoudiniError({ filepath, message: "Could not figure out type of field" });
|
|
61308
|
-
}
|
|
61309
|
-
if (head.kind === "OperationDefinition") {
|
|
61310
|
-
const operationType = {
|
|
61311
|
-
query: schema.getQueryType(),
|
|
61312
|
-
mutation: schema.getMutationType(),
|
|
61313
|
-
subscription: schema.getSubscriptionType()
|
|
61314
|
-
}[head.operation];
|
|
61315
|
-
if (!operationType) {
|
|
61316
|
-
throw new HoudiniError({ filepath, message: "Could not find operation type" });
|
|
61317
|
-
}
|
|
61318
|
-
return operationType;
|
|
61319
|
-
}
|
|
61320
|
-
if (head.kind === "FragmentDefinition") {
|
|
61321
|
-
const result = schema.getType(head.typeCondition.name.value);
|
|
61322
|
-
if (!result) {
|
|
61323
|
-
throw new HoudiniError({
|
|
61324
|
-
filepath,
|
|
61325
|
-
message: `Could not find definition for ${head.typeCondition.name.value} in the schema`
|
|
61326
|
-
});
|
|
61327
|
-
}
|
|
61328
|
-
return result;
|
|
61329
|
-
}
|
|
61330
|
-
if (head.kind === "FragmentSpread") {
|
|
61331
|
-
throw new Error("How the hell did this happen?");
|
|
61332
|
-
}
|
|
61333
|
-
const parent2 = walkAncestors(schema, filepath, ancestors);
|
|
61334
|
-
if (head.kind === "InlineFragment") {
|
|
61335
|
-
if (!head.typeCondition) {
|
|
61336
|
-
return parent2;
|
|
61337
|
-
}
|
|
61338
|
-
const wrapper = schema.getType(head.typeCondition.name.value);
|
|
61339
|
-
if (!wrapper) {
|
|
61340
|
-
throw new HoudiniError({
|
|
61341
|
-
filepath,
|
|
61342
|
-
message: "Could not find type with name: " + head.typeCondition.name.value
|
|
61343
|
-
});
|
|
61344
|
-
}
|
|
61345
|
-
return wrapper;
|
|
61346
|
-
}
|
|
61347
|
-
if (head.kind === "SelectionSet") {
|
|
61348
|
-
return parent2;
|
|
61349
|
-
}
|
|
61350
|
-
const field = parent2.getFields()[head.name.value];
|
|
61351
|
-
if (!field) {
|
|
61352
|
-
throw new HoudiniError({
|
|
61353
|
-
filepath,
|
|
61354
|
-
message: `Could not find definition of ${head.name.value} in ${parent2.toString()}`
|
|
61355
|
-
});
|
|
61356
|
-
}
|
|
61357
|
-
return getRootType(field.type);
|
|
61358
|
-
}
|
|
61359
|
-
function definitionFromAncestors(ancestors) {
|
|
61360
|
-
let parents = [...ancestors];
|
|
61361
|
-
parents.shift();
|
|
61362
|
-
let definition = parents.shift();
|
|
61363
|
-
while (Array.isArray(definition) && definition) {
|
|
61364
|
-
definition = parents.shift();
|
|
61365
|
-
}
|
|
61366
|
-
return { parents, definition };
|
|
61367
|
-
}
|
|
61368
|
-
function unwrapType(config, type, wrappers = [], convertRuntimeScalars) {
|
|
61369
|
-
if (type.kind === "NonNullType") {
|
|
61370
|
-
return unwrapType(config, type.type, [TypeWrapper.NonNull, ...wrappers]);
|
|
61371
|
-
}
|
|
61372
|
-
if (type instanceof graphql5.GraphQLNonNull) {
|
|
61373
|
-
return unwrapType(config, type.ofType, [TypeWrapper.NonNull, ...wrappers]);
|
|
61374
|
-
}
|
|
61375
|
-
if (wrappers[0] !== TypeWrapper.NonNull) {
|
|
61376
|
-
wrappers.unshift(TypeWrapper.Nullable);
|
|
61377
|
-
}
|
|
61378
|
-
if (type.kind === "ListType") {
|
|
61379
|
-
return unwrapType(config, type.type, [TypeWrapper.List, ...wrappers]);
|
|
61380
|
-
}
|
|
61381
|
-
if (type instanceof graphql5.GraphQLList) {
|
|
61382
|
-
return unwrapType(config, type.ofType, [TypeWrapper.List, ...wrappers]);
|
|
61383
|
-
}
|
|
61384
|
-
if (convertRuntimeScalars && config.configFile.features?.runtimeScalars?.[type.name.value]) {
|
|
61385
|
-
type = config.schema.getType(
|
|
61386
|
-
config.configFile.features?.runtimeScalars?.[type.name.value].type
|
|
61387
|
-
);
|
|
61388
|
-
}
|
|
61389
|
-
const namedType = config.schema.getType(type.name.value || type.name);
|
|
61390
|
-
if (!namedType) {
|
|
61391
|
-
throw new Error("Unknown type: " + type.name.value || type.name);
|
|
61392
|
-
}
|
|
61393
|
-
return { type: namedType, wrappers };
|
|
61394
|
-
}
|
|
61395
|
-
function wrapType({
|
|
61396
|
-
type,
|
|
61397
|
-
wrappers
|
|
61398
|
-
}) {
|
|
61399
|
-
const head = wrappers[0];
|
|
61400
|
-
const tail = wrappers.slice(1);
|
|
61401
|
-
let kind = graphql5.Kind.NAMED_TYPE;
|
|
61402
|
-
if (head === TypeWrapper.List) {
|
|
61403
|
-
kind = graphql5.Kind.LIST_TYPE;
|
|
61404
|
-
} else if (head === TypeWrapper.NonNull) {
|
|
61405
|
-
kind = graphql5.Kind.NON_NULL_TYPE;
|
|
61406
|
-
}
|
|
61407
|
-
if (kind === "NamedType") {
|
|
61408
|
-
return {
|
|
61409
|
-
kind,
|
|
61410
|
-
name: {
|
|
61411
|
-
kind: graphql5.Kind.NAME,
|
|
61412
|
-
value: type.name
|
|
61413
|
-
}
|
|
61414
|
-
};
|
|
61415
|
-
}
|
|
61416
|
-
return {
|
|
61417
|
-
kind,
|
|
61418
|
-
type: wrapType({ type, wrappers: tail })
|
|
61419
|
-
};
|
|
61420
|
-
}
|
|
61421
|
-
var TypeWrapper = /* @__PURE__ */ ((TypeWrapper2) => {
|
|
61422
|
-
TypeWrapper2["Nullable"] = "Nullable";
|
|
61423
|
-
TypeWrapper2["List"] = "List";
|
|
61424
|
-
TypeWrapper2["NonNull"] = "NonNull";
|
|
61425
|
-
return TypeWrapper2;
|
|
61426
|
-
})(TypeWrapper || {});
|
|
61427
|
-
|
|
61428
|
-
// src/lib/parse.ts
|
|
61429
|
-
var import_parser = __toESM(require_lib6(), 1);
|
|
61430
|
-
var import_recast = __toESM(require_main2(), 1);
|
|
61431
|
-
|
|
61432
|
-
// src/lib/deepMerge.ts
|
|
61433
|
-
var import_deepmerge = __toESM(require_cjs(), 1);
|
|
61434
|
-
function deepMerge2(filepath, ...targets) {
|
|
61435
|
-
try {
|
|
61436
|
-
if (targets.length === 1) {
|
|
61437
|
-
return targets[0];
|
|
61438
|
-
} else if (targets.length === 2) {
|
|
61439
|
-
return (0, import_deepmerge.default)(targets[0], targets[1], {
|
|
61440
|
-
arrayMerge: (source, update) => [...new Set(source.concat(update))]
|
|
61441
|
-
});
|
|
61442
|
-
}
|
|
61443
|
-
return deepMerge2(filepath, targets[0], deepMerge2(filepath, ...targets.slice(1)));
|
|
61444
|
-
} catch (e) {
|
|
61445
|
-
throw new HoudiniError({
|
|
61446
|
-
filepath,
|
|
61447
|
-
message: "could not merge: " + JSON.stringify(targets, null, 4),
|
|
61448
|
-
description: e.message
|
|
61449
|
-
});
|
|
61450
|
-
}
|
|
61451
|
-
}
|
|
61452
|
-
|
|
61453
|
-
// src/lib/parse.ts
|
|
61454
|
-
function parseJS(str, config) {
|
|
61455
|
-
const defaultConfig = {
|
|
61456
|
-
plugins: [
|
|
61457
|
-
"typescript",
|
|
61458
|
-
"importAssertions",
|
|
61459
|
-
"decorators-legacy",
|
|
61460
|
-
"explicitResourceManagement"
|
|
61461
|
-
],
|
|
61462
|
-
sourceType: "module"
|
|
61463
|
-
};
|
|
61464
|
-
return (0, import_parser.parse)(str || "", config ? deepMerge2("", defaultConfig, config) : defaultConfig).program;
|
|
61465
|
-
}
|
|
61466
|
-
async function printJS(script, options) {
|
|
61467
|
-
if (options?.pretty) {
|
|
61468
|
-
return (0, import_recast.prettyPrint)(script, options);
|
|
61469
|
-
} else {
|
|
61470
|
-
return (0, import_recast.print)(script, options);
|
|
61471
|
-
}
|
|
61472
|
-
}
|
|
61473
|
-
|
|
61474
61474
|
// src/lib/imports.ts
|
|
61475
61475
|
var recast = __toESM(require_main2(), 1);
|
|
61476
61476
|
var AST2 = recast.types.builders;
|
|
@@ -61599,18 +61599,18 @@ function scalarPropertyValue(config, filepath, missingScalars, target, body, fie
|
|
|
61599
61599
|
return AST3.tsNeverKeyword();
|
|
61600
61600
|
}
|
|
61601
61601
|
const component = config.componentFields[field.parent][field.field];
|
|
61602
|
-
const sourcePathRelative =
|
|
61603
|
-
|
|
61602
|
+
const sourcePathRelative = relative(
|
|
61603
|
+
join(config.projectRoot, "src"),
|
|
61604
61604
|
component.filepath
|
|
61605
61605
|
);
|
|
61606
|
-
let sourcePathParsed =
|
|
61607
|
-
let sourcePath =
|
|
61606
|
+
let sourcePathParsed = parse(sourcePathRelative);
|
|
61607
|
+
let sourcePath = join(sourcePathParsed.dir, sourcePathParsed.name);
|
|
61608
61608
|
const localImport = ensureImports({
|
|
61609
61609
|
config,
|
|
61610
61610
|
body,
|
|
61611
61611
|
import: "__component__" + component.fragment,
|
|
61612
|
-
sourceModule:
|
|
61613
|
-
|
|
61612
|
+
sourceModule: join(
|
|
61613
|
+
relative(dirname(filepath), config.projectRoot),
|
|
61614
61614
|
"src",
|
|
61615
61615
|
sourcePath
|
|
61616
61616
|
)
|
|
@@ -64215,6 +64215,16 @@ async function generatePluginIndex({
|
|
|
64215
64215
|
}
|
|
64216
64216
|
|
|
64217
64217
|
// src/codegen/generators/runtime/pluginRuntime.ts
|
|
64218
|
+
function moduleStatments(config) {
|
|
64219
|
+
const importStatement = config.module === "commonjs" ? importDefaultFrom : (where, as) => `import ${as} from '${where}'`;
|
|
64220
|
+
const exportDefaultStatement = config.module === "commonjs" ? exportDefault : (as) => `export default ${as}`;
|
|
64221
|
+
const exportStarStatement = config.module === "commonjs" ? exportStarFrom : (where) => `export * from '${where}'`;
|
|
64222
|
+
return {
|
|
64223
|
+
importStatement,
|
|
64224
|
+
exportDefaultStatement,
|
|
64225
|
+
exportStarStatement
|
|
64226
|
+
};
|
|
64227
|
+
}
|
|
64218
64228
|
async function generatePluginRuntimes({
|
|
64219
64229
|
config,
|
|
64220
64230
|
docs
|
|
@@ -64230,7 +64240,7 @@ async function generatePluginRuntimes({
|
|
|
64230
64240
|
return;
|
|
64231
64241
|
}
|
|
64232
64242
|
try {
|
|
64233
|
-
await
|
|
64243
|
+
await stat(runtime_path);
|
|
64234
64244
|
} catch {
|
|
64235
64245
|
throw new HoudiniError({
|
|
64236
64246
|
message: "Cannot find runtime to generate for " + plugin2.name,
|
|
@@ -64242,13 +64252,13 @@ async function generatePluginRuntimes({
|
|
|
64242
64252
|
if (transformMap && typeof transformMap === "function") {
|
|
64243
64253
|
transformMap = transformMap(docs, { config });
|
|
64244
64254
|
}
|
|
64245
|
-
await
|
|
64246
|
-
await
|
|
64255
|
+
await mkdirp(pluginDir);
|
|
64256
|
+
await recursiveCopy(
|
|
64247
64257
|
runtime_path,
|
|
64248
64258
|
pluginDir,
|
|
64249
64259
|
Object.fromEntries(
|
|
64250
64260
|
Object.entries(transformMap).map(([key, value]) => [
|
|
64251
|
-
|
|
64261
|
+
join(runtime_path, key),
|
|
64252
64262
|
(content) => value({
|
|
64253
64263
|
config,
|
|
64254
64264
|
content,
|
|
@@ -64295,21 +64305,21 @@ async function runtimeGenerator(config, docs) {
|
|
|
64295
64305
|
exportStarStatement: exportStar
|
|
64296
64306
|
} = moduleStatments(config);
|
|
64297
64307
|
await Promise.all([
|
|
64298
|
-
|
|
64299
|
-
[
|
|
64308
|
+
recursiveCopy(config.runtimeSource, config.runtimeDirectory, {
|
|
64309
|
+
[join(config.runtimeSource, "lib", "constants.js")]: (content) => {
|
|
64300
64310
|
return content.replace("SITE_URL", siteURL);
|
|
64301
64311
|
},
|
|
64302
|
-
[
|
|
64312
|
+
[join(config.runtimeSource, "imports", "pluginConfig.js")]: (content) => {
|
|
64303
64313
|
return injectConfig({ config, importStatement, exportStatement, content });
|
|
64304
64314
|
},
|
|
64305
|
-
[
|
|
64306
|
-
const configFilePath =
|
|
64307
|
-
const relativePath =
|
|
64315
|
+
[join(config.runtimeSource, "imports", "config.js")]: (content) => {
|
|
64316
|
+
const configFilePath = join(config.runtimeDirectory, "imports", "config.js");
|
|
64317
|
+
const relativePath = relative(dirname(configFilePath), config.filepath);
|
|
64308
64318
|
return `${importStatement(relativePath, "config")}
|
|
64309
64319
|
${exportStatement("config")}
|
|
64310
64320
|
`;
|
|
64311
64321
|
},
|
|
64312
|
-
[
|
|
64322
|
+
[join(config.runtimeSource, "client", "plugins", "injectedPlugins.js")]: (content) => injectPlugins({ config, content, importStatement, exportStatement })
|
|
64313
64323
|
}),
|
|
64314
64324
|
generatePluginRuntimes({
|
|
64315
64325
|
config,
|
|
@@ -64319,16 +64329,6 @@ ${exportStatement("config")}
|
|
|
64319
64329
|
]);
|
|
64320
64330
|
await generateGraphqlReturnTypes(config, docs);
|
|
64321
64331
|
}
|
|
64322
|
-
function moduleStatments(config) {
|
|
64323
|
-
const importStatement = config.module === "commonjs" ? importDefaultFrom : (where, as) => `import ${as} from '${where}'`;
|
|
64324
|
-
const exportDefaultStatement = config.module === "commonjs" ? exportDefault : (as) => `export default ${as}`;
|
|
64325
|
-
const exportStarStatement = config.module === "commonjs" ? exportStarFrom : (where) => `export * from '${where}'`;
|
|
64326
|
-
return {
|
|
64327
|
-
importStatement,
|
|
64328
|
-
exportDefaultStatement,
|
|
64329
|
-
exportStarStatement
|
|
64330
|
-
};
|
|
64331
|
-
}
|
|
64332
64332
|
|
|
64333
64333
|
// src/codegen/generators/typescript/documentTypes.ts
|
|
64334
64334
|
var recast11 = __toESM(require_main2(), 1);
|