houdini 1.2.44 → 1.2.46

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.
Files changed (55) hide show
  1. package/build/cmd-cjs/index.js +664 -848
  2. package/build/cmd-esm/index.js +514 -698
  3. package/build/codegen/generators/comments/jsdoc.d.ts +2 -0
  4. package/build/codegen-cjs/index.js +662 -846
  5. package/build/codegen-esm/index.js +512 -696
  6. package/build/lib/graphql.d.ts +1 -1
  7. package/build/lib/index.d.ts +1 -0
  8. package/build/lib/typescript.d.ts +19 -0
  9. package/build/lib-cjs/index.js +726 -467
  10. package/build/lib-esm/index.js +720 -467
  11. package/build/runtime/client/index.d.ts +7 -1
  12. package/build/runtime/client/plugins/fragment.d.ts +2 -2
  13. package/build/runtime/client/plugins/mutation.d.ts +2 -1
  14. package/build/runtime/client/plugins/query.d.ts +2 -2
  15. package/build/runtime/lib/scalars.d.ts +1 -1
  16. package/build/runtime/lib/types.d.ts +13 -2
  17. package/build/runtime/router/match.d.ts +3 -2
  18. package/build/runtime/router/types.d.ts +3 -1
  19. package/build/runtime-cjs/client/index.d.ts +7 -1
  20. package/build/runtime-cjs/client/index.js +26 -11
  21. package/build/runtime-cjs/client/plugins/fragment.d.ts +2 -2
  22. package/build/runtime-cjs/client/plugins/fragment.js +4 -11
  23. package/build/runtime-cjs/client/plugins/mutation.d.ts +2 -1
  24. package/build/runtime-cjs/client/plugins/mutation.js +8 -15
  25. package/build/runtime-cjs/client/plugins/query.d.ts +2 -2
  26. package/build/runtime-cjs/client/plugins/query.js +4 -11
  27. package/build/runtime-cjs/lib/scalars.d.ts +1 -1
  28. package/build/runtime-cjs/lib/scalars.js +4 -0
  29. package/build/runtime-cjs/lib/types.d.ts +13 -2
  30. package/build/runtime-cjs/router/match.d.ts +3 -2
  31. package/build/runtime-cjs/router/match.js +11 -2
  32. package/build/runtime-cjs/router/server.js +1 -1
  33. package/build/runtime-cjs/router/types.d.ts +3 -1
  34. package/build/runtime-esm/client/index.d.ts +7 -1
  35. package/build/runtime-esm/client/index.js +26 -11
  36. package/build/runtime-esm/client/plugins/fragment.d.ts +2 -2
  37. package/build/runtime-esm/client/plugins/fragment.js +1 -2
  38. package/build/runtime-esm/client/plugins/mutation.d.ts +2 -1
  39. package/build/runtime-esm/client/plugins/mutation.js +1 -2
  40. package/build/runtime-esm/client/plugins/query.d.ts +2 -2
  41. package/build/runtime-esm/client/plugins/query.js +1 -2
  42. package/build/runtime-esm/lib/scalars.d.ts +1 -1
  43. package/build/runtime-esm/lib/scalars.js +6 -0
  44. package/build/runtime-esm/lib/types.d.ts +13 -2
  45. package/build/runtime-esm/router/match.d.ts +3 -2
  46. package/build/runtime-esm/router/match.js +11 -2
  47. package/build/runtime-esm/router/server.js +1 -1
  48. package/build/runtime-esm/router/types.d.ts +3 -1
  49. package/build/test-cjs/index.js +677 -844
  50. package/build/test-esm/index.js +527 -694
  51. package/build/vite-cjs/index.js +786 -857
  52. package/build/vite-esm/index.js +636 -707
  53. package/package.json +1 -1
  54. package/build/codegen/generators/typescript/typeReference.d.ts +0 -8
  55. package/build/codegen/generators/typescript/types.d.ts +0 -10
@@ -23,8 +23,12 @@ export type ObserveParams<_Data extends GraphQLObject, _Artifact extends Documen
23
23
  };
24
24
  export declare class HoudiniClient {
25
25
  url: string;
26
- readonly plugins: ClientPlugin[];
27
26
  readonly throwOnError_operations: ThrowOnErrorOperations[];
27
+ private cache;
28
+ private throwOnError;
29
+ private fetchParams;
30
+ private pipeline;
31
+ private extraPlugins;
28
32
  proxies: Record<string, (operation: {
29
33
  query: string;
30
34
  variables: any;
@@ -32,7 +36,9 @@ export declare class HoudiniClient {
32
36
  session: App.Session | null | undefined;
33
37
  }) => Promise<any>>;
34
38
  componentCache: Record<string, any>;
39
+ setCache(cache: Cache): void;
35
40
  constructor({ url, fetchParams, plugins, pipeline, throwOnError, }?: HoudiniClientConstructorArgs);
41
+ get plugins(): ClientPlugin[];
36
42
  observe<_Data extends GraphQLObject, _Input extends GraphQLVariables>({ enableCache, fetching, ...rest }: ObserveParams<_Data, DocumentArtifact, _Input>): DocumentStore<_Data, _Input>;
37
43
  registerProxy(url: string, handler: (operation: {
38
44
  query: string;
@@ -1,2 +1,2 @@
1
- import type { ClientPlugin } from '../documentStore';
2
- export declare const fragment: ClientPlugin;
1
+ import type { Cache } from '../../cache/cache';
2
+ export declare const fragment: (cache: Cache) => import("..").ClientPlugin;
@@ -1 +1,2 @@
1
- export declare const mutation: import("..").ClientPlugin;
1
+ import type { Cache } from '../../cache/cache';
2
+ export declare const mutation: (cache: Cache) => import("..").ClientPlugin;
@@ -1,2 +1,2 @@
1
- import type { ClientPlugin } from '../documentStore';
2
- export declare const query: ClientPlugin;
1
+ import type { Cache } from '../../cache/cache';
2
+ export declare const query: (cache: Cache) => import("..").ClientPlugin;
@@ -1,5 +1,5 @@
1
1
  import type { ConfigFile } from './config';
2
- import type { FragmentArtifact, MutationArtifact, QueryArtifact, SubscriptionArtifact, SubscriptionSelection } from './types';
2
+ import { type FragmentArtifact, type MutationArtifact, type QueryArtifact, type SubscriptionArtifact, type SubscriptionSelection } from './types';
3
3
  export declare function marshalSelection({ selection, data, }: {
4
4
  selection: SubscriptionSelection;
5
5
  data: any;
@@ -367,6 +367,14 @@ export type PageManifest = {
367
367
  layouts: string[];
368
368
  /** The filepath of the unit */
369
369
  path: string;
370
+ /**
371
+ * The name and type of every route paramter that this page can use.
372
+ * null indicates the type is unknown (not constrained by a query)
373
+ **/
374
+ params: Record<string, {
375
+ type: string;
376
+ wrappers: string[];
377
+ } | null>;
370
378
  };
371
379
  export type QueryManifest = {
372
380
  /** the name of the query */
@@ -377,6 +385,9 @@ export type QueryManifest = {
377
385
  loading: boolean;
378
386
  /** The filepath of the unit */
379
387
  path: string;
380
- /** The list of variables that this query cares about */
381
- variables: string[];
388
+ /** The name and GraphQL type for the variables that this query cares about */
389
+ variables: Record<string, {
390
+ wrappers: string[];
391
+ type: string;
392
+ }>;
382
393
  };
@@ -1,4 +1,5 @@
1
1
  import type { GraphQLVariables } from '$houdini/runtime/lib/types';
2
+ import { type ConfigFile } from '../lib';
2
3
  import type { RouterManifest, RouterPageManifest } from './types';
3
4
  export type RouteParam = {
4
5
  name: string;
@@ -10,8 +11,8 @@ export type RouteParam = {
10
11
  export interface ParamMatcher {
11
12
  (param: string): boolean;
12
13
  }
13
- export declare function find_match<_ComponentType>(manifest: RouterManifest<_ComponentType>, current: string, allowNull: true): [RouterPageManifest<_ComponentType> | null, GraphQLVariables];
14
- export declare function find_match<_ComponentType>(manifest: RouterManifest<_ComponentType>, current: string, allowNull?: false): [RouterPageManifest<_ComponentType>, GraphQLVariables];
14
+ export declare function find_match<_ComponentType>(config: ConfigFile, manifest: RouterManifest<_ComponentType>, current: string, allowNull: true): [RouterPageManifest<_ComponentType> | null, GraphQLVariables];
15
+ export declare function find_match<_ComponentType>(config: ConfigFile, manifest: RouterManifest<_ComponentType>, current: string, allowNull?: false): [RouterPageManifest<_ComponentType>, GraphQLVariables];
15
16
  /**
16
17
  * Creates the regex pattern, extracts parameter names, and generates types for a route
17
18
  */
@@ -16,7 +16,9 @@ export type RouterPageManifest<_ComponentType> = {
16
16
  default: QueryArtifact;
17
17
  }>;
18
18
  loading: boolean;
19
- variables: string[];
19
+ variables: Record<string, {
20
+ type: string;
21
+ }>;
20
22
  }>;
21
23
  component: () => Promise<{
22
24
  default: (props: any) => _ComponentType;
@@ -23,8 +23,12 @@ export type ObserveParams<_Data extends GraphQLObject, _Artifact extends Documen
23
23
  };
24
24
  export declare class HoudiniClient {
25
25
  url: string;
26
- readonly plugins: ClientPlugin[];
27
26
  readonly throwOnError_operations: ThrowOnErrorOperations[];
27
+ private cache;
28
+ private throwOnError;
29
+ private fetchParams;
30
+ private pipeline;
31
+ private extraPlugins;
28
32
  proxies: Record<string, (operation: {
29
33
  query: string;
30
34
  variables: any;
@@ -32,7 +36,9 @@ export declare class HoudiniClient {
32
36
  session: App.Session | null | undefined;
33
37
  }) => Promise<any>>;
34
38
  componentCache: Record<string, any>;
39
+ setCache(cache: Cache): void;
35
40
  constructor({ url, fetchParams, plugins, pipeline, throwOnError, }?: HoudiniClientConstructorArgs);
41
+ get plugins(): ClientPlugin[];
36
42
  observe<_Data extends GraphQLObject, _Input extends GraphQLVariables>({ enableCache, fetching, ...rest }: ObserveParams<_Data, DocumentArtifact, _Input>): DocumentStore<_Data, _Input>;
37
43
  registerProxy(url: string, handler: (operation: {
38
44
  query: string;
@@ -33,6 +33,7 @@ __export(client_exports, {
33
33
  subscription: () => import_plugins2.subscription
34
34
  });
35
35
  module.exports = __toCommonJS(client_exports);
36
+ var import_cache = __toESM(require("../cache"), 1);
36
37
  var import_lib = require("../lib");
37
38
  var import_flatten = require("../lib/flatten");
38
39
  var import_documentStore = require("./documentStore");
@@ -42,10 +43,17 @@ var import_documentStore2 = require("./documentStore");
42
43
  var import_plugins2 = require("./plugins");
43
44
  class HoudiniClient {
44
45
  url;
45
- plugins;
46
46
  throwOnError_operations;
47
+ cache = null;
48
+ throwOnError;
49
+ fetchParams;
50
+ pipeline;
51
+ extraPlugins;
47
52
  proxies = {};
48
53
  componentCache = {};
54
+ setCache(cache) {
55
+ this.cache = cache;
56
+ }
49
57
  constructor({
50
58
  url,
51
59
  fetchParams,
@@ -59,23 +67,29 @@ class HoudiniClient {
59
67
  );
60
68
  }
61
69
  this.throwOnError_operations = throwOnError?.operations ?? [];
62
- this.plugins = (0, import_flatten.flatten)(
70
+ let serverPort = globalThis.process?.env?.HOUDINI_PORT ?? "5173";
71
+ this.url = url ?? (globalThis.window ? "" : `https://localhost:${serverPort}`) + (0, import_lib.localApiEndpoint)((0, import_lib.getCurrentConfig)());
72
+ this.throwOnError = throwOnError;
73
+ this.fetchParams = fetchParams;
74
+ this.pipeline = pipeline;
75
+ this.extraPlugins = plugins;
76
+ }
77
+ get plugins() {
78
+ return (0, import_flatten.flatten)(
63
79
  [].concat(
64
- throwOnError ? [(0, import_plugins.throwOnError)(throwOnError)] : [],
65
- (0, import_plugins.fetchParams)(fetchParams),
66
- pipeline ?? [
67
- import_plugins.query,
68
- import_plugins.mutation,
69
- import_plugins.fragment
80
+ this.throwOnError ? [(0, import_plugins.throwOnError)(this.throwOnError)] : [],
81
+ (0, import_plugins.fetchParams)(this.fetchParams),
82
+ this.pipeline ?? [
83
+ (0, import_plugins.query)(this.cache ?? import_cache.default),
84
+ (0, import_plugins.mutation)(this.cache ?? import_cache.default),
85
+ (0, import_plugins.fragment)(this.cache ?? import_cache.default)
70
86
  ].concat(
71
- plugins ?? [],
87
+ this.extraPlugins ?? [],
72
88
  import_injectedPlugins.default,
73
89
  (0, import_plugins.fetch)()
74
90
  )
75
91
  )
76
92
  );
77
- let serverPort = globalThis.process?.env?.HOUDINI_PORT ?? "5173";
78
- this.url = url ?? (globalThis.window ? "" : `https://localhost:${serverPort}`) + (0, import_lib.localApiEndpoint)((0, import_lib.getCurrentConfig)());
79
93
  }
80
94
  observe({
81
95
  enableCache = true,
@@ -87,6 +101,7 @@ class HoudiniClient {
87
101
  plugins: createPluginHooks(this.plugins),
88
102
  fetching,
89
103
  enableCache,
104
+ cache: this.cache ?? void 0,
90
105
  ...rest
91
106
  });
92
107
  }
@@ -1,2 +1,2 @@
1
- import type { ClientPlugin } from '../documentStore';
2
- export declare const fragment: ClientPlugin;
1
+ import type { Cache } from '../../cache/cache';
2
+ export declare const fragment: (cache: Cache) => import("..").ClientPlugin;
@@ -1,9 +1,7 @@
1
1
  "use strict";
2
- var __create = Object.create;
3
2
  var __defProp = Object.defineProperty;
4
3
  var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
5
4
  var __getOwnPropNames = Object.getOwnPropertyNames;
6
- var __getProtoOf = Object.getPrototypeOf;
7
5
  var __hasOwnProp = Object.prototype.hasOwnProperty;
8
6
  var __export = (target, all) => {
9
7
  for (var name in all)
@@ -17,21 +15,16 @@ var __copyProps = (to, from, except, desc) => {
17
15
  }
18
16
  return to;
19
17
  };
20
- var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
21
- isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
22
- mod
23
- ));
24
18
  var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
25
19
  var fragment_exports = {};
26
20
  __export(fragment_exports, {
27
21
  fragment: () => fragment
28
22
  });
29
23
  module.exports = __toCommonJS(fragment_exports);
30
- var import_cache = __toESM(require("../../cache"), 1);
31
24
  var import_deepEquals = require("../../lib/deepEquals");
32
25
  var import_types = require("../../lib/types");
33
26
  var import_utils = require("../utils");
34
- const fragment = (0, import_utils.documentPlugin)(import_types.ArtifactKind.Fragment, function() {
27
+ const fragment = (cache) => (0, import_utils.documentPlugin)(import_types.ArtifactKind.Fragment, function() {
35
28
  let subscriptionSpec = null;
36
29
  let lastReference = null;
37
30
  return {
@@ -45,7 +38,7 @@ const fragment = (0, import_utils.documentPlugin)(import_types.ArtifactKind.Frag
45
38
  };
46
39
  if (!ctx.cacheParams?.disableSubscriptions && (!(0, import_deepEquals.deepEquals)(lastReference, currentReference) || variablesChanged(ctx))) {
47
40
  if (subscriptionSpec) {
48
- import_cache.default.unsubscribe(subscriptionSpec, subscriptionSpec.variables?.() || {});
41
+ cache.unsubscribe(subscriptionSpec, subscriptionSpec.variables?.() || {});
49
42
  }
50
43
  const variables = marshalVariables(ctx);
51
44
  subscriptionSpec = {
@@ -65,14 +58,14 @@ const fragment = (0, import_utils.documentPlugin)(import_types.ArtifactKind.Frag
65
58
  });
66
59
  }
67
60
  };
68
- import_cache.default.subscribe(subscriptionSpec, variables);
61
+ cache.subscribe(subscriptionSpec, variables);
69
62
  lastReference = currentReference;
70
63
  }
71
64
  next(ctx);
72
65
  },
73
66
  cleanup() {
74
67
  if (subscriptionSpec) {
75
- import_cache.default.unsubscribe(subscriptionSpec, subscriptionSpec.variables?.());
68
+ cache.unsubscribe(subscriptionSpec, subscriptionSpec.variables?.());
76
69
  }
77
70
  }
78
71
  };
@@ -1 +1,2 @@
1
- export declare const mutation: import("..").ClientPlugin;
1
+ import type { Cache } from '../../cache/cache';
2
+ export declare const mutation: (cache: Cache) => import("..").ClientPlugin;
@@ -1,9 +1,7 @@
1
1
  "use strict";
2
- var __create = Object.create;
3
2
  var __defProp = Object.defineProperty;
4
3
  var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
5
4
  var __getOwnPropNames = Object.getOwnPropertyNames;
6
- var __getProtoOf = Object.getPrototypeOf;
7
5
  var __hasOwnProp = Object.prototype.hasOwnProperty;
8
6
  var __export = (target, all) => {
9
7
  for (var name in all)
@@ -17,28 +15,23 @@ var __copyProps = (to, from, except, desc) => {
17
15
  }
18
16
  return to;
19
17
  };
20
- var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
21
- isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
22
- mod
23
- ));
24
18
  var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
25
19
  var mutation_exports = {};
26
20
  __export(mutation_exports, {
27
21
  mutation: () => mutation
28
22
  });
29
23
  module.exports = __toCommonJS(mutation_exports);
30
- var import_cache = __toESM(require("../../cache"), 1);
31
24
  var import_scalars = require("../../lib/scalars");
32
25
  var import_types = require("../../lib/types");
33
26
  var import_utils = require("../utils");
34
- const mutation = (0, import_utils.documentPlugin)(import_types.ArtifactKind.Mutation, () => {
27
+ const mutation = (cache) => (0, import_utils.documentPlugin)(import_types.ArtifactKind.Mutation, () => {
35
28
  return {
36
29
  async start(ctx, { next, marshalVariables }) {
37
- const layerOptimistic = import_cache.default._internal_unstable.storage.createLayer(true);
30
+ const layerOptimistic = cache._internal_unstable.storage.createLayer(true);
38
31
  const optimisticResponse = ctx.stuff.optimisticResponse;
39
32
  let toNotify = [];
40
33
  if (optimisticResponse) {
41
- toNotify = import_cache.default.write({
34
+ toNotify = cache.write({
42
35
  selection: ctx.artifact.selection,
43
36
  data: await (0, import_scalars.marshalSelection)({
44
37
  selection: ctx.artifact.selection,
@@ -58,7 +51,7 @@ const mutation = (0, import_utils.documentPlugin)(import_types.ArtifactKind.Muta
58
51
  },
59
52
  afterNetwork(ctx, { resolve }) {
60
53
  if (ctx.cacheParams?.layer) {
61
- import_cache.default.clearLayer(ctx.cacheParams.layer.id);
54
+ cache.clearLayer(ctx.cacheParams.layer.id);
62
55
  }
63
56
  resolve(ctx);
64
57
  },
@@ -66,19 +59,19 @@ const mutation = (0, import_utils.documentPlugin)(import_types.ArtifactKind.Muta
66
59
  const hasErrors = value.errors && value.errors.length > 0;
67
60
  if (hasErrors) {
68
61
  if (ctx.cacheParams?.layer) {
69
- import_cache.default.clearLayer(ctx.cacheParams.layer.id);
62
+ cache.clearLayer(ctx.cacheParams.layer.id);
70
63
  }
71
64
  }
72
65
  if (ctx.cacheParams?.layer) {
73
- import_cache.default._internal_unstable.storage.resolveLayer(ctx.cacheParams.layer.id);
66
+ cache._internal_unstable.storage.resolveLayer(ctx.cacheParams.layer.id);
74
67
  }
75
68
  resolve(ctx);
76
69
  },
77
70
  catch(ctx, { error }) {
78
71
  if (ctx.cacheParams?.layer) {
79
72
  const { layer } = ctx.cacheParams;
80
- import_cache.default.clearLayer(layer.id);
81
- import_cache.default._internal_unstable.storage.resolveLayer(layer.id);
73
+ cache.clearLayer(layer.id);
74
+ cache._internal_unstable.storage.resolveLayer(layer.id);
82
75
  }
83
76
  throw error;
84
77
  }
@@ -1,2 +1,2 @@
1
- import type { ClientPlugin } from '../documentStore';
2
- export declare const query: ClientPlugin;
1
+ import type { Cache } from '../../cache/cache';
2
+ export declare const query: (cache: Cache) => import("..").ClientPlugin;
@@ -1,9 +1,7 @@
1
1
  "use strict";
2
- var __create = Object.create;
3
2
  var __defProp = Object.defineProperty;
4
3
  var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
5
4
  var __getOwnPropNames = Object.getOwnPropertyNames;
6
- var __getProtoOf = Object.getPrototypeOf;
7
5
  var __hasOwnProp = Object.prototype.hasOwnProperty;
8
6
  var __export = (target, all) => {
9
7
  for (var name in all)
@@ -17,20 +15,15 @@ var __copyProps = (to, from, except, desc) => {
17
15
  }
18
16
  return to;
19
17
  };
20
- var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
21
- isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
22
- mod
23
- ));
24
18
  var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
25
19
  var query_exports = {};
26
20
  __export(query_exports, {
27
21
  query: () => query
28
22
  });
29
23
  module.exports = __toCommonJS(query_exports);
30
- var import_cache = __toESM(require("../../cache"), 1);
31
24
  var import_types = require("../../lib/types");
32
25
  var import_utils = require("../utils");
33
- const query = (0, import_utils.documentPlugin)(import_types.ArtifactKind.Query, function() {
26
+ const query = (cache) => (0, import_utils.documentPlugin)(import_types.ArtifactKind.Query, function() {
34
27
  let subscriptionSpec = null;
35
28
  let lastVariables = null;
36
29
  return {
@@ -58,7 +51,7 @@ const query = (0, import_utils.documentPlugin)(import_types.ArtifactKind.Query,
58
51
  end(ctx, { resolve, marshalVariables, variablesChanged }) {
59
52
  if (variablesChanged(ctx) && !ctx.cacheParams?.disableSubscriptions) {
60
53
  if (subscriptionSpec) {
61
- import_cache.default.unsubscribe(subscriptionSpec, subscriptionSpec.variables?.() || {});
54
+ cache.unsubscribe(subscriptionSpec, subscriptionSpec.variables?.() || {});
62
55
  }
63
56
  lastVariables = { ...marshalVariables(ctx) };
64
57
  const variables = lastVariables;
@@ -78,13 +71,13 @@ const query = (0, import_utils.documentPlugin)(import_types.ArtifactKind.Query,
78
71
  });
79
72
  }
80
73
  };
81
- import_cache.default.subscribe(subscriptionSpec, lastVariables);
74
+ cache.subscribe(subscriptionSpec, lastVariables);
82
75
  }
83
76
  resolve(ctx);
84
77
  },
85
78
  cleanup() {
86
79
  if (subscriptionSpec) {
87
- import_cache.default.unsubscribe(subscriptionSpec, subscriptionSpec.variables?.());
80
+ cache.unsubscribe(subscriptionSpec, subscriptionSpec.variables?.());
88
81
  lastVariables = null;
89
82
  }
90
83
  }
@@ -1,5 +1,5 @@
1
1
  import type { ConfigFile } from './config';
2
- import type { FragmentArtifact, MutationArtifact, QueryArtifact, SubscriptionArtifact, SubscriptionSelection } from './types';
2
+ import { type FragmentArtifact, type MutationArtifact, type QueryArtifact, type SubscriptionArtifact, type SubscriptionSelection } from './types';
3
3
  export declare function marshalSelection({ selection, data, }: {
4
4
  selection: SubscriptionSelection;
5
5
  data: any;
@@ -26,6 +26,7 @@ __export(scalars_exports, {
26
26
  module.exports = __toCommonJS(scalars_exports);
27
27
  var import_config = require("./config");
28
28
  var import_selection = require("./selection");
29
+ var import_types = require("./types");
29
30
  async function marshalSelection({
30
31
  selection,
31
32
  data
@@ -41,6 +42,9 @@ async function marshalSelection({
41
42
  return Object.fromEntries(
42
43
  await Promise.all(
43
44
  Object.entries(data).map(async ([fieldName, value]) => {
45
+ if (fieldName === import_types.fragmentKey) {
46
+ return [fieldName, value];
47
+ }
44
48
  const { type, selection: selection2 } = targetSelection[fieldName];
45
49
  if (!type) {
46
50
  return [fieldName, value];
@@ -367,6 +367,14 @@ export type PageManifest = {
367
367
  layouts: string[];
368
368
  /** The filepath of the unit */
369
369
  path: string;
370
+ /**
371
+ * The name and type of every route paramter that this page can use.
372
+ * null indicates the type is unknown (not constrained by a query)
373
+ **/
374
+ params: Record<string, {
375
+ type: string;
376
+ wrappers: string[];
377
+ } | null>;
370
378
  };
371
379
  export type QueryManifest = {
372
380
  /** the name of the query */
@@ -377,6 +385,9 @@ export type QueryManifest = {
377
385
  loading: boolean;
378
386
  /** The filepath of the unit */
379
387
  path: string;
380
- /** The list of variables that this query cares about */
381
- variables: string[];
388
+ /** The name and GraphQL type for the variables that this query cares about */
389
+ variables: Record<string, {
390
+ wrappers: string[];
391
+ type: string;
392
+ }>;
382
393
  };
@@ -1,4 +1,5 @@
1
1
  import type { GraphQLVariables } from '$houdini/runtime/lib/types';
2
+ import { type ConfigFile } from '../lib';
2
3
  import type { RouterManifest, RouterPageManifest } from './types';
3
4
  export type RouteParam = {
4
5
  name: string;
@@ -10,8 +11,8 @@ export type RouteParam = {
10
11
  export interface ParamMatcher {
11
12
  (param: string): boolean;
12
13
  }
13
- export declare function find_match<_ComponentType>(manifest: RouterManifest<_ComponentType>, current: string, allowNull: true): [RouterPageManifest<_ComponentType> | null, GraphQLVariables];
14
- export declare function find_match<_ComponentType>(manifest: RouterManifest<_ComponentType>, current: string, allowNull?: false): [RouterPageManifest<_ComponentType>, GraphQLVariables];
14
+ export declare function find_match<_ComponentType>(config: ConfigFile, manifest: RouterManifest<_ComponentType>, current: string, allowNull: true): [RouterPageManifest<_ComponentType> | null, GraphQLVariables];
15
+ export declare function find_match<_ComponentType>(config: ConfigFile, manifest: RouterManifest<_ComponentType>, current: string, allowNull?: false): [RouterPageManifest<_ComponentType>, GraphQLVariables];
15
16
  /**
16
17
  * Creates the regex pattern, extracts parameter names, and generates types for a route
17
18
  */
@@ -24,8 +24,9 @@ __export(match_exports, {
24
24
  parse_page_pattern: () => parse_page_pattern
25
25
  });
26
26
  module.exports = __toCommonJS(match_exports);
27
+ var import_lib = require("../lib");
27
28
  const param_pattern = /^(\[)?(\.\.\.)?(\w+)(?:=(\w+))?(\])?$/;
28
- function find_match(manifest, current, allowNull = true) {
29
+ function find_match(config, manifest, current, allowNull = true) {
29
30
  let match = null;
30
31
  let matchVariables = null;
31
32
  for (const page of Object.values(manifest.pages)) {
@@ -40,7 +41,15 @@ function find_match(manifest, current, allowNull = true) {
40
41
  if (!match && !allowNull) {
41
42
  throw new Error("404");
42
43
  }
43
- return [match, matchVariables];
44
+ let variables = {};
45
+ for (const document of Object.values(match?.documents ?? {})) {
46
+ for (const [variable, { type }] of Object.entries(document.variables)) {
47
+ if (matchVariables?.[variable]) {
48
+ variables[variable] = (0, import_lib.parseScalar)(config, type, matchVariables[variable]);
49
+ }
50
+ }
51
+ }
52
+ return [match, variables];
44
53
  }
45
54
  function parse_page_pattern(id) {
46
55
  const params = [];
@@ -73,7 +73,7 @@ function _serverHandler({
73
73
  if (authResponse) {
74
74
  return authResponse;
75
75
  }
76
- const [match] = (0, import_match.find_match)(manifest, url);
76
+ const [match] = (0, import_match.find_match)(config_file, manifest, url);
77
77
  const rendered = await on_render({
78
78
  url,
79
79
  match,
@@ -16,7 +16,9 @@ export type RouterPageManifest<_ComponentType> = {
16
16
  default: QueryArtifact;
17
17
  }>;
18
18
  loading: boolean;
19
- variables: string[];
19
+ variables: Record<string, {
20
+ type: string;
21
+ }>;
20
22
  }>;
21
23
  component: () => Promise<{
22
24
  default: (props: any) => _ComponentType;
@@ -23,8 +23,12 @@ export type ObserveParams<_Data extends GraphQLObject, _Artifact extends Documen
23
23
  };
24
24
  export declare class HoudiniClient {
25
25
  url: string;
26
- readonly plugins: ClientPlugin[];
27
26
  readonly throwOnError_operations: ThrowOnErrorOperations[];
27
+ private cache;
28
+ private throwOnError;
29
+ private fetchParams;
30
+ private pipeline;
31
+ private extraPlugins;
28
32
  proxies: Record<string, (operation: {
29
33
  query: string;
30
34
  variables: any;
@@ -32,7 +36,9 @@ export declare class HoudiniClient {
32
36
  session: App.Session | null | undefined;
33
37
  }) => Promise<any>>;
34
38
  componentCache: Record<string, any>;
39
+ setCache(cache: Cache): void;
35
40
  constructor({ url, fetchParams, plugins, pipeline, throwOnError, }?: HoudiniClientConstructorArgs);
41
+ get plugins(): ClientPlugin[];
36
42
  observe<_Data extends GraphQLObject, _Input extends GraphQLVariables>({ enableCache, fetching, ...rest }: ObserveParams<_Data, DocumentArtifact, _Input>): DocumentStore<_Data, _Input>;
37
43
  registerProxy(url: string, handler: (operation: {
38
44
  query: string;
@@ -1,3 +1,4 @@
1
+ import cacheRef from "../cache";
1
2
  import { getCurrentConfig, localApiEndpoint } from "../lib";
2
3
  import { flatten } from "../lib/flatten";
3
4
  import { DocumentStore } from "./documentStore";
@@ -14,10 +15,17 @@ import { DocumentStore as DocumentStore2 } from "./documentStore";
14
15
  import { fetch, mutation, query, subscription } from "./plugins";
15
16
  class HoudiniClient {
16
17
  url;
17
- plugins;
18
18
  throwOnError_operations;
19
+ cache = null;
20
+ throwOnError;
21
+ fetchParams;
22
+ pipeline;
23
+ extraPlugins;
19
24
  proxies = {};
20
25
  componentCache = {};
26
+ setCache(cache) {
27
+ this.cache = cache;
28
+ }
21
29
  constructor({
22
30
  url,
23
31
  fetchParams,
@@ -31,23 +39,29 @@ class HoudiniClient {
31
39
  );
32
40
  }
33
41
  this.throwOnError_operations = throwOnError?.operations ?? [];
34
- this.plugins = flatten(
42
+ let serverPort = globalThis.process?.env?.HOUDINI_PORT ?? "5173";
43
+ this.url = url ?? (globalThis.window ? "" : `https://localhost:${serverPort}`) + localApiEndpoint(getCurrentConfig());
44
+ this.throwOnError = throwOnError;
45
+ this.fetchParams = fetchParams;
46
+ this.pipeline = pipeline;
47
+ this.extraPlugins = plugins;
48
+ }
49
+ get plugins() {
50
+ return flatten(
35
51
  [].concat(
36
- throwOnError ? [throwOnErrorPlugin(throwOnError)] : [],
37
- fetchParamsPlugin(fetchParams),
38
- pipeline ?? [
39
- queryPlugin,
40
- mutationPlugin,
41
- fragmentPlugin
52
+ this.throwOnError ? [throwOnErrorPlugin(this.throwOnError)] : [],
53
+ fetchParamsPlugin(this.fetchParams),
54
+ this.pipeline ?? [
55
+ queryPlugin(this.cache ?? cacheRef),
56
+ mutationPlugin(this.cache ?? cacheRef),
57
+ fragmentPlugin(this.cache ?? cacheRef)
42
58
  ].concat(
43
- plugins ?? [],
59
+ this.extraPlugins ?? [],
44
60
  pluginsFromPlugins,
45
61
  fetchPlugin()
46
62
  )
47
63
  )
48
64
  );
49
- let serverPort = globalThis.process?.env?.HOUDINI_PORT ?? "5173";
50
- this.url = url ?? (globalThis.window ? "" : `https://localhost:${serverPort}`) + localApiEndpoint(getCurrentConfig());
51
65
  }
52
66
  observe({
53
67
  enableCache = true,
@@ -59,6 +73,7 @@ class HoudiniClient {
59
73
  plugins: createPluginHooks(this.plugins),
60
74
  fetching,
61
75
  enableCache,
76
+ cache: this.cache ?? void 0,
62
77
  ...rest
63
78
  });
64
79
  }
@@ -1,2 +1,2 @@
1
- import type { ClientPlugin } from '../documentStore';
2
- export declare const fragment: ClientPlugin;
1
+ import type { Cache } from '../../cache/cache';
2
+ export declare const fragment: (cache: Cache) => import("..").ClientPlugin;
@@ -1,8 +1,7 @@
1
- import cache from "../../cache";
2
1
  import { deepEquals } from "../../lib/deepEquals";
3
2
  import { ArtifactKind, DataSource } from "../../lib/types";
4
3
  import { documentPlugin } from "../utils";
5
- const fragment = documentPlugin(ArtifactKind.Fragment, function() {
4
+ const fragment = (cache) => documentPlugin(ArtifactKind.Fragment, function() {
6
5
  let subscriptionSpec = null;
7
6
  let lastReference = null;
8
7
  return {
@@ -1 +1,2 @@
1
- export declare const mutation: import("..").ClientPlugin;
1
+ import type { Cache } from '../../cache/cache';
2
+ export declare const mutation: (cache: Cache) => import("..").ClientPlugin;