houdini 1.0.0-next.2 → 1.0.0-next.21

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 (195) hide show
  1. package/README.md +4 -1
  2. package/build/cmd-cjs/index.js +5366 -2772
  3. package/build/cmd-esm/index.js +5340 -2746
  4. package/build/codegen/generators/artifacts/index.d.ts +2 -2
  5. package/build/codegen/generators/artifacts/indexFile.d.ts +2 -2
  6. package/build/codegen/generators/artifacts/selection.d.ts +5 -5
  7. package/build/codegen/generators/artifacts/utils.d.ts +0 -1
  8. package/build/codegen/generators/indexFile/index.d.ts +2 -2
  9. package/build/codegen/generators/persistedQueries/index.d.ts +2 -2
  10. package/build/codegen/generators/runtime/graphqlFunction.d.ts +2 -2
  11. package/build/codegen/generators/runtime/index.d.ts +2 -2
  12. package/build/codegen/generators/runtime/runtimeConfig.d.ts +7 -0
  13. package/build/codegen/generators/typescript/documentTypes.d.ts +2 -0
  14. package/build/codegen/generators/typescript/imperativeTypeDef.d.ts +2 -0
  15. package/build/codegen/generators/typescript/index.d.ts +2 -2
  16. package/build/codegen/generators/typescript/typeReference.d.ts +4 -2
  17. package/build/codegen/generators/typescript/types.d.ts +0 -1
  18. package/build/codegen/index.d.ts +2 -2
  19. package/build/codegen/transforms/addID.d.ts +2 -2
  20. package/build/codegen/transforms/composeQueries.d.ts +4 -4
  21. package/build/codegen/transforms/fragmentVariables.d.ts +3 -2
  22. package/build/codegen/transforms/list.d.ts +2 -2
  23. package/build/codegen/transforms/paginate.d.ts +2 -2
  24. package/build/codegen/transforms/schema.d.ts +2 -2
  25. package/build/codegen/transforms/typename.d.ts +2 -2
  26. package/build/codegen/utils/flattenSelections.d.ts +1 -1
  27. package/build/codegen/validators/noIDAlias.d.ts +2 -2
  28. package/build/codegen/validators/plugins.d.ts +2 -2
  29. package/build/codegen/validators/typeCheck.d.ts +2 -2
  30. package/build/codegen/validators/uniqueNames.d.ts +2 -2
  31. package/build/codegen-cjs/index.js +4694 -2137
  32. package/build/codegen-esm/index.js +4682 -2125
  33. package/build/lib/config.d.ts +15 -96
  34. package/build/lib/deepMerge.d.ts +1 -0
  35. package/build/lib/graphql.d.ts +5 -2
  36. package/build/lib/index.d.ts +2 -0
  37. package/build/lib/path.d.ts +1 -1
  38. package/build/lib/pipeline.d.ts +1 -1
  39. package/build/lib/plugin.d.ts +2 -0
  40. package/build/lib/types.d.ts +257 -6
  41. package/build/lib/walk.d.ts +4 -1
  42. package/build/lib-cjs/index.js +4108 -928
  43. package/build/lib-esm/index.js +4078 -907
  44. package/build/runtime/cache/cache.d.ts +28 -11
  45. package/build/runtime/cache/lists.d.ts +1 -0
  46. package/build/runtime/cache/staleManager.d.ts +30 -0
  47. package/build/runtime/cache/storage.d.ts +23 -20
  48. package/build/runtime/cache/stuff.d.ts +0 -2
  49. package/build/runtime/cache/subscription.d.ts +2 -1
  50. package/build/runtime/client/documentStore.d.ts +20 -17
  51. package/build/runtime/client/index.d.ts +13 -11
  52. package/build/runtime/client/plugins/cache.d.ts +1 -1
  53. package/build/runtime/client/plugins/fetch.d.ts +1 -1
  54. package/build/runtime/client/plugins/fetchParams.d.ts +2 -2
  55. package/build/runtime/client/plugins/injectedPlugins.d.ts +2 -1
  56. package/build/runtime/client/plugins/mutation.d.ts +1 -1
  57. package/build/runtime/client/plugins/query.d.ts +1 -1
  58. package/build/runtime/client/plugins/subscription.d.ts +2 -3
  59. package/build/runtime/client/plugins/throwOnError.d.ts +1 -1
  60. package/build/runtime/client/utils/documentPlugins.d.ts +3 -3
  61. package/build/runtime/generated.d.ts +1 -0
  62. package/build/runtime/imports/pluginConfig.d.ts +3 -0
  63. package/build/runtime/index.d.ts +1 -1
  64. package/build/runtime/lib/config.d.ts +27 -24
  65. package/build/runtime/lib/flatten.d.ts +2 -0
  66. package/build/runtime/lib/index.d.ts +1 -0
  67. package/build/runtime/lib/key.d.ts +6 -0
  68. package/build/runtime/lib/scalars.d.ts +3 -3
  69. package/build/runtime/lib/types.d.ts +47 -47
  70. package/build/runtime/public/cache.d.ts +26 -6
  71. package/build/runtime/public/record.d.ts +26 -17
  72. package/build/runtime/public/tests/test.d.ts +52 -10
  73. package/build/runtime/public/types.d.ts +8 -0
  74. package/build/runtime-cjs/cache/cache.d.ts +28 -11
  75. package/build/runtime-cjs/cache/cache.js +97 -22
  76. package/build/runtime-cjs/cache/gc.js +9 -0
  77. package/build/runtime-cjs/cache/lists.d.ts +1 -0
  78. package/build/runtime-cjs/cache/lists.js +9 -6
  79. package/build/runtime-cjs/cache/staleManager.d.ts +30 -0
  80. package/build/runtime-cjs/cache/staleManager.js +95 -0
  81. package/build/runtime-cjs/cache/storage.d.ts +23 -20
  82. package/build/runtime-cjs/cache/storage.js +11 -13
  83. package/build/runtime-cjs/cache/stuff.d.ts +0 -2
  84. package/build/runtime-cjs/cache/stuff.js +2 -19
  85. package/build/runtime-cjs/cache/subscription.d.ts +2 -1
  86. package/build/runtime-cjs/cache/subscription.js +11 -7
  87. package/build/runtime-cjs/client/documentStore.d.ts +20 -17
  88. package/build/runtime-cjs/client/documentStore.js +13 -9
  89. package/build/runtime-cjs/client/index.d.ts +13 -11
  90. package/build/runtime-cjs/client/index.js +48 -19
  91. package/build/runtime-cjs/client/plugins/cache.d.ts +1 -1
  92. package/build/runtime-cjs/client/plugins/cache.js +12 -10
  93. package/build/runtime-cjs/client/plugins/fetch.d.ts +1 -1
  94. package/build/runtime-cjs/client/plugins/fetch.js +10 -9
  95. package/build/runtime-cjs/client/plugins/fetchParams.d.ts +2 -2
  96. package/build/runtime-cjs/client/plugins/fetchParams.js +9 -4
  97. package/build/runtime-cjs/client/plugins/injectedPlugins.d.ts +2 -1
  98. package/build/runtime-cjs/client/plugins/mutation.d.ts +1 -1
  99. package/build/runtime-cjs/client/plugins/mutation.js +3 -3
  100. package/build/runtime-cjs/client/plugins/query.d.ts +1 -1
  101. package/build/runtime-cjs/client/plugins/query.js +5 -5
  102. package/build/runtime-cjs/client/plugins/subscription.d.ts +2 -3
  103. package/build/runtime-cjs/client/plugins/subscription.js +7 -5
  104. package/build/runtime-cjs/client/plugins/throwOnError.d.ts +1 -1
  105. package/build/runtime-cjs/client/plugins/throwOnError.js +3 -3
  106. package/build/runtime-cjs/client/utils/documentPlugins.d.ts +3 -3
  107. package/build/runtime-cjs/generated.d.ts +1 -0
  108. package/build/runtime-cjs/imports/pluginConfig.d.ts +3 -0
  109. package/build/runtime-cjs/imports/pluginConfig.js +27 -0
  110. package/build/runtime-cjs/index.d.ts +1 -1
  111. package/build/runtime-cjs/lib/config.d.ts +27 -24
  112. package/build/runtime-cjs/lib/config.js +11 -1
  113. package/build/runtime-cjs/lib/flatten.d.ts +2 -0
  114. package/build/runtime-cjs/lib/flatten.js +41 -0
  115. package/build/runtime-cjs/lib/index.d.ts +1 -0
  116. package/build/runtime-cjs/lib/index.js +1 -0
  117. package/build/runtime-cjs/lib/key.d.ts +6 -0
  118. package/build/runtime-cjs/lib/key.js +41 -0
  119. package/build/runtime-cjs/lib/scalars.d.ts +3 -3
  120. package/build/runtime-cjs/lib/scalars.js +13 -2
  121. package/build/runtime-cjs/lib/types.d.ts +47 -47
  122. package/build/runtime-cjs/lib/types.js +26 -30
  123. package/build/runtime-cjs/public/cache.d.ts +26 -6
  124. package/build/runtime-cjs/public/cache.js +32 -32
  125. package/build/runtime-cjs/public/list.js +6 -28
  126. package/build/runtime-cjs/public/record.d.ts +26 -17
  127. package/build/runtime-cjs/public/record.js +27 -187
  128. package/build/runtime-cjs/public/tests/test.d.ts +52 -10
  129. package/build/runtime-cjs/public/tests/test.js +27 -2
  130. package/build/runtime-cjs/public/types.d.ts +8 -0
  131. package/build/runtime-esm/cache/cache.d.ts +28 -11
  132. package/build/runtime-esm/cache/cache.js +99 -24
  133. package/build/runtime-esm/cache/gc.js +9 -0
  134. package/build/runtime-esm/cache/lists.d.ts +1 -0
  135. package/build/runtime-esm/cache/lists.js +9 -6
  136. package/build/runtime-esm/cache/staleManager.d.ts +30 -0
  137. package/build/runtime-esm/cache/staleManager.js +71 -0
  138. package/build/runtime-esm/cache/storage.d.ts +23 -20
  139. package/build/runtime-esm/cache/storage.js +11 -13
  140. package/build/runtime-esm/cache/stuff.d.ts +0 -2
  141. package/build/runtime-esm/cache/stuff.js +1 -17
  142. package/build/runtime-esm/cache/subscription.d.ts +2 -1
  143. package/build/runtime-esm/cache/subscription.js +12 -8
  144. package/build/runtime-esm/client/documentStore.d.ts +20 -17
  145. package/build/runtime-esm/client/documentStore.js +14 -10
  146. package/build/runtime-esm/client/index.d.ts +13 -11
  147. package/build/runtime-esm/client/index.js +49 -21
  148. package/build/runtime-esm/client/plugins/cache.d.ts +1 -1
  149. package/build/runtime-esm/client/plugins/cache.js +11 -9
  150. package/build/runtime-esm/client/plugins/fetch.d.ts +1 -1
  151. package/build/runtime-esm/client/plugins/fetch.js +9 -8
  152. package/build/runtime-esm/client/plugins/fetchParams.d.ts +2 -2
  153. package/build/runtime-esm/client/plugins/fetchParams.js +8 -3
  154. package/build/runtime-esm/client/plugins/injectedPlugins.d.ts +2 -1
  155. package/build/runtime-esm/client/plugins/mutation.d.ts +1 -1
  156. package/build/runtime-esm/client/plugins/mutation.js +2 -2
  157. package/build/runtime-esm/client/plugins/query.d.ts +1 -1
  158. package/build/runtime-esm/client/plugins/query.js +4 -4
  159. package/build/runtime-esm/client/plugins/subscription.d.ts +2 -3
  160. package/build/runtime-esm/client/plugins/subscription.js +6 -4
  161. package/build/runtime-esm/client/plugins/throwOnError.d.ts +1 -1
  162. package/build/runtime-esm/client/plugins/throwOnError.js +2 -2
  163. package/build/runtime-esm/client/utils/documentPlugins.d.ts +3 -3
  164. package/build/runtime-esm/generated.d.ts +1 -0
  165. package/build/runtime-esm/imports/pluginConfig.d.ts +3 -0
  166. package/build/runtime-esm/imports/pluginConfig.js +5 -0
  167. package/build/runtime-esm/index.d.ts +1 -1
  168. package/build/runtime-esm/lib/config.d.ts +27 -24
  169. package/build/runtime-esm/lib/config.js +11 -1
  170. package/build/runtime-esm/lib/flatten.d.ts +2 -0
  171. package/build/runtime-esm/lib/flatten.js +17 -0
  172. package/build/runtime-esm/lib/index.d.ts +1 -0
  173. package/build/runtime-esm/lib/index.js +1 -0
  174. package/build/runtime-esm/lib/key.d.ts +6 -0
  175. package/build/runtime-esm/lib/key.js +17 -0
  176. package/build/runtime-esm/lib/scalars.d.ts +3 -3
  177. package/build/runtime-esm/lib/scalars.js +13 -2
  178. package/build/runtime-esm/lib/types.d.ts +47 -47
  179. package/build/runtime-esm/lib/types.js +26 -30
  180. package/build/runtime-esm/public/cache.d.ts +26 -6
  181. package/build/runtime-esm/public/cache.js +31 -30
  182. package/build/runtime-esm/public/list.js +6 -28
  183. package/build/runtime-esm/public/record.d.ts +26 -17
  184. package/build/runtime-esm/public/record.js +26 -183
  185. package/build/runtime-esm/public/tests/test.d.ts +52 -10
  186. package/build/runtime-esm/public/tests/test.js +26 -1
  187. package/build/runtime-esm/public/types.d.ts +8 -0
  188. package/build/test/index.d.ts +3 -3
  189. package/build/test-cjs/index.js +5007 -2465
  190. package/build/test-esm/index.js +4995 -2453
  191. package/build/vite/houdini.d.ts +2 -0
  192. package/build/vite-cjs/index.js +5344 -2744
  193. package/build/vite-esm/index.js +5319 -2719
  194. package/package.json +6 -5
  195. package/build/codegen/generators/typescript/imperativeCache.d.ts +0 -2
@@ -118,6 +118,9 @@ function isScalar(config, type) {
118
118
  return ["String", "Boolean", "Float", "ID", "Int"].concat(Object.keys(config.scalars || {})).includes(type);
119
119
  }
120
120
  function parseScalar(config, type, value) {
121
+ if (typeof value === "undefined") {
122
+ return void 0;
123
+ }
121
124
  if (type === "Boolean") {
122
125
  return value === "true";
123
126
  }
@@ -128,10 +131,18 @@ function parseScalar(config, type, value) {
128
131
  return value;
129
132
  }
130
133
  if (type === "Int") {
131
- return parseInt(value, 10);
134
+ const result = parseInt(value, 10);
135
+ if (Number.isNaN(result)) {
136
+ return void 0;
137
+ }
138
+ return result;
132
139
  }
133
140
  if (type === "Float") {
134
- return parseFloat(value);
141
+ const result = parseFloat(value);
142
+ if (Number.isNaN(result)) {
143
+ return void 0;
144
+ }
145
+ return result;
135
146
  }
136
147
  if (config.scalars?.[type]?.marshal) {
137
148
  return config.scalars[type]?.marshal(value);
@@ -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,49 +31,44 @@ 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;
71
69
  rootType: string;
72
70
  input?: InputObject;
73
71
  refetch?: {
74
- update: RefetchUpdateMode;
75
72
  path: string[];
76
73
  method: 'cursor' | 'offset';
77
74
  pageSize: number;
@@ -79,9 +76,9 @@ export type BaseCompiledDocument = {
79
76
  embedded: boolean;
80
77
  targetType: string;
81
78
  paginated: boolean;
82
- direction?: 'forward' | 'backwards';
79
+ direction: 'forward' | 'backward' | 'both';
83
80
  };
84
- pluginsData?: Record<string, any>;
81
+ pluginData?: Record<string, any>;
85
82
  };
86
83
  export type HoudiniFetchContext = {
87
84
  variables: () => {};
@@ -93,20 +90,21 @@ export type ListWhen = {
93
90
  must?: Filter;
94
91
  must_not?: Filter;
95
92
  };
96
- export declare enum DataSource {
93
+ export declare const DataSource: {
97
94
  /**
98
95
  * from the browser cache
99
96
  */
100
- Cache = "cache",
97
+ readonly Cache: "cache";
101
98
  /**
102
99
  * from a browser side `fetch`
103
100
  */
104
- Network = "network",
101
+ readonly Network: "network";
105
102
  /**
106
103
  * from a server side `fetch`
107
104
  */
108
- Ssr = "ssr"
109
- }
105
+ readonly Ssr: "ssr";
106
+ };
107
+ export type DataSources = ValuesOf<typeof DataSource>;
110
108
  export type MutationOperation = {
111
109
  action: 'insert' | 'remove' | 'delete' | 'toggle';
112
110
  list?: string;
@@ -135,7 +133,7 @@ export type SubscriptionSelection = {
135
133
  connection: boolean;
136
134
  type: string;
137
135
  };
138
- update?: RefetchUpdateMode;
136
+ updates?: string[];
139
137
  filters?: {
140
138
  [key: string]: {
141
139
  kind: 'Boolean' | 'String' | 'Float' | 'Int' | 'Variable';
@@ -164,8 +162,7 @@ export type SubscriptionSpec = {
164
162
  };
165
163
  export type FetchQueryResult<_Data> = {
166
164
  result: RequestPayload<_Data | null>;
167
- source: DataSource | null;
168
- partial: boolean;
165
+ source: DataSources | null;
169
166
  };
170
167
  export type QueryResult<_Data = GraphQLObject, _Input = Record<string, any>> = {
171
168
  data: _Data | null;
@@ -174,8 +171,9 @@ export type QueryResult<_Data = GraphQLObject, _Input = Record<string, any>> = {
174
171
  }[] | null;
175
172
  fetching: boolean;
176
173
  partial: boolean;
177
- source: DataSource | null;
178
- variables: _Input | null;
174
+ stale: boolean;
175
+ source: DataSources | null;
176
+ variables: _Input | {};
179
177
  };
180
178
  export type RequestPayload<GraphQLObject = any> = {
181
179
  data: GraphQLObject | null;
@@ -183,4 +181,6 @@ export type RequestPayload<GraphQLObject = any> = {
183
181
  message: string;
184
182
  }[] | null;
185
183
  };
184
+ export type NestedList<_Result = string> = (_Result | null | NestedList<_Result>)[];
185
+ export type ValueOf<Parent> = Parent[keyof Parent];
186
186
  export {};
@@ -1,33 +1,29 @@
1
- var CachePolicy = /* @__PURE__ */ ((CachePolicy2) => {
2
- CachePolicy2["CacheOrNetwork"] = "CacheOrNetwork";
3
- CachePolicy2["CacheOnly"] = "CacheOnly";
4
- CachePolicy2["NetworkOnly"] = "NetworkOnly";
5
- CachePolicy2["CacheAndNetwork"] = "CacheAndNetwork";
6
- return CachePolicy2;
7
- })(CachePolicy || {});
8
- var ArtifactKind = /* @__PURE__ */ ((ArtifactKind2) => {
9
- ArtifactKind2["Query"] = "HoudiniQuery";
10
- ArtifactKind2["Subscription"] = "HoudiniSubscription";
11
- ArtifactKind2["Mutation"] = "HoudiniMutation";
12
- ArtifactKind2["Fragment"] = "HoudiniFragment";
13
- return ArtifactKind2;
14
- })(ArtifactKind || {});
15
- const CompiledFragmentKind = "HoudiniFragment" /* Fragment */;
16
- const CompiledMutationKind = "HoudiniMutation" /* Mutation */;
17
- const CompiledQueryKind = "HoudiniQuery" /* Query */;
18
- const CompiledSubscriptionKind = "HoudiniSubscription" /* Subscription */;
19
- var RefetchUpdateMode = /* @__PURE__ */ ((RefetchUpdateMode2) => {
20
- RefetchUpdateMode2["append"] = "append";
21
- RefetchUpdateMode2["prepend"] = "prepend";
22
- RefetchUpdateMode2["replace"] = "replace";
23
- return RefetchUpdateMode2;
24
- })(RefetchUpdateMode || {});
25
- var DataSource = /* @__PURE__ */ ((DataSource2) => {
26
- DataSource2["Cache"] = "cache";
27
- DataSource2["Network"] = "network";
28
- DataSource2["Ssr"] = "ssr";
29
- return DataSource2;
30
- })(DataSource || {});
1
+ const CachePolicy = {
2
+ CacheOrNetwork: "CacheOrNetwork",
3
+ CacheOnly: "CacheOnly",
4
+ NetworkOnly: "NetworkOnly",
5
+ CacheAndNetwork: "CacheAndNetwork"
6
+ };
7
+ const ArtifactKind = {
8
+ Query: "HoudiniQuery",
9
+ Subscription: "HoudiniSubscription",
10
+ Mutation: "HoudiniMutation",
11
+ Fragment: "HoudiniFragment"
12
+ };
13
+ const CompiledFragmentKind = ArtifactKind.Fragment;
14
+ const CompiledMutationKind = ArtifactKind.Mutation;
15
+ const CompiledQueryKind = ArtifactKind.Query;
16
+ const CompiledSubscriptionKind = ArtifactKind.Subscription;
17
+ const RefetchUpdateMode = {
18
+ append: "append",
19
+ prepend: "prepend",
20
+ replace: "replace"
21
+ };
22
+ const DataSource = {
23
+ Cache: "cache",
24
+ Network: "network",
25
+ Ssr: "ssr"
26
+ };
31
27
  export {
32
28
  ArtifactKind,
33
29
  CachePolicy,
@@ -1,19 +1,39 @@
1
1
  import type { Cache as _Cache } from '../cache/cache';
2
- import type { SchemaManager, TypeInfo } from '../cache/schema';
2
+ import { type QueryArtifact } from '../lib';
3
3
  import { ListCollection } from './list';
4
4
  import { Record } from './record';
5
- import type { CacheTypeDef, IDFields, TypeNames, ValidLists } from './types';
5
+ import type { ArgType, CacheTypeDef, IDFields, QueryInput, QueryList, QueryValue, TypeFieldNames, TypeNames, ValidLists } from './types';
6
6
  export declare class Cache<Def extends CacheTypeDef> {
7
7
  _internal_unstable: _Cache;
8
8
  constructor(cache: _Cache);
9
9
  validateInstabilityWarning(): void;
10
- setFieldType(...args: Parameters<SchemaManager['setFieldType']>): void;
11
- get root(): Record<Def, '__ROOT__'>;
12
10
  get<T extends TypeNames<Def>>(type: T, data: IDFields<Def, T>): Record<Def, T>;
13
- get config(): import("..").ConfigFile;
11
+ get config(): import("../lib").ConfigFile;
14
12
  list<Name extends ValidLists<Def>>(name: Name, { parentID, allLists }?: {
15
13
  parentID?: string;
16
14
  allLists?: boolean;
17
15
  }): ListCollection<Def, Name>;
16
+ read<_Query extends {
17
+ artifact: QueryArtifact;
18
+ }>({ query, variables, }: {
19
+ query: _Query;
20
+ variables?: QueryInput<QueryList<Def>, _Query>;
21
+ }): {
22
+ data: QueryValue<QueryList<Def>, _Query> | null;
23
+ partial: boolean;
24
+ };
25
+ write<_Query extends {
26
+ artifact: QueryArtifact;
27
+ }>({ query, variables, data, }: {
28
+ query: _Query;
29
+ data: QueryValue<QueryList<Def>, _Query>;
30
+ variables?: QueryInput<QueryList<Def>, _Query>;
31
+ }): void;
32
+ /**
33
+ * Mark some elements of the cache stale.
34
+ */
35
+ markStale<_Type extends TypeNames<Def>, _Field extends TypeFieldNames<Def, _Type>>(type?: _Type, options?: {
36
+ field?: _Field;
37
+ when?: ArgType<Def, _Type, _Field>;
38
+ }): void;
18
39
  }
19
- export declare function _typeInfo<Def extends CacheTypeDef>(cache: Cache<Def>, type: string, field: string): TypeInfo;
@@ -1,4 +1,4 @@
1
- import { rootID } from "../cache/cache";
1
+ import { marshalInputs } from "../lib";
2
2
  import { ListCollection } from "./list";
3
3
  import { Record } from "./record";
4
4
  class Cache {
@@ -12,19 +12,6 @@ class Cache {
12
12
  Please acknowledge this by setting acceptImperativeInstability to true in your config file.`);
13
13
  }
14
14
  }
15
- setFieldType(...args) {
16
- this.validateInstabilityWarning();
17
- this._internal_unstable._internal_unstable.schema.setFieldType(...args);
18
- }
19
- get root() {
20
- this.validateInstabilityWarning();
21
- return new Record({
22
- cache: this,
23
- type: "Query",
24
- id: rootID,
25
- idFields: {}
26
- });
27
- }
28
15
  get(type, data) {
29
16
  this.validateInstabilityWarning();
30
17
  let recordID = this._internal_unstable._internal_unstable.id(type, data);
@@ -42,6 +29,7 @@ Please acknowledge this by setting acceptImperativeInstability to true in your c
42
29
  return this._internal_unstable._internal_unstable.config;
43
30
  }
44
31
  list(name, { parentID, allLists } = {}) {
32
+ this.validateInstabilityWarning();
45
33
  return new ListCollection({
46
34
  cache: this,
47
35
  name,
@@ -49,24 +37,37 @@ Please acknowledge this by setting acceptImperativeInstability to true in your c
49
37
  allLists
50
38
  });
51
39
  }
52
- }
53
- function _typeInfo(cache, type, field) {
54
- if (field === "__typename") {
55
- return {
56
- type: "String",
57
- nullable: false,
58
- link: false
59
- };
40
+ read({
41
+ query,
42
+ variables
43
+ }) {
44
+ this.validateInstabilityWarning();
45
+ return this._internal_unstable.read({
46
+ selection: query.artifact.selection,
47
+ variables
48
+ });
49
+ }
50
+ write({
51
+ query,
52
+ variables,
53
+ data
54
+ }) {
55
+ this.validateInstabilityWarning();
56
+ this._internal_unstable.write({
57
+ selection: query.artifact.selection,
58
+ data,
59
+ variables: marshalInputs({
60
+ config: this.config,
61
+ artifact: query.artifact,
62
+ input: variables
63
+ }) ?? {}
64
+ });
65
+ return;
60
66
  }
61
- const info = cache._internal_unstable._internal_unstable.schema.fieldType(type, field);
62
- if (!info) {
63
- throw new Error(
64
- `Unknown field: ${field} for type ${type}. Please provide type information using setFieldType().`
65
- );
67
+ markStale(type, options) {
68
+ return this._internal_unstable.markTypeStale(type ? { ...options, type } : void 0);
66
69
  }
67
- return info;
68
70
  }
69
71
  export {
70
- Cache,
71
- _typeInfo
72
+ Cache
72
73
  };
@@ -1,5 +1,3 @@
1
- import { keyFieldsForType } from "../lib/config";
2
- import { _typeInfo } from "./cache";
3
1
  import { Record } from "./record";
4
2
  class ListCollection {
5
3
  #parentID;
@@ -60,7 +58,7 @@ class ListCollection {
60
58
  return new ListCollection({
61
59
  parentID: this.#parentID,
62
60
  allLists: this.#allLists,
63
- when: this.#when,
61
+ when: filter,
64
62
  cache: this.#cache,
65
63
  name: this.#name
66
64
  });
@@ -96,36 +94,16 @@ class ListCollection {
96
94
  }
97
95
  }
98
96
  #listOperationPayload(records) {
99
- const selection = {
100
- abstractFields: {
101
- fields: {},
102
- typeMap: {}
103
- }
104
- };
97
+ let selection = this.#collection.selection;
98
+ const connectionSelection = selection.fields?.["edges"]?.selection?.fields?.node.selection;
99
+ if (connectionSelection) {
100
+ selection = connectionSelection;
101
+ }
105
102
  const data = [];
106
103
  for (const record of records) {
107
104
  if (!(record instanceof Record)) {
108
105
  throw new Error("You must provide a Record to a list operation");
109
106
  }
110
- const keys = keyFieldsForType(this.#cache.config, record.type);
111
- selection.abstractFields.fields[record.type] = keys.reduce(
112
- (acc, key) => {
113
- const keyInfo = _typeInfo(this.#cache, record.type, key);
114
- return {
115
- ...acc,
116
- [key]: {
117
- type: keyInfo.type,
118
- keyRaw: key
119
- }
120
- };
121
- },
122
- {
123
- __typename: {
124
- type: "String",
125
- keyRaw: "__typename"
126
- }
127
- }
128
- );
129
107
  data.push({ __typename: record.type, ...record.idFields });
130
108
  }
131
109
  return {
@@ -1,5 +1,6 @@
1
+ import type { FragmentArtifact } from '../lib/types';
1
2
  import type { Cache } from './cache';
2
- import type { ArgType, CacheTypeDef, FieldType, TypeFieldNames, ValidTypes } from './types';
3
+ import type { ArgType, CacheTypeDef, FragmentList, FragmentValue, FragmentVariables, TypeFieldNames, ValidTypes } from './types';
3
4
  export declare class Record<Def extends CacheTypeDef, Type extends ValidTypes<Def>> {
4
5
  #private;
5
6
  type: string;
@@ -10,22 +11,30 @@ export declare class Record<Def extends CacheTypeDef, Type extends ValidTypes<De
10
11
  idFields: {};
11
12
  id: string;
12
13
  });
13
- set<Field extends TypeFieldNames<Def, Type>>({ field, args, value, }: {
14
- field: Field;
15
- args?: ArgType<Def, Type, Field>;
16
- value: FieldType<Def, Type, Field>;
14
+ read<_Fragment extends {
15
+ artifact: FragmentArtifact;
16
+ }>({ fragment, variables, }: {
17
+ fragment: _Fragment;
18
+ variables?: FragmentVariables<FragmentList<Def, Type>, _Fragment>;
19
+ }): {
20
+ data: FragmentValue<FragmentList<Def, Type>, _Fragment> | null;
21
+ partial: boolean;
22
+ };
23
+ write<_Fragment extends {
24
+ artifact: FragmentArtifact;
25
+ }, _Variable>(args: {
26
+ fragment: _Fragment;
27
+ data: FragmentValue<FragmentList<Def, Type>, _Fragment>;
28
+ variables?: FragmentVariables<FragmentList<Def, Type>, _Fragment>;
29
+ forceStale?: boolean;
17
30
  }): void;
18
- get<Field extends TypeFieldNames<Def, Type>>({ field, args, }: {
19
- field: Field;
20
- args?: ArgType<Def, Type, Field>;
21
- }): FieldType<Def, Type, Field>;
22
31
  delete(): void;
32
+ /**
33
+ * Mark some elements of the record stale in the cache.
34
+ * @param field
35
+ * @param when
36
+ */
37
+ markStale<Field extends TypeFieldNames<Def, Type>>(field?: Field, { when, }?: {
38
+ when?: ArgType<Def, Type, Field>;
39
+ }): void;
23
40
  }
24
- export declare function computeKey({ field, args }: {
25
- field: string;
26
- args?: {
27
- [key: string]: any;
28
- };
29
- }): string;
30
- export declare const stringifyObjectWithNoQuotesOnKeys: (obj_from_json: {}) => string;
31
- export declare function marshalNestedList(list: any[]): any[];