houdini 1.0.0-next.8 → 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.
Files changed (92) hide show
  1. package/README.md +4 -1
  2. package/build/cmd-cjs/index.js +2325 -121
  3. package/build/cmd-esm/index.js +2325 -121
  4. package/build/codegen/generators/runtime/runtimeConfig.d.ts +7 -0
  5. package/build/codegen/generators/typescript/typeReference.d.ts +4 -2
  6. package/build/codegen/generators/typescript/types.d.ts +0 -1
  7. package/build/codegen/utils/flattenSelections.d.ts +1 -1
  8. package/build/codegen-cjs/index.js +2919 -689
  9. package/build/codegen-esm/index.js +2919 -689
  10. package/build/lib/config.d.ts +4 -6
  11. package/build/lib/types.d.ts +18 -15
  12. package/build/lib-cjs/index.js +3159 -171
  13. package/build/lib-esm/index.js +3152 -171
  14. package/build/runtime/cache/storage.d.ts +18 -15
  15. package/build/runtime/client/documentStore.d.ts +15 -13
  16. package/build/runtime/client/index.d.ts +1 -1
  17. package/build/runtime/client/plugins/cache.d.ts +1 -1
  18. package/build/runtime/client/plugins/fetch.d.ts +1 -1
  19. package/build/runtime/client/plugins/fetchParams.d.ts +1 -1
  20. package/build/runtime/client/plugins/mutation.d.ts +1 -1
  21. package/build/runtime/client/plugins/query.d.ts +1 -1
  22. package/build/runtime/client/plugins/subscription.d.ts +1 -1
  23. package/build/runtime/client/plugins/throwOnError.d.ts +1 -1
  24. package/build/runtime/client/utils/documentPlugins.d.ts +2 -2
  25. package/build/runtime/imports/pluginConfig.d.ts +3 -0
  26. package/build/runtime/lib/config.d.ts +2 -2
  27. package/build/runtime/lib/scalars.d.ts +1 -1
  28. package/build/runtime/lib/types.d.ts +42 -42
  29. package/build/runtime-cjs/cache/storage.d.ts +18 -15
  30. package/build/runtime-cjs/cache/storage.js +9 -11
  31. package/build/runtime-cjs/client/documentStore.d.ts +15 -13
  32. package/build/runtime-cjs/client/documentStore.js +11 -8
  33. package/build/runtime-cjs/client/index.d.ts +1 -1
  34. package/build/runtime-cjs/client/index.js +16 -13
  35. package/build/runtime-cjs/client/plugins/cache.d.ts +1 -1
  36. package/build/runtime-cjs/client/plugins/cache.js +6 -6
  37. package/build/runtime-cjs/client/plugins/fetch.d.ts +1 -1
  38. package/build/runtime-cjs/client/plugins/fetch.js +9 -9
  39. package/build/runtime-cjs/client/plugins/fetchParams.d.ts +1 -1
  40. package/build/runtime-cjs/client/plugins/fetchParams.js +3 -3
  41. package/build/runtime-cjs/client/plugins/mutation.d.ts +1 -1
  42. package/build/runtime-cjs/client/plugins/mutation.js +3 -3
  43. package/build/runtime-cjs/client/plugins/query.d.ts +1 -1
  44. package/build/runtime-cjs/client/plugins/query.js +4 -4
  45. package/build/runtime-cjs/client/plugins/subscription.d.ts +1 -1
  46. package/build/runtime-cjs/client/plugins/subscription.js +5 -5
  47. package/build/runtime-cjs/client/plugins/throwOnError.d.ts +1 -1
  48. package/build/runtime-cjs/client/plugins/throwOnError.js +3 -3
  49. package/build/runtime-cjs/client/utils/documentPlugins.d.ts +2 -2
  50. package/build/runtime-cjs/imports/pluginConfig.d.ts +3 -0
  51. package/build/runtime-cjs/imports/pluginConfig.js +27 -0
  52. package/build/runtime-cjs/lib/config.d.ts +2 -2
  53. package/build/runtime-cjs/lib/config.js +11 -1
  54. package/build/runtime-cjs/lib/scalars.d.ts +1 -1
  55. package/build/runtime-cjs/lib/scalars.js +13 -2
  56. package/build/runtime-cjs/lib/types.d.ts +42 -42
  57. package/build/runtime-cjs/lib/types.js +26 -30
  58. package/build/runtime-esm/cache/storage.d.ts +18 -15
  59. package/build/runtime-esm/cache/storage.js +9 -11
  60. package/build/runtime-esm/client/documentStore.d.ts +15 -13
  61. package/build/runtime-esm/client/documentStore.js +12 -9
  62. package/build/runtime-esm/client/index.d.ts +1 -1
  63. package/build/runtime-esm/client/index.js +13 -10
  64. package/build/runtime-esm/client/plugins/cache.d.ts +1 -1
  65. package/build/runtime-esm/client/plugins/cache.js +5 -5
  66. package/build/runtime-esm/client/plugins/fetch.d.ts +1 -1
  67. package/build/runtime-esm/client/plugins/fetch.js +8 -8
  68. package/build/runtime-esm/client/plugins/fetchParams.d.ts +1 -1
  69. package/build/runtime-esm/client/plugins/fetchParams.js +2 -2
  70. package/build/runtime-esm/client/plugins/mutation.d.ts +1 -1
  71. package/build/runtime-esm/client/plugins/mutation.js +2 -2
  72. package/build/runtime-esm/client/plugins/query.d.ts +1 -1
  73. package/build/runtime-esm/client/plugins/query.js +3 -3
  74. package/build/runtime-esm/client/plugins/subscription.d.ts +1 -1
  75. package/build/runtime-esm/client/plugins/subscription.js +4 -4
  76. package/build/runtime-esm/client/plugins/throwOnError.d.ts +1 -1
  77. package/build/runtime-esm/client/plugins/throwOnError.js +2 -2
  78. package/build/runtime-esm/client/utils/documentPlugins.d.ts +2 -2
  79. package/build/runtime-esm/imports/pluginConfig.d.ts +3 -0
  80. package/build/runtime-esm/imports/pluginConfig.js +5 -0
  81. package/build/runtime-esm/lib/config.d.ts +2 -2
  82. package/build/runtime-esm/lib/config.js +11 -1
  83. package/build/runtime-esm/lib/scalars.d.ts +1 -1
  84. package/build/runtime-esm/lib/scalars.js +13 -2
  85. package/build/runtime-esm/lib/types.d.ts +42 -42
  86. package/build/runtime-esm/lib/types.js +26 -30
  87. package/build/test-cjs/index.js +2302 -98
  88. package/build/test-esm/index.js +2302 -98
  89. package/build/vite/houdini.d.ts +2 -0
  90. package/build/vite-cjs/index.js +2328 -122
  91. package/build/vite-esm/index.js +2328 -122
  92. package/package.json +2 -2
@@ -7,7 +7,7 @@ export declare class InMemoryStorage {
7
7
  get layerCount(): number;
8
8
  get nextRank(): number;
9
9
  createLayer(optimistic?: boolean): Layer;
10
- insert(id: string, field: string, location: OperationLocation, target: string): void;
10
+ insert(id: string, field: string, location: OperationLocations, target: string): void;
11
11
  remove(id: string, field: string, target: string): void;
12
12
  delete(id: string): void;
13
13
  deleteField(id: string, field: string): void;
@@ -47,7 +47,7 @@ export declare class Layer {
47
47
  removeUndefinedFields(): void;
48
48
  delete(id: string): void;
49
49
  deleteField(id: string, field: string): void;
50
- insert(id: string, field: string, where: OperationLocation, target: string): void;
50
+ insert(id: string, field: string, where: OperationLocations, target: string): void;
51
51
  remove(id: string, field: string, target: string): void;
52
52
  writeLayer(layer: Layer): void;
53
53
  private addFieldOperation;
@@ -71,28 +71,31 @@ type OperationMap = {
71
71
  };
72
72
  type NestedList<_Result = string> = (_Result | null | NestedList<_Result>)[];
73
73
  type InsertOperation = {
74
- kind: OperationKind.insert;
75
- location: OperationLocation;
74
+ kind: 'insert';
75
+ location: OperationLocations;
76
76
  id: string;
77
77
  };
78
78
  type RemoveOperation = {
79
- kind: OperationKind.remove;
79
+ kind: 'remove';
80
80
  id: string;
81
81
  };
82
82
  type DeleteOperation = {
83
- kind: OperationKind.delete;
83
+ kind: 'delete';
84
84
  target: string;
85
85
  };
86
86
  type ListOperation = InsertOperation | RemoveOperation;
87
87
  type Operation = ListOperation | DeleteOperation;
88
- export declare enum OperationLocation {
89
- start = "start",
90
- end = "end"
91
- }
92
- export declare enum OperationKind {
93
- delete = "delete",
94
- insert = "insert",
95
- remove = "remove"
96
- }
88
+ type ValuesOf<Target> = Target[keyof Target];
89
+ export declare const OperationLocation: {
90
+ readonly start: "start";
91
+ readonly end: "end";
92
+ };
93
+ export type OperationLocations = ValuesOf<typeof OperationLocation>;
94
+ export declare const OperationKind: {
95
+ readonly delete: "delete";
96
+ readonly insert: "insert";
97
+ readonly remove: "remove";
98
+ };
99
+ export type OperationKinds = ValuesOf<typeof OperationKind>;
97
100
  export type LayerID = number;
98
101
  export {};
@@ -2,7 +2,7 @@ import type { HoudiniClient } from '.';
2
2
  import type { Layer } from '../cache/storage';
3
3
  import type { ConfigFile } from '../lib/config';
4
4
  import { Writable } from '../lib/store';
5
- import type { CachePolicy, DocumentArtifact, QueryResult, GraphQLObject, SubscriptionSpec } from '../lib/types';
5
+ import type { DocumentArtifact, QueryResult, GraphQLObject, SubscriptionSpec, CachePolicies } from '../lib/types';
6
6
  export declare class DocumentStore<_Data extends GraphQLObject, _Input extends Record<string, any>> extends Writable<QueryResult<_Data, _Input>> {
7
7
  #private;
8
8
  constructor({ artifact, plugins, pipeline, client, cache, initialValue, fetching, }: {
@@ -14,16 +14,7 @@ export declare class DocumentStore<_Data extends GraphQLObject, _Input extends R
14
14
  initialValue?: _Data | null;
15
15
  fetching?: boolean;
16
16
  });
17
- send({ metadata, session, fetch, variables, policy, stuff, cacheParams, setup, }?: {
18
- fetch?: Fetch;
19
- variables?: Record<string, any> | null;
20
- metadata?: App.Metadata | null;
21
- session?: App.Session | null;
22
- policy?: CachePolicy;
23
- stuff?: Partial<App.Stuff>;
24
- cacheParams?: ClientPluginContext['cacheParams'];
25
- setup?: boolean;
26
- }): Promise<QueryResult<_Data, _Input>>;
17
+ send({ metadata, session, fetch, variables, policy, stuff, cacheParams, setup, silenceEcho, }?: SendParams): Promise<QueryResult<_Data, _Input>>;
27
18
  }
28
19
  declare function marshalVariables<_Data extends GraphQLObject, _Input extends {}>(ctx: ClientPluginContext): Record<string, any>;
29
20
  export type ClientPlugin = () => ClientHooks | null | (ClientHooks | ClientPlugin | null)[];
@@ -42,9 +33,9 @@ export type ClientPluginContext = {
42
33
  text: string;
43
34
  hash: string;
44
35
  artifact: DocumentArtifact;
45
- policy?: CachePolicy;
36
+ policy?: CachePolicies;
46
37
  fetch?: Fetch;
47
- variables?: Record<string, any>;
38
+ variables?: Record<string, any> | null;
48
39
  metadata?: App.Metadata | null;
49
40
  session?: App.Session | null;
50
41
  fetchParams?: RequestInit;
@@ -85,4 +76,15 @@ export type ClientPluginExitHandlers = Omit<ClientPluginEnterHandlers, 'resolve'
85
76
  export type ClientPluginErrorHandlers = ClientPluginEnterHandlers & {
86
77
  error: unknown;
87
78
  };
79
+ export type SendParams = {
80
+ fetch?: Fetch;
81
+ variables?: Record<string, any> | null;
82
+ metadata?: App.Metadata | null;
83
+ session?: App.Session | null;
84
+ policy?: CachePolicies;
85
+ stuff?: Partial<App.Stuff>;
86
+ cacheParams?: ClientPluginContext['cacheParams'];
87
+ setup?: boolean;
88
+ silenceEcho?: boolean;
89
+ };
88
90
  export {};
@@ -4,7 +4,7 @@ import type { ClientPlugin, ClientHooks } from './documentStore';
4
4
  import { DocumentStore } from './documentStore';
5
5
  import { type FetchParamFn, type ThrowOnErrorParams } from './plugins';
6
6
  export { DocumentStore, type ClientPlugin } from './documentStore';
7
- export { fetchPlugin, mutationPlugin, queryPlugin, subscriptionPlugin } from './plugins';
7
+ export { fetch, mutation, query, subscription } from './plugins';
8
8
  type ConstructorArgs = {
9
9
  url: string;
10
10
  fetchParams?: FetchParamFn;
@@ -1,7 +1,7 @@
1
1
  import cache from '../../cache';
2
2
  import type { Cache } from '../../cache/cache';
3
3
  import type { ClientPlugin } from '../documentStore';
4
- export declare const cachePolicyPlugin: ({ enabled, setFetching, cache: localCache, }: {
4
+ export declare const cachePolicy: ({ enabled, setFetching, cache: localCache, }: {
5
5
  enabled: boolean;
6
6
  setFetching: (val: boolean) => void;
7
7
  cache?: Cache | undefined;
@@ -1,6 +1,6 @@
1
1
  import type { RequestPayload } from '../../lib/types';
2
2
  import type { ClientPlugin } from '../documentStore';
3
- export declare const fetchPlugin: (target?: RequestHandler | string) => ClientPlugin;
3
+ export declare const fetch: (target?: RequestHandler | string) => ClientPlugin;
4
4
  export type FetchContext = {
5
5
  fetch: typeof globalThis.fetch;
6
6
  metadata?: App.Metadata | null;
@@ -1,7 +1,7 @@
1
1
  import type { DocumentArtifact } from '../../lib/types';
2
2
  import type { ClientPlugin, ClientPluginContext } from '../documentStore';
3
3
  export type FetchParamFn = (ctx: FetchParamsInput) => Required<ClientPluginContext>['fetchParams'];
4
- export declare const fetchParamsPlugin: (fn?: FetchParamFn) => ClientPlugin;
4
+ export declare const fetchParams: (fn?: FetchParamFn) => ClientPlugin;
5
5
  export type FetchParamsInput = Pick<ClientPluginContext, 'config' | 'policy' | 'variables' | 'metadata' | 'session' | 'stuff'> & {
6
6
  text: string;
7
7
  hash: string;
@@ -1 +1 @@
1
- export declare const mutationPlugin: import("..").ClientPlugin;
1
+ export declare const mutation: import("..").ClientPlugin;
@@ -1,2 +1,2 @@
1
1
  import type { ClientPlugin } from '../documentStore';
2
- export declare const queryPlugin: ClientPlugin;
2
+ export declare const query: ClientPlugin;
@@ -1,5 +1,5 @@
1
1
  import type { ClientPluginContext } from '../documentStore';
2
- export declare function subscriptionPlugin(factory: SubscriptionHandler): import("../documentStore").ClientPlugin;
2
+ export declare function subscription(factory: SubscriptionHandler): import("../documentStore").ClientPlugin;
3
3
  export type SubscriptionHandler = (ctx: ClientPluginContext) => {
4
4
  subscribe: (payload: {
5
5
  query: string;
@@ -4,4 +4,4 @@ export type ThrowOnErrorParams = {
4
4
  operations: ('all' | 'query' | 'mutation' | 'subscription')[];
5
5
  error?: (errors: NonNullable<QueryResult<any, any>['errors']>) => unknown;
6
6
  };
7
- export declare const throwOnErrorPlugin: ({ operations, error }: ThrowOnErrorParams) => ClientPlugin;
7
+ export declare const throwOnError: ({ operations, error }: ThrowOnErrorParams) => ClientPlugin;
@@ -1,3 +1,3 @@
1
- import type { ArtifactKind } from '../../lib/types';
1
+ import type { ArtifactKinds } from '../../lib/types';
2
2
  import type { ClientPlugin, ClientHooks } from '../documentStore';
3
- export declare const documentPlugin: (kind: ArtifactKind, source: () => ClientHooks) => ClientPlugin;
3
+ export declare const documentPlugin: (kind: ArtifactKinds, source: () => ClientHooks) => ClientPlugin;
@@ -0,0 +1,3 @@
1
+ import type { ConfigFile } from '../lib/config';
2
+ declare const configs: ((old: ConfigFile) => ConfigFile)[];
3
+ export default configs;
@@ -1,5 +1,5 @@
1
1
  import type { GraphQLSchema } from 'graphql';
2
- import type { CachePolicy } from './types';
2
+ import type { CachePolicies } from './types';
3
3
  export declare function getMockConfig(): ConfigFile | null;
4
4
  export declare function setMockConfig(config: ConfigFile | null): void;
5
5
  export declare function defaultConfigValues(file: ConfigFile): ConfigFile;
@@ -50,7 +50,7 @@ export type ConfigFile = {
50
50
  /**
51
51
  * The default cache policy to use for queries. For more information: https://www.houdinigraphql.com/guides/caching-data
52
52
  */
53
- defaultCachePolicy?: CachePolicy;
53
+ defaultCachePolicy?: CachePolicies;
54
54
  /**
55
55
  * Specifies whether or not the cache should always use partial data. For more information: https://www.houdinigraphql.com/guides/caching-data#partial-data
56
56
  */
@@ -12,4 +12,4 @@ export declare function marshalInputs<T>({ artifact, input, config, rootType, }:
12
12
  }): {} | null | undefined;
13
13
  export declare function unmarshalSelection(config: ConfigFile, selection: SubscriptionSelection, data: any): {} | null | undefined;
14
14
  export declare function isScalar(config: ConfigFile, type: string): boolean;
15
- export declare function parseScalar(config: ConfigFile, type: string, value: string): string | number | boolean;
15
+ export declare function parseScalar(config: ConfigFile, type: string, value?: string): string | number | boolean | undefined;
@@ -1,9 +1,11 @@
1
- export declare enum CachePolicy {
2
- CacheOrNetwork = "CacheOrNetwork",
3
- CacheOnly = "CacheOnly",
4
- NetworkOnly = "NetworkOnly",
5
- CacheAndNetwork = "CacheAndNetwork"
6
- }
1
+ export declare const CachePolicy: {
2
+ readonly CacheOrNetwork: "CacheOrNetwork";
3
+ readonly CacheOnly: "CacheOnly";
4
+ readonly NetworkOnly: "NetworkOnly";
5
+ readonly CacheAndNetwork: "CacheAndNetwork";
6
+ };
7
+ type ValuesOf<Target> = Target[keyof Target];
8
+ export type CachePolicies = ValuesOf<typeof CachePolicy>;
7
9
  declare global {
8
10
  namespace App {
9
11
  interface Session {
@@ -29,42 +31,38 @@ export type Operation<_Result, _Input> = {
29
31
  };
30
32
  export type Maybe<T> = T | null | undefined;
31
33
  export type DocumentArtifact = FragmentArtifact | QueryArtifact | MutationArtifact | SubscriptionArtifact;
32
- export declare enum ArtifactKind {
33
- Query = "HoudiniQuery",
34
- Subscription = "HoudiniSubscription",
35
- Mutation = "HoudiniMutation",
36
- Fragment = "HoudiniFragment"
37
- }
38
- export declare const CompiledFragmentKind = ArtifactKind.Fragment;
39
- export declare const CompiledMutationKind = ArtifactKind.Mutation;
40
- export declare const CompiledQueryKind = ArtifactKind.Query;
41
- export declare const CompiledSubscriptionKind = ArtifactKind.Subscription;
42
- export type CompiledDocumentKind = ArtifactKind;
43
- export type QueryArtifact = BaseCompiledDocument & {
44
- kind: ArtifactKind.Query;
45
- policy?: CachePolicy;
34
+ export declare const ArtifactKind: {
35
+ readonly Query: "HoudiniQuery";
36
+ readonly Subscription: "HoudiniSubscription";
37
+ readonly Mutation: "HoudiniMutation";
38
+ readonly Fragment: "HoudiniFragment";
39
+ };
40
+ export type ArtifactKinds = ValuesOf<typeof ArtifactKind>;
41
+ export declare const CompiledFragmentKind: "HoudiniFragment";
42
+ export declare const CompiledMutationKind: "HoudiniMutation";
43
+ export declare const CompiledQueryKind: "HoudiniQuery";
44
+ export declare const CompiledSubscriptionKind: "HoudiniSubscription";
45
+ export type CompiledDocumentKind = ArtifactKinds;
46
+ export type QueryArtifact = BaseCompiledDocument<'HoudiniQuery'> & {
47
+ policy?: CachePolicies;
46
48
  partial?: boolean;
47
49
  };
48
- export type MutationArtifact = BaseCompiledDocument & {
49
- kind: ArtifactKind.Mutation;
50
- };
51
- export type FragmentArtifact = BaseCompiledDocument & {
52
- kind: ArtifactKind.Fragment;
53
- };
54
- export type SubscriptionArtifact = BaseCompiledDocument & {
55
- kind: ArtifactKind.Subscription;
50
+ export type MutationArtifact = BaseCompiledDocument<'HoudiniMutation'>;
51
+ export type FragmentArtifact = BaseCompiledDocument<'HoudiniFragment'>;
52
+ export type SubscriptionArtifact = BaseCompiledDocument<'HoudiniSubscription'>;
53
+ export declare const RefetchUpdateMode: {
54
+ readonly append: "append";
55
+ readonly prepend: "prepend";
56
+ readonly replace: "replace";
56
57
  };
57
- export declare enum RefetchUpdateMode {
58
- append = "append",
59
- prepend = "prepend",
60
- replace = "replace"
61
- }
58
+ export type RefetchUpdateModes = ValuesOf<typeof RefetchUpdateMode>;
62
59
  export type InputObject = {
63
60
  fields: Record<string, string>;
64
61
  types: Record<string, Record<string, string>>;
65
62
  };
66
- export type BaseCompiledDocument = {
63
+ export type BaseCompiledDocument<_Kind extends ArtifactKinds> = {
67
64
  name: string;
65
+ kind: _Kind;
68
66
  raw: string;
69
67
  hash: string;
70
68
  selection: SubscriptionSelection;
@@ -80,7 +78,7 @@ export type BaseCompiledDocument = {
80
78
  paginated: boolean;
81
79
  direction: 'forward' | 'backward' | 'both';
82
80
  };
83
- plugin_data?: Record<string, any>;
81
+ pluginData?: Record<string, any>;
84
82
  };
85
83
  export type HoudiniFetchContext = {
86
84
  variables: () => {};
@@ -92,20 +90,21 @@ export type ListWhen = {
92
90
  must?: Filter;
93
91
  must_not?: Filter;
94
92
  };
95
- export declare enum DataSource {
93
+ export declare const DataSource: {
96
94
  /**
97
95
  * from the browser cache
98
96
  */
99
- Cache = "cache",
97
+ readonly Cache: "cache";
100
98
  /**
101
99
  * from a browser side `fetch`
102
100
  */
103
- Network = "network",
101
+ readonly Network: "network";
104
102
  /**
105
103
  * from a server side `fetch`
106
104
  */
107
- Ssr = "ssr"
108
- }
105
+ readonly Ssr: "ssr";
106
+ };
107
+ export type DataSources = ValuesOf<typeof DataSource>;
109
108
  export type MutationOperation = {
110
109
  action: 'insert' | 'remove' | 'delete' | 'toggle';
111
110
  list?: string;
@@ -163,7 +162,7 @@ export type SubscriptionSpec = {
163
162
  };
164
163
  export type FetchQueryResult<_Data> = {
165
164
  result: RequestPayload<_Data | null>;
166
- source: DataSource | null;
165
+ source: DataSources | null;
167
166
  };
168
167
  export type QueryResult<_Data = GraphQLObject, _Input = Record<string, any>> = {
169
168
  data: _Data | null;
@@ -173,7 +172,7 @@ export type QueryResult<_Data = GraphQLObject, _Input = Record<string, any>> = {
173
172
  fetching: boolean;
174
173
  partial: boolean;
175
174
  stale: boolean;
176
- source: DataSource | null;
175
+ source: DataSources | null;
177
176
  variables: _Input | null;
178
177
  };
179
178
  export type RequestPayload<GraphQLObject = any> = {
@@ -183,4 +182,5 @@ export type RequestPayload<GraphQLObject = any> = {
183
182
  }[] | null;
184
183
  };
185
184
  export type NestedList<_Result = string> = (_Result | null | NestedList<_Result>)[];
185
+ export type ValueOf<Parent> = Parent[keyof Parent];
186
186
  export {};
@@ -7,7 +7,7 @@ export declare class InMemoryStorage {
7
7
  get layerCount(): number;
8
8
  get nextRank(): number;
9
9
  createLayer(optimistic?: boolean): Layer;
10
- insert(id: string, field: string, location: OperationLocation, target: string): void;
10
+ insert(id: string, field: string, location: OperationLocations, target: string): void;
11
11
  remove(id: string, field: string, target: string): void;
12
12
  delete(id: string): void;
13
13
  deleteField(id: string, field: string): void;
@@ -47,7 +47,7 @@ export declare class Layer {
47
47
  removeUndefinedFields(): void;
48
48
  delete(id: string): void;
49
49
  deleteField(id: string, field: string): void;
50
- insert(id: string, field: string, where: OperationLocation, target: string): void;
50
+ insert(id: string, field: string, where: OperationLocations, target: string): void;
51
51
  remove(id: string, field: string, target: string): void;
52
52
  writeLayer(layer: Layer): void;
53
53
  private addFieldOperation;
@@ -71,28 +71,31 @@ type OperationMap = {
71
71
  };
72
72
  type NestedList<_Result = string> = (_Result | null | NestedList<_Result>)[];
73
73
  type InsertOperation = {
74
- kind: OperationKind.insert;
75
- location: OperationLocation;
74
+ kind: 'insert';
75
+ location: OperationLocations;
76
76
  id: string;
77
77
  };
78
78
  type RemoveOperation = {
79
- kind: OperationKind.remove;
79
+ kind: 'remove';
80
80
  id: string;
81
81
  };
82
82
  type DeleteOperation = {
83
- kind: OperationKind.delete;
83
+ kind: 'delete';
84
84
  target: string;
85
85
  };
86
86
  type ListOperation = InsertOperation | RemoveOperation;
87
87
  type Operation = ListOperation | DeleteOperation;
88
- export declare enum OperationLocation {
89
- start = "start",
90
- end = "end"
91
- }
92
- export declare enum OperationKind {
93
- delete = "delete",
94
- insert = "insert",
95
- remove = "remove"
96
- }
88
+ type ValuesOf<Target> = Target[keyof Target];
89
+ export declare const OperationLocation: {
90
+ readonly start: "start";
91
+ readonly end: "end";
92
+ };
93
+ export type OperationLocations = ValuesOf<typeof OperationLocation>;
94
+ export declare const OperationKind: {
95
+ readonly delete: "delete";
96
+ readonly insert: "insert";
97
+ readonly remove: "remove";
98
+ };
99
+ export type OperationKinds = ValuesOf<typeof OperationKind>;
97
100
  export type LayerID = number;
98
101
  export {};
@@ -376,17 +376,15 @@ function isInsertOperation(value) {
376
376
  function isRemoveOperation(value) {
377
377
  return !!value && value.kind === OperationKind.remove;
378
378
  }
379
- var OperationLocation = /* @__PURE__ */ ((OperationLocation2) => {
380
- OperationLocation2["start"] = "start";
381
- OperationLocation2["end"] = "end";
382
- return OperationLocation2;
383
- })(OperationLocation || {});
384
- var OperationKind = /* @__PURE__ */ ((OperationKind2) => {
385
- OperationKind2["delete"] = "delete";
386
- OperationKind2["insert"] = "insert";
387
- OperationKind2["remove"] = "remove";
388
- return OperationKind2;
389
- })(OperationKind || {});
379
+ const OperationLocation = {
380
+ start: "start",
381
+ end: "end"
382
+ };
383
+ const OperationKind = {
384
+ delete: "delete",
385
+ insert: "insert",
386
+ remove: "remove"
387
+ };
390
388
  // Annotate the CommonJS export names for ESM import in node:
391
389
  0 && (module.exports = {
392
390
  InMemoryStorage,
@@ -2,7 +2,7 @@ import type { HoudiniClient } from '.';
2
2
  import type { Layer } from '../cache/storage';
3
3
  import type { ConfigFile } from '../lib/config';
4
4
  import { Writable } from '../lib/store';
5
- import type { CachePolicy, DocumentArtifact, QueryResult, GraphQLObject, SubscriptionSpec } from '../lib/types';
5
+ import type { DocumentArtifact, QueryResult, GraphQLObject, SubscriptionSpec, CachePolicies } from '../lib/types';
6
6
  export declare class DocumentStore<_Data extends GraphQLObject, _Input extends Record<string, any>> extends Writable<QueryResult<_Data, _Input>> {
7
7
  #private;
8
8
  constructor({ artifact, plugins, pipeline, client, cache, initialValue, fetching, }: {
@@ -14,16 +14,7 @@ export declare class DocumentStore<_Data extends GraphQLObject, _Input extends R
14
14
  initialValue?: _Data | null;
15
15
  fetching?: boolean;
16
16
  });
17
- send({ metadata, session, fetch, variables, policy, stuff, cacheParams, setup, }?: {
18
- fetch?: Fetch;
19
- variables?: Record<string, any> | null;
20
- metadata?: App.Metadata | null;
21
- session?: App.Session | null;
22
- policy?: CachePolicy;
23
- stuff?: Partial<App.Stuff>;
24
- cacheParams?: ClientPluginContext['cacheParams'];
25
- setup?: boolean;
26
- }): Promise<QueryResult<_Data, _Input>>;
17
+ send({ metadata, session, fetch, variables, policy, stuff, cacheParams, setup, silenceEcho, }?: SendParams): Promise<QueryResult<_Data, _Input>>;
27
18
  }
28
19
  declare function marshalVariables<_Data extends GraphQLObject, _Input extends {}>(ctx: ClientPluginContext): Record<string, any>;
29
20
  export type ClientPlugin = () => ClientHooks | null | (ClientHooks | ClientPlugin | null)[];
@@ -42,9 +33,9 @@ export type ClientPluginContext = {
42
33
  text: string;
43
34
  hash: string;
44
35
  artifact: DocumentArtifact;
45
- policy?: CachePolicy;
36
+ policy?: CachePolicies;
46
37
  fetch?: Fetch;
47
- variables?: Record<string, any>;
38
+ variables?: Record<string, any> | null;
48
39
  metadata?: App.Metadata | null;
49
40
  session?: App.Session | null;
50
41
  fetchParams?: RequestInit;
@@ -85,4 +76,15 @@ export type ClientPluginExitHandlers = Omit<ClientPluginEnterHandlers, 'resolve'
85
76
  export type ClientPluginErrorHandlers = ClientPluginEnterHandlers & {
86
77
  error: unknown;
87
78
  };
79
+ export type SendParams = {
80
+ fetch?: Fetch;
81
+ variables?: Record<string, any> | null;
82
+ metadata?: App.Metadata | null;
83
+ session?: App.Session | null;
84
+ policy?: CachePolicies;
85
+ stuff?: Partial<App.Stuff>;
86
+ cacheParams?: ClientPluginContext['cacheParams'];
87
+ setup?: boolean;
88
+ silenceEcho?: boolean;
89
+ };
88
90
  export {};
@@ -47,9 +47,7 @@ class DocumentStore extends import_store.Writable {
47
47
  initialValue,
48
48
  fetching
49
49
  }) {
50
- if (fetching === void 0) {
51
- fetching = artifact.kind === import_types.ArtifactKind.Query;
52
- }
50
+ fetching ??= artifact.kind === import_types.ArtifactKind.Query;
53
51
  const initialState = {
54
52
  data: initialValue ?? null,
55
53
  errors: null,
@@ -72,7 +70,7 @@ class DocumentStore extends import_store.Writable {
72
70
  this.#lastVariables = null;
73
71
  this.#configFile = (0, import_config.getCurrentConfig)();
74
72
  this.#plugins = pipeline ?? [
75
- (0, import_plugins.cachePolicyPlugin)({
73
+ (0, import_plugins.cachePolicy)({
76
74
  enabled: cache,
77
75
  setFetching: (fetching2) => this.update((state) => ({ ...state, fetching: fetching2 }))
78
76
  })(),
@@ -87,14 +85,15 @@ class DocumentStore extends import_store.Writable {
87
85
  policy,
88
86
  stuff,
89
87
  cacheParams,
90
- setup = false
88
+ setup = false,
89
+ silenceEcho = false
91
90
  } = {}) {
92
91
  let context = new ClientPluginContextWrapper({
93
92
  config: this.#configFile,
94
93
  text: this.#artifact.raw,
95
94
  hash: this.#artifact.hash,
96
95
  policy: policy ?? this.#artifact.policy,
97
- variables: {},
96
+ variables: null,
98
97
  metadata,
99
98
  session,
100
99
  fetch,
@@ -111,13 +110,14 @@ class DocumentStore extends import_store.Writable {
111
110
  cacheParams
112
111
  });
113
112
  const draft = context.draft();
114
- draft.variables = variables ?? {};
113
+ draft.variables = variables ?? null;
115
114
  context = context.apply(draft, false);
116
115
  return await new Promise((resolve, reject) => {
117
116
  const state = {
118
117
  setup,
119
118
  currentStep: 0,
120
119
  index: 0,
120
+ silenceEcho,
121
121
  promise: {
122
122
  resolved: false,
123
123
  resolve,
@@ -255,6 +255,9 @@ class DocumentStore extends import_store.Writable {
255
255
  }
256
256
  this.#lastContext = ctx.context.draft();
257
257
  this.#lastVariables = this.#lastContext.stuff.inputs.marshaled;
258
+ if (ctx.silenceEcho && finalValue.data === this.state.data) {
259
+ return;
260
+ }
258
261
  this.set(finalValue);
259
262
  }
260
263
  }
@@ -285,7 +288,7 @@ class ClientPluginContextWrapper {
285
288
  ctx.stuff = val;
286
289
  },
287
290
  get variables() {
288
- return ctx.variables ?? {};
291
+ return ctx.variables ?? null;
289
292
  },
290
293
  set variables(val) {
291
294
  Object.assign(ctx, applyVariables(ctx, { variables: val }));
@@ -4,7 +4,7 @@ import type { ClientPlugin, ClientHooks } from './documentStore';
4
4
  import { DocumentStore } from './documentStore';
5
5
  import { type FetchParamFn, type ThrowOnErrorParams } from './plugins';
6
6
  export { DocumentStore, type ClientPlugin } from './documentStore';
7
- export { fetchPlugin, mutationPlugin, queryPlugin, subscriptionPlugin } from './plugins';
7
+ export { fetch, mutation, query, subscription } from './plugins';
8
8
  type ConstructorArgs = {
9
9
  url: string;
10
10
  fetchParams?: FetchParamFn;
@@ -27,10 +27,10 @@ __export(client_exports, {
27
27
  DocumentStore: () => import_documentStore2.DocumentStore,
28
28
  HoudiniClient: () => HoudiniClient,
29
29
  createPluginHooks: () => createPluginHooks,
30
- fetchPlugin: () => import_plugins2.fetchPlugin,
31
- mutationPlugin: () => import_plugins2.mutationPlugin,
32
- queryPlugin: () => import_plugins2.queryPlugin,
33
- subscriptionPlugin: () => import_plugins2.subscriptionPlugin
30
+ fetch: () => import_plugins2.fetch,
31
+ mutation: () => import_plugins2.mutation,
32
+ query: () => import_plugins2.query,
33
+ subscription: () => import_plugins2.subscription
34
34
  });
35
35
  module.exports = __toCommonJS(client_exports);
36
36
  var import_flatten = require("../lib/flatten");
@@ -50,15 +50,15 @@ class HoudiniClient {
50
50
  }
51
51
  this.#plugins = (0, import_flatten.flatten)(
52
52
  [].concat(
53
- throwOnError ? [(0, import_plugins.throwOnErrorPlugin)(throwOnError)] : [],
54
- (0, import_plugins.fetchParamsPlugin)(fetchParams),
53
+ throwOnError ? [(0, import_plugins.throwOnError)(throwOnError)] : [],
54
+ (0, import_plugins.fetchParams)(fetchParams),
55
55
  pipeline ?? [
56
- import_plugins.queryPlugin,
57
- import_plugins.mutationPlugin
56
+ import_plugins.query,
57
+ import_plugins.mutation
58
58
  ].concat(
59
59
  plugins ?? [],
60
60
  import_injectedPlugins.default,
61
- (0, import_plugins.fetchPlugin)()
61
+ (0, import_plugins.fetch)()
62
62
  )
63
63
  )
64
64
  );
@@ -82,6 +82,9 @@ class HoudiniClient {
82
82
  }
83
83
  function createPluginHooks(plugins) {
84
84
  return plugins.reduce((hooks, plugin) => {
85
+ if (typeof plugin !== "function") {
86
+ throw new Error("Encountered client plugin that's not a function");
87
+ }
85
88
  const result = plugin();
86
89
  if (!result) {
87
90
  return hooks;
@@ -106,8 +109,8 @@ function createPluginHooks(plugins) {
106
109
  DocumentStore,
107
110
  HoudiniClient,
108
111
  createPluginHooks,
109
- fetchPlugin,
110
- mutationPlugin,
111
- queryPlugin,
112
- subscriptionPlugin
112
+ fetch,
113
+ mutation,
114
+ query,
115
+ subscription
113
116
  });