houdini 1.3.1 → 1.4.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/build/cmd-cjs/index.js +143 -28
- package/build/cmd-esm/index.js +143 -28
- package/build/codegen-cjs/index.js +123 -10
- package/build/codegen-esm/index.js +123 -10
- package/build/lib/config.d.ts +1 -0
- package/build/lib/router/types.d.ts +3 -1
- package/build/lib-cjs/index.js +92 -19
- package/build/lib-esm/index.js +91 -19
- package/build/runtime/cache/cache.d.ts +1 -1
- package/build/runtime/cache/lists.d.ts +3 -1
- package/build/runtime/lib/config.d.ts +10 -1
- package/build/runtime/lib/types.d.ts +14 -2
- package/build/runtime-cjs/cache/cache.d.ts +1 -1
- package/build/runtime-cjs/cache/cache.js +31 -5
- package/build/runtime-cjs/cache/lists.d.ts +3 -1
- package/build/runtime-cjs/cache/lists.js +15 -1
- package/build/runtime-cjs/client/documentStore.js +27 -7
- package/build/runtime-cjs/client/plugins/fetch.js +5 -0
- package/build/runtime-cjs/lib/config.d.ts +10 -1
- package/build/runtime-cjs/lib/types.d.ts +14 -2
- package/build/runtime-cjs/lib/types.js +7 -0
- package/build/runtime-cjs/router/match.js +1 -1
- package/build/runtime-esm/cache/cache.d.ts +1 -1
- package/build/runtime-esm/cache/cache.js +31 -5
- package/build/runtime-esm/cache/lists.d.ts +3 -1
- package/build/runtime-esm/cache/lists.js +15 -1
- package/build/runtime-esm/client/documentStore.js +28 -8
- package/build/runtime-esm/client/plugins/fetch.js +5 -0
- package/build/runtime-esm/lib/config.d.ts +10 -1
- package/build/runtime-esm/lib/types.d.ts +14 -2
- package/build/runtime-esm/lib/types.js +6 -0
- package/build/runtime-esm/router/match.js +1 -1
- package/build/test-cjs/index.js +129 -15
- package/build/test-esm/index.js +129 -15
- package/build/vite/ast.d.ts +8 -2
- package/build/vite-cjs/index.js +374 -255
- package/build/vite-esm/index.js +374 -255
- package/package.json +3 -3
package/build/cmd-cjs/index.js
CHANGED
|
@@ -63313,6 +63313,11 @@ var CachePolicy = {
|
|
|
63313
63313
|
CacheAndNetwork: "CacheAndNetwork",
|
|
63314
63314
|
NoCache: "NoCache"
|
|
63315
63315
|
};
|
|
63316
|
+
var DedupeMatchMode = {
|
|
63317
|
+
Variables: "Variables",
|
|
63318
|
+
Operation: "Operation",
|
|
63319
|
+
None: "None"
|
|
63320
|
+
};
|
|
63316
63321
|
var PaginateMode = {
|
|
63317
63322
|
Infinite: "Infinite",
|
|
63318
63323
|
SinglePage: "SinglePage"
|
|
@@ -65331,7 +65336,18 @@ var ListManager = class {
|
|
|
65331
65336
|
}
|
|
65332
65337
|
lists = /* @__PURE__ */ new Map();
|
|
65333
65338
|
listsByField = /* @__PURE__ */ new Map();
|
|
65334
|
-
get(listName, id, allLists) {
|
|
65339
|
+
get(listName, id, allLists, skipMatches) {
|
|
65340
|
+
const lists = this.getLists(listName, id, allLists);
|
|
65341
|
+
if (!lists) {
|
|
65342
|
+
return null;
|
|
65343
|
+
}
|
|
65344
|
+
if (skipMatches) {
|
|
65345
|
+
return new ListCollection(lists.lists.filter((list) => !skipMatches.has(list.fieldRef)));
|
|
65346
|
+
} else {
|
|
65347
|
+
return lists;
|
|
65348
|
+
}
|
|
65349
|
+
}
|
|
65350
|
+
getLists(listName, id, allLists) {
|
|
65335
65351
|
const matches = this.lists.get(listName);
|
|
65336
65352
|
if (!matches || matches.size === 0) {
|
|
65337
65353
|
return null;
|
|
@@ -65453,6 +65469,9 @@ var List = class {
|
|
|
65453
65469
|
this.manager = manager;
|
|
65454
65470
|
this.abstract = abstract;
|
|
65455
65471
|
}
|
|
65472
|
+
get fieldRef() {
|
|
65473
|
+
return `${this.recordID}.${this.key}`;
|
|
65474
|
+
}
|
|
65456
65475
|
when(when) {
|
|
65457
65476
|
return this.manager.lists.get(this.name).get(this.recordID).when(when);
|
|
65458
65477
|
}
|
|
@@ -66605,8 +66624,8 @@ var Cache = class {
|
|
|
66605
66624
|
variables
|
|
66606
66625
|
);
|
|
66607
66626
|
}
|
|
66608
|
-
list(name, parentID, allLists) {
|
|
66609
|
-
const handler = this._internal_unstable.lists.get(name, parentID, allLists);
|
|
66627
|
+
list(name, parentID, allLists, skipMatches) {
|
|
66628
|
+
const handler = this._internal_unstable.lists.get(name, parentID, allLists, skipMatches);
|
|
66610
66629
|
if (!handler) {
|
|
66611
66630
|
throw new Error(
|
|
66612
66631
|
`Cannot find list with name: ${name}${parentID ? " under parent " + parentID : ""}. Is it possible that the query is not mounted?`
|
|
@@ -67021,6 +67040,7 @@ var CacheInternal = class {
|
|
|
67021
67040
|
});
|
|
67022
67041
|
}
|
|
67023
67042
|
}
|
|
67043
|
+
const processedOperations = /* @__PURE__ */ new Set();
|
|
67024
67044
|
for (const operation of operations || []) {
|
|
67025
67045
|
let parentID;
|
|
67026
67046
|
if (operation.parentID) {
|
|
@@ -67040,7 +67060,12 @@ var CacheInternal = class {
|
|
|
67040
67060
|
const targets = Array.isArray(value) ? value : [value];
|
|
67041
67061
|
for (const target of targets) {
|
|
67042
67062
|
if (operation.action === "insert" && target instanceof Object && fieldSelection && operation.list) {
|
|
67043
|
-
this.cache.list(
|
|
67063
|
+
this.cache.list(
|
|
67064
|
+
operation.list,
|
|
67065
|
+
parentID,
|
|
67066
|
+
operation.target === "all",
|
|
67067
|
+
processedOperations
|
|
67068
|
+
).when(operation.when).addToList(
|
|
67044
67069
|
fieldSelection,
|
|
67045
67070
|
target,
|
|
67046
67071
|
variables,
|
|
@@ -67048,7 +67073,12 @@ var CacheInternal = class {
|
|
|
67048
67073
|
layer
|
|
67049
67074
|
);
|
|
67050
67075
|
} else if (operation.action === "toggle" && target instanceof Object && fieldSelection && operation.list) {
|
|
67051
|
-
this.cache.list(
|
|
67076
|
+
this.cache.list(
|
|
67077
|
+
operation.list,
|
|
67078
|
+
parentID,
|
|
67079
|
+
operation.target === "all",
|
|
67080
|
+
processedOperations
|
|
67081
|
+
).when(operation.when).toggleElement({
|
|
67052
67082
|
selection: fieldSelection,
|
|
67053
67083
|
data: target,
|
|
67054
67084
|
variables,
|
|
@@ -67056,7 +67086,12 @@ var CacheInternal = class {
|
|
|
67056
67086
|
layer
|
|
67057
67087
|
});
|
|
67058
67088
|
} else if (operation.action === "remove" && target instanceof Object && fieldSelection && operation.list) {
|
|
67059
|
-
this.cache.list(
|
|
67089
|
+
this.cache.list(
|
|
67090
|
+
operation.list,
|
|
67091
|
+
parentID,
|
|
67092
|
+
operation.target === "all",
|
|
67093
|
+
processedOperations
|
|
67094
|
+
).when(operation.when).remove(target, variables, layer);
|
|
67060
67095
|
} else if (operation.action === "delete" && operation.type && target) {
|
|
67061
67096
|
const targetID = this.id(operation.type, target);
|
|
67062
67097
|
if (!targetID) {
|
|
@@ -67068,6 +67103,16 @@ var CacheInternal = class {
|
|
|
67068
67103
|
this.cache.delete(targetID, layer);
|
|
67069
67104
|
}
|
|
67070
67105
|
}
|
|
67106
|
+
if (operation.list) {
|
|
67107
|
+
const matchingLists = this.cache.list(
|
|
67108
|
+
operation.list,
|
|
67109
|
+
parentID,
|
|
67110
|
+
operation.target === "all"
|
|
67111
|
+
);
|
|
67112
|
+
for (const list of matchingLists.lists) {
|
|
67113
|
+
processedOperations.add(list.fieldRef);
|
|
67114
|
+
}
|
|
67115
|
+
}
|
|
67071
67116
|
}
|
|
67072
67117
|
}
|
|
67073
67118
|
return toNotify;
|
|
@@ -67587,8 +67632,9 @@ var Config = class {
|
|
|
67587
67632
|
localSchema;
|
|
67588
67633
|
projectRoot;
|
|
67589
67634
|
schema;
|
|
67635
|
+
runtimeDir;
|
|
67590
67636
|
schemaPath;
|
|
67591
|
-
persistedQueriesPath
|
|
67637
|
+
persistedQueriesPath;
|
|
67592
67638
|
exclude;
|
|
67593
67639
|
scalars;
|
|
67594
67640
|
module = "esm";
|
|
@@ -67629,6 +67675,7 @@ var Config = class {
|
|
|
67629
67675
|
let {
|
|
67630
67676
|
schema,
|
|
67631
67677
|
schemaPath = "./schema.graphql",
|
|
67678
|
+
runtimeDir = "$houdini",
|
|
67632
67679
|
exclude = [],
|
|
67633
67680
|
module: module2 = "esm",
|
|
67634
67681
|
scalars,
|
|
@@ -67667,6 +67714,7 @@ var Config = class {
|
|
|
67667
67714
|
this.projectRoot = dirname(
|
|
67668
67715
|
projectDir ? join2(process.cwd(), projectDir) : filepath
|
|
67669
67716
|
);
|
|
67717
|
+
this.runtimeDir = runtimeDir;
|
|
67670
67718
|
this.scalars = scalars;
|
|
67671
67719
|
this.cacheBufferSize = cacheBufferSize;
|
|
67672
67720
|
this.defaultCachePolicy = defaultCachePolicy;
|
|
@@ -67681,11 +67729,9 @@ var Config = class {
|
|
|
67681
67729
|
this.schemaPollInterval = watchSchema?.interval === void 0 ? 2e3 : watchSchema.interval;
|
|
67682
67730
|
this.schemaPollTimeout = watchSchema?.timeout ?? 3e4;
|
|
67683
67731
|
this.schemaPollHeaders = watchSchema?.headers ?? {};
|
|
67684
|
-
this.rootDir = join2(this.projectRoot,
|
|
67732
|
+
this.rootDir = join2(this.projectRoot, this.runtimeDir);
|
|
67733
|
+
this.persistedQueriesPath = persistedQueriesPath ?? join2(this.rootDir, "persisted_queries.json");
|
|
67685
67734
|
this.#fragmentVariableMaps = {};
|
|
67686
|
-
if (persistedQueriesPath) {
|
|
67687
|
-
this.persistedQueriesPath = persistedQueriesPath;
|
|
67688
|
-
}
|
|
67689
67735
|
if (defaultKeys) {
|
|
67690
67736
|
this.defaultKeys = defaultKeys;
|
|
67691
67737
|
}
|
|
@@ -70662,14 +70708,27 @@ async function paginate(config, documents) {
|
|
|
70662
70708
|
return {
|
|
70663
70709
|
...node,
|
|
70664
70710
|
variableDefinitions: finalVariables,
|
|
70665
|
-
directives: [
|
|
70711
|
+
directives: config.configFile.supressPaginationDeduplication ? node.directives : [
|
|
70666
70712
|
...node.directives || [],
|
|
70667
70713
|
{
|
|
70668
70714
|
kind: graphql13.Kind.DIRECTIVE,
|
|
70669
70715
|
name: {
|
|
70670
70716
|
kind: graphql13.Kind.NAME,
|
|
70671
70717
|
value: config.dedupeDirective
|
|
70672
|
-
}
|
|
70718
|
+
},
|
|
70719
|
+
arguments: [
|
|
70720
|
+
{
|
|
70721
|
+
kind: "Argument",
|
|
70722
|
+
name: {
|
|
70723
|
+
kind: "Name",
|
|
70724
|
+
value: "match"
|
|
70725
|
+
},
|
|
70726
|
+
value: {
|
|
70727
|
+
kind: "EnumValue",
|
|
70728
|
+
value: DedupeMatchMode.Variables
|
|
70729
|
+
}
|
|
70730
|
+
}
|
|
70731
|
+
]
|
|
70673
70732
|
}
|
|
70674
70733
|
]
|
|
70675
70734
|
};
|
|
@@ -71037,6 +71096,46 @@ function objectNode([type, defaultValue]) {
|
|
|
71037
71096
|
return node;
|
|
71038
71097
|
}
|
|
71039
71098
|
var pageInfoSelection = [
|
|
71099
|
+
{
|
|
71100
|
+
kind: graphql13.Kind.FIELD,
|
|
71101
|
+
name: {
|
|
71102
|
+
kind: graphql13.Kind.NAME,
|
|
71103
|
+
value: "pageInfo"
|
|
71104
|
+
},
|
|
71105
|
+
selectionSet: {
|
|
71106
|
+
kind: graphql13.Kind.SELECTION_SET,
|
|
71107
|
+
selections: [
|
|
71108
|
+
{
|
|
71109
|
+
kind: graphql13.Kind.FIELD,
|
|
71110
|
+
name: {
|
|
71111
|
+
kind: graphql13.Kind.NAME,
|
|
71112
|
+
value: "hasPreviousPage"
|
|
71113
|
+
}
|
|
71114
|
+
},
|
|
71115
|
+
{
|
|
71116
|
+
kind: graphql13.Kind.FIELD,
|
|
71117
|
+
name: {
|
|
71118
|
+
kind: graphql13.Kind.NAME,
|
|
71119
|
+
value: "hasNextPage"
|
|
71120
|
+
}
|
|
71121
|
+
},
|
|
71122
|
+
{
|
|
71123
|
+
kind: graphql13.Kind.FIELD,
|
|
71124
|
+
name: {
|
|
71125
|
+
kind: graphql13.Kind.NAME,
|
|
71126
|
+
value: "startCursor"
|
|
71127
|
+
}
|
|
71128
|
+
},
|
|
71129
|
+
{
|
|
71130
|
+
kind: graphql13.Kind.FIELD,
|
|
71131
|
+
name: {
|
|
71132
|
+
kind: graphql13.Kind.NAME,
|
|
71133
|
+
value: "endCursor"
|
|
71134
|
+
}
|
|
71135
|
+
}
|
|
71136
|
+
]
|
|
71137
|
+
}
|
|
71138
|
+
},
|
|
71040
71139
|
{
|
|
71041
71140
|
kind: graphql13.Kind.FIELD,
|
|
71042
71141
|
name: {
|
|
@@ -72026,7 +72125,13 @@ function artifactGenerator(stats) {
|
|
|
72026
72125
|
const cancelFirstArg = dedupeDirective.arguments?.find(
|
|
72027
72126
|
(arg) => arg.name.value === "cancelFirst"
|
|
72028
72127
|
);
|
|
72029
|
-
|
|
72128
|
+
const matchArg = dedupeDirective.arguments?.find(
|
|
72129
|
+
(arg) => arg.name.value === "match"
|
|
72130
|
+
);
|
|
72131
|
+
dedupe = {
|
|
72132
|
+
cancel: cancelFirstArg && cancelFirstArg.value.kind === "BooleanValue" && cancelFirstArg.value ? "first" : "last",
|
|
72133
|
+
match: matchArg && matchArg.value.kind === "EnumValue" ? matchArg.value.value : DedupeMatchMode.Operation
|
|
72134
|
+
};
|
|
72030
72135
|
}
|
|
72031
72136
|
selectionSet = operation.selectionSet;
|
|
72032
72137
|
if (originalParsed.definitions[0].kind === "OperationDefinition") {
|
|
@@ -75693,11 +75798,20 @@ directive @${config.paginateDirective}(${config.listOrPaginateNameArg}: String,
|
|
|
75693
75798
|
"""
|
|
75694
75799
|
directive @${config.listPrependDirective} on FRAGMENT_SPREAD
|
|
75695
75800
|
|
|
75801
|
+
enum DedupeMatchMode {
|
|
75802
|
+
${DedupeMatchMode.Variables}
|
|
75803
|
+
${DedupeMatchMode.Operation}
|
|
75804
|
+
${DedupeMatchMode.None}
|
|
75805
|
+
}
|
|
75806
|
+
|
|
75696
75807
|
"""
|
|
75697
75808
|
@${config.dedupeDirective} is used to prevent an operation from running more than once at the same time.
|
|
75698
75809
|
If the cancelFirst arg is set to true, the response already in flight will be canceled instead of the second one.
|
|
75810
|
+
If match is set to Operation, then a request will be deduplicated any time there is a request with the same operation.
|
|
75811
|
+
If it's set to Variables then the request will only be deduplicated if the variables match. If match is set to None,
|
|
75812
|
+
then the request will never be deduplicated.
|
|
75699
75813
|
"""
|
|
75700
|
-
directive @${config.dedupeDirective}(cancelFirst: Boolean) on QUERY | MUTATION
|
|
75814
|
+
directive @${config.dedupeDirective}(cancelFirst: Boolean, match: DedupeMatchMode) on QUERY | MUTATION
|
|
75701
75815
|
|
|
75702
75816
|
"""
|
|
75703
75817
|
@${config.optimisticKeyDirective} is used to identify a field as an optimistic key
|
|
@@ -78247,6 +78361,7 @@ async function houdiniConfig(configPath, schemaPath, module2, frameworkInfo, url
|
|
|
78247
78361
|
url
|
|
78248
78362
|
};
|
|
78249
78363
|
}
|
|
78364
|
+
config.runtimeDir = ".houdini";
|
|
78250
78365
|
if (schemaPath !== "./schema.graphql") {
|
|
78251
78366
|
config.schemaPath = schemaPath;
|
|
78252
78367
|
}
|
|
@@ -78328,7 +78443,7 @@ const config = {
|
|
|
78328
78443
|
kit: {
|
|
78329
78444
|
adapter: adapter(),
|
|
78330
78445
|
alias: {
|
|
78331
|
-
$houdini: '
|
|
78446
|
+
$houdini: '.houdini/'
|
|
78332
78447
|
}
|
|
78333
78448
|
}
|
|
78334
78449
|
};
|
|
@@ -78342,7 +78457,7 @@ const config = {
|
|
|
78342
78457
|
kit: {
|
|
78343
78458
|
adapter: adapter(),
|
|
78344
78459
|
alias: {
|
|
78345
|
-
$houdini: '
|
|
78460
|
+
$houdini: '.houdini/'
|
|
78346
78461
|
}
|
|
78347
78462
|
}
|
|
78348
78463
|
};
|
|
@@ -78354,8 +78469,8 @@ export default config;
|
|
|
78354
78469
|
async function gitIgnore(targetPath) {
|
|
78355
78470
|
const filepath = path_exports.join(targetPath, ".gitignore");
|
|
78356
78471
|
const existing = await fs_exports.readFile(filepath) || "";
|
|
78357
|
-
if (!existing.includes("\n
|
|
78358
|
-
await fs_exports.writeFile(filepath, existing + "\n
|
|
78472
|
+
if (!existing.includes("\n.houdini\n")) {
|
|
78473
|
+
await fs_exports.writeFile(filepath, existing + "\n.houdini\n");
|
|
78359
78474
|
}
|
|
78360
78475
|
}
|
|
78361
78476
|
async function graphqlRC(targetPath) {
|
|
@@ -78364,11 +78479,11 @@ async function graphqlRC(targetPath) {
|
|
|
78364
78479
|
default:
|
|
78365
78480
|
schema:
|
|
78366
78481
|
- ./schema.graphql
|
|
78367
|
-
-
|
|
78482
|
+
- ./.houdini/graphql/schema.graphql
|
|
78368
78483
|
documents:
|
|
78369
78484
|
- '**/*.gql'
|
|
78370
78485
|
- '**/*.svelte'
|
|
78371
|
-
-
|
|
78486
|
+
- ./.houdini/graphql/documents.gql
|
|
78372
78487
|
`;
|
|
78373
78488
|
await fs_exports.writeFile(target, content);
|
|
78374
78489
|
}
|
|
@@ -78386,7 +78501,7 @@ export default defineConfig({
|
|
|
78386
78501
|
|
|
78387
78502
|
resolve: {
|
|
78388
78503
|
alias: {
|
|
78389
|
-
$houdini:
|
|
78504
|
+
$houdini: '.houdini/',
|
|
78390
78505
|
},
|
|
78391
78506
|
},
|
|
78392
78507
|
})
|
|
@@ -78423,15 +78538,15 @@ async function tjsConfig(targetPath, frameworkInfo) {
|
|
|
78423
78538
|
var tjsConfig2 = parseJSON(tjsConfigFile);
|
|
78424
78539
|
}
|
|
78425
78540
|
if (frameworkInfo.framework === "svelte") {
|
|
78426
|
-
tjsConfig2.compilerOptions.rootDirs = [".", "
|
|
78541
|
+
tjsConfig2.compilerOptions.rootDirs = [".", "./.houdini/types"];
|
|
78427
78542
|
} else if (frameworkInfo.framework === "kit") {
|
|
78428
|
-
tjsConfig2.compilerOptions.rootDirs = [".", "./.svelte-kit/types", "
|
|
78543
|
+
tjsConfig2.compilerOptions.rootDirs = [".", "./.svelte-kit/types", "./.houdini/types"];
|
|
78429
78544
|
}
|
|
78430
78545
|
if (frameworkInfo.framework === "svelte") {
|
|
78431
78546
|
tjsConfig2.compilerOptions.paths = {
|
|
78432
78547
|
...tjsConfig2.compilerOptions.paths,
|
|
78433
|
-
$houdini: ["
|
|
78434
|
-
"$houdini/*": ["
|
|
78548
|
+
$houdini: ["./.houdini/"],
|
|
78549
|
+
"$houdini/*": ["./.houdini/*"]
|
|
78435
78550
|
};
|
|
78436
78551
|
}
|
|
78437
78552
|
await fs_exports.writeFile(configFile, JSON.stringify(tjsConfig2, null, 4));
|
|
@@ -78448,12 +78563,12 @@ async function packageJSON(targetPath, frameworkInfo) {
|
|
|
78448
78563
|
}
|
|
78449
78564
|
packageJSON2.devDependencies = {
|
|
78450
78565
|
...packageJSON2.devDependencies,
|
|
78451
|
-
houdini: "^1.
|
|
78566
|
+
houdini: "^1.4.1"
|
|
78452
78567
|
};
|
|
78453
78568
|
if (frameworkInfo.framework === "svelte" || frameworkInfo.framework === "kit") {
|
|
78454
78569
|
packageJSON2.devDependencies = {
|
|
78455
78570
|
...packageJSON2.devDependencies,
|
|
78456
|
-
"houdini-svelte": "^2.
|
|
78571
|
+
"houdini-svelte": "^2.1.1"
|
|
78457
78572
|
};
|
|
78458
78573
|
} else {
|
|
78459
78574
|
throw new Error(`Unmanaged framework: "${JSON.stringify(frameworkInfo)}"`);
|