houdini 1.0.0-next.0 → 1.0.0-next.2

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 (213) hide show
  1. package/build/cmd/generate.d.ts +0 -1
  2. package/build/cmd-cjs/index.js +409 -2066
  3. package/build/cmd-esm/index.js +409 -2066
  4. package/build/codegen/generators/artifacts/fieldKey.d.ts +1 -1
  5. package/build/codegen/generators/artifacts/index.d.ts +1 -1
  6. package/build/codegen/generators/artifacts/indexFile.d.ts +1 -1
  7. package/build/codegen/generators/artifacts/inputs.d.ts +2 -2
  8. package/build/codegen/generators/artifacts/operations.d.ts +2 -2
  9. package/build/codegen/generators/artifacts/selection.d.ts +1 -1
  10. package/build/codegen/generators/artifacts/utils.d.ts +1 -1
  11. package/build/codegen/generators/definitions/enums.d.ts +1 -1
  12. package/build/codegen/generators/definitions/index.d.ts +1 -1
  13. package/build/codegen/generators/indexFile/index.d.ts +1 -1
  14. package/build/codegen/generators/persistedQueries/index.d.ts +1 -1
  15. package/build/codegen/generators/runtime/graphqlFunction.d.ts +2 -0
  16. package/build/codegen/generators/runtime/index.d.ts +1 -1
  17. package/build/codegen/generators/runtime/injectPlugins.d.ts +7 -0
  18. package/build/codegen/generators/runtime/pluginIndex.d.ts +5 -0
  19. package/build/codegen/generators/typescript/addReferencedInputTypes.d.ts +1 -1
  20. package/build/codegen/generators/typescript/imperativeCache.d.ts +1 -1
  21. package/build/codegen/generators/typescript/index.d.ts +1 -1
  22. package/build/codegen/generators/typescript/inlineType.d.ts +1 -1
  23. package/build/codegen/generators/typescript/typeReference.d.ts +1 -1
  24. package/build/codegen/generators/typescript/types.d.ts +1 -1
  25. package/build/codegen/index.d.ts +1 -1
  26. package/build/codegen/transforms/addID.d.ts +1 -1
  27. package/build/codegen/transforms/composeQueries.d.ts +2 -2
  28. package/build/codegen/transforms/fragmentVariables.d.ts +2 -2
  29. package/build/codegen/transforms/list.d.ts +1 -1
  30. package/build/codegen/transforms/paginate.d.ts +1 -1
  31. package/build/codegen/transforms/schema.d.ts +1 -1
  32. package/build/codegen/transforms/typename.d.ts +1 -1
  33. package/build/codegen/utils/commonjs.d.ts +2 -0
  34. package/build/codegen/utils/flattenSelections.d.ts +2 -2
  35. package/build/codegen/utils/moduleExport.d.ts +1 -1
  36. package/build/codegen/utils/objectIdentificationSelection.d.ts +1 -1
  37. package/build/codegen/validators/noIDAlias.d.ts +1 -1
  38. package/build/codegen/validators/typeCheck.d.ts +1 -1
  39. package/build/codegen-cjs/index.js +330 -1977
  40. package/build/codegen-esm/index.js +330 -1977
  41. package/build/lib/config.d.ts +8 -3
  42. package/build/lib/fs.d.ts +1 -1
  43. package/build/lib/graphql.d.ts +1 -1
  44. package/build/lib/imports.d.ts +1 -1
  45. package/build/lib/types.d.ts +3 -3
  46. package/build/lib/walk.d.ts +4 -4
  47. package/build/lib-cjs/index.js +145 -1846
  48. package/build/lib-esm/index.js +145 -1846
  49. package/build/runtime/cache/cache.d.ts +10 -8
  50. package/build/runtime/cache/gc.d.ts +1 -1
  51. package/build/runtime/cache/lists.d.ts +2 -2
  52. package/build/runtime/cache/schema.d.ts +2 -2
  53. package/build/runtime/cache/stuff.d.ts +2 -2
  54. package/build/runtime/cache/subscription.d.ts +19 -11
  55. package/build/runtime/client/documentStore.d.ts +87 -0
  56. package/build/runtime/client/index.d.ts +25 -0
  57. package/build/runtime/client/plugins/cache.d.ts +8 -0
  58. package/build/runtime/client/plugins/fetch.d.ts +37 -0
  59. package/build/runtime/client/plugins/fetchParams.d.ts +9 -0
  60. package/build/runtime/client/plugins/index.d.ts +7 -0
  61. package/build/runtime/client/plugins/injectedPlugins.d.ts +3 -0
  62. package/build/runtime/client/plugins/mutation.d.ts +1 -0
  63. package/build/runtime/client/plugins/query.d.ts +2 -0
  64. package/build/runtime/client/plugins/subscription.d.ts +18 -0
  65. package/build/runtime/client/plugins/throwOnError.d.ts +7 -0
  66. package/build/runtime/client/utils/documentPlugins.d.ts +3 -0
  67. package/build/runtime/client/utils/index.d.ts +1 -0
  68. package/build/runtime/imports/config.d.ts +3 -0
  69. package/build/runtime/index.d.ts +2 -1
  70. package/build/runtime/lib/config.d.ts +5 -3
  71. package/build/runtime/lib/index.d.ts +1 -2
  72. package/build/runtime/lib/scalars.d.ts +5 -4
  73. package/build/runtime/lib/selection.d.ts +1 -1
  74. package/build/runtime/lib/store.d.ts +19 -0
  75. package/build/runtime/lib/types.d.ts +22 -9
  76. package/build/runtime/public/cache.d.ts +2 -2
  77. package/build/runtime/public/list.d.ts +2 -2
  78. package/build/runtime/public/record.d.ts +1 -1
  79. package/build/runtime/public/tests/test.d.ts +1 -1
  80. package/build/runtime-cjs/cache/cache.d.ts +10 -8
  81. package/build/runtime-cjs/cache/cache.js +5 -11
  82. package/build/runtime-cjs/cache/gc.d.ts +1 -1
  83. package/build/runtime-cjs/cache/lists.d.ts +2 -2
  84. package/build/runtime-cjs/cache/lists.js +2 -2
  85. package/build/runtime-cjs/cache/schema.d.ts +2 -2
  86. package/build/runtime-cjs/cache/stuff.d.ts +2 -2
  87. package/build/runtime-cjs/cache/subscription.d.ts +19 -11
  88. package/build/runtime-cjs/cache/subscription.js +95 -56
  89. package/build/runtime-cjs/client/documentStore.d.ts +87 -0
  90. package/build/runtime-cjs/client/documentStore.js +360 -0
  91. package/build/runtime-cjs/client/index.d.ts +25 -0
  92. package/build/runtime-cjs/client/index.js +87 -0
  93. package/build/runtime-cjs/client/plugins/cache.d.ts +8 -0
  94. package/build/runtime-cjs/client/plugins/cache.js +99 -0
  95. package/build/runtime-cjs/client/plugins/fetch.d.ts +37 -0
  96. package/build/runtime-cjs/{lib/networkUtils.js → client/plugins/fetch.js} +95 -3
  97. package/build/runtime-cjs/client/plugins/fetchParams.d.ts +9 -0
  98. package/build/runtime-cjs/client/plugins/fetchParams.js +40 -0
  99. package/build/runtime-cjs/client/plugins/index.d.ts +7 -0
  100. package/build/runtime-cjs/client/plugins/index.js +24 -0
  101. package/build/runtime-cjs/client/plugins/injectedPlugins.d.ts +3 -0
  102. package/build/runtime-cjs/{lib/errors.js → client/plugins/injectedPlugins.js} +7 -15
  103. package/build/runtime-cjs/client/plugins/mutation.d.ts +1 -0
  104. package/build/runtime-cjs/client/plugins/mutation.js +86 -0
  105. package/build/runtime-cjs/client/plugins/query.d.ts +2 -0
  106. package/build/runtime-cjs/client/plugins/query.js +83 -0
  107. package/build/runtime-cjs/client/plugins/subscription.d.ts +18 -0
  108. package/build/runtime-cjs/client/plugins/subscription.js +98 -0
  109. package/build/runtime-cjs/client/plugins/throwOnError.d.ts +7 -0
  110. package/build/runtime-cjs/client/plugins/throwOnError.js +47 -0
  111. package/build/runtime-cjs/client/utils/documentPlugins.d.ts +3 -0
  112. package/build/runtime-cjs/client/utils/documentPlugins.js +56 -0
  113. package/build/runtime-cjs/client/utils/index.d.ts +1 -0
  114. package/build/runtime-cjs/client/utils/index.js +18 -0
  115. package/build/runtime-cjs/imports/config.d.ts +3 -0
  116. package/build/runtime-cjs/imports/config.js +26 -0
  117. package/build/runtime-cjs/index.d.ts +2 -1
  118. package/build/runtime-cjs/index.js +1 -0
  119. package/build/runtime-cjs/lib/config.d.ts +5 -3
  120. package/build/runtime-cjs/lib/config.js +5 -4
  121. package/build/runtime-cjs/lib/index.d.ts +1 -2
  122. package/build/runtime-cjs/lib/index.js +1 -2
  123. package/build/runtime-cjs/lib/scalars.d.ts +5 -4
  124. package/build/runtime-cjs/lib/scalars.js +20 -24
  125. package/build/runtime-cjs/lib/selection.d.ts +1 -1
  126. package/build/runtime-cjs/lib/store.d.ts +19 -0
  127. package/build/runtime-cjs/lib/store.js +81 -0
  128. package/build/runtime-cjs/lib/types.d.ts +22 -9
  129. package/build/runtime-cjs/public/cache.d.ts +2 -2
  130. package/build/runtime-cjs/public/list.d.ts +2 -2
  131. package/build/runtime-cjs/public/list.js +2 -2
  132. package/build/runtime-cjs/public/record.d.ts +1 -1
  133. package/build/runtime-cjs/public/record.js +4 -4
  134. package/build/runtime-cjs/public/tests/test.d.ts +1 -1
  135. package/build/runtime-esm/cache/cache.d.ts +10 -8
  136. package/build/runtime-esm/cache/cache.js +5 -11
  137. package/build/runtime-esm/cache/gc.d.ts +1 -1
  138. package/build/runtime-esm/cache/lists.d.ts +2 -2
  139. package/build/runtime-esm/cache/lists.js +2 -2
  140. package/build/runtime-esm/cache/schema.d.ts +2 -2
  141. package/build/runtime-esm/cache/stuff.d.ts +2 -2
  142. package/build/runtime-esm/cache/subscription.d.ts +19 -11
  143. package/build/runtime-esm/cache/subscription.js +95 -56
  144. package/build/runtime-esm/client/documentStore.d.ts +87 -0
  145. package/build/runtime-esm/client/documentStore.js +336 -0
  146. package/build/runtime-esm/client/index.d.ts +25 -0
  147. package/build/runtime-esm/client/index.js +58 -0
  148. package/build/runtime-esm/client/plugins/cache.d.ts +8 -0
  149. package/build/runtime-esm/client/plugins/cache.js +69 -0
  150. package/build/runtime-esm/client/plugins/fetch.d.ts +37 -0
  151. package/build/runtime-esm/client/plugins/fetch.js +151 -0
  152. package/build/runtime-esm/client/plugins/fetchParams.d.ts +9 -0
  153. package/build/runtime-esm/client/plugins/fetchParams.js +16 -0
  154. package/build/runtime-esm/client/plugins/index.d.ts +7 -0
  155. package/build/runtime-esm/client/plugins/index.js +7 -0
  156. package/build/runtime-esm/client/plugins/injectedPlugins.d.ts +3 -0
  157. package/build/runtime-esm/client/plugins/injectedPlugins.js +5 -0
  158. package/build/runtime-esm/client/plugins/mutation.d.ts +1 -0
  159. package/build/runtime-esm/client/plugins/mutation.js +56 -0
  160. package/build/runtime-esm/client/plugins/query.d.ts +2 -0
  161. package/build/runtime-esm/client/plugins/query.js +53 -0
  162. package/build/runtime-esm/client/plugins/subscription.d.ts +18 -0
  163. package/build/runtime-esm/client/plugins/subscription.js +74 -0
  164. package/build/runtime-esm/client/plugins/throwOnError.d.ts +7 -0
  165. package/build/runtime-esm/client/plugins/throwOnError.js +23 -0
  166. package/build/runtime-esm/client/utils/documentPlugins.d.ts +3 -0
  167. package/build/runtime-esm/client/utils/documentPlugins.js +32 -0
  168. package/build/runtime-esm/client/utils/index.d.ts +1 -0
  169. package/build/runtime-esm/client/utils/index.js +1 -0
  170. package/build/runtime-esm/imports/config.d.ts +3 -0
  171. package/build/runtime-esm/imports/config.js +4 -0
  172. package/build/runtime-esm/index.d.ts +2 -1
  173. package/build/runtime-esm/index.js +1 -0
  174. package/build/runtime-esm/lib/config.d.ts +5 -3
  175. package/build/runtime-esm/lib/config.js +5 -4
  176. package/build/runtime-esm/lib/index.d.ts +1 -2
  177. package/build/runtime-esm/lib/index.js +1 -2
  178. package/build/runtime-esm/lib/scalars.d.ts +5 -4
  179. package/build/runtime-esm/lib/scalars.js +20 -24
  180. package/build/runtime-esm/lib/selection.d.ts +1 -1
  181. package/build/runtime-esm/lib/store.d.ts +19 -0
  182. package/build/runtime-esm/lib/store.js +57 -0
  183. package/build/runtime-esm/lib/types.d.ts +22 -9
  184. package/build/runtime-esm/public/cache.d.ts +2 -2
  185. package/build/runtime-esm/public/list.d.ts +2 -2
  186. package/build/runtime-esm/public/list.js +1 -1
  187. package/build/runtime-esm/public/record.d.ts +1 -1
  188. package/build/runtime-esm/public/record.js +1 -1
  189. package/build/runtime-esm/public/tests/test.d.ts +1 -1
  190. package/build/test/index.d.ts +4 -3
  191. package/build/test-cjs/index.js +336 -1955
  192. package/build/test-esm/index.js +336 -1955
  193. package/build/vite/ast.d.ts +1 -1
  194. package/build/vite/houdini.d.ts +1 -1
  195. package/build/vite/imports.d.ts +3 -3
  196. package/build/vite/index.d.ts +1 -1
  197. package/build/vite/schema.d.ts +1 -1
  198. package/build/vite-cjs/index.js +396 -2010
  199. package/build/vite-esm/index.js +396 -2010
  200. package/package.json +1 -1
  201. package/build/runtime/lib/errors.d.ts +0 -3
  202. package/build/runtime/lib/network.d.ts +0 -79
  203. package/build/runtime/lib/networkUtils.d.ts +0 -8
  204. package/build/runtime-cjs/lib/errors.d.ts +0 -3
  205. package/build/runtime-cjs/lib/network.d.ts +0 -79
  206. package/build/runtime-cjs/lib/network.js +0 -200
  207. package/build/runtime-cjs/lib/networkUtils.d.ts +0 -8
  208. package/build/runtime-esm/lib/errors.d.ts +0 -3
  209. package/build/runtime-esm/lib/errors.js +0 -11
  210. package/build/runtime-esm/lib/network.d.ts +0 -79
  211. package/build/runtime-esm/lib/network.js +0 -170
  212. package/build/runtime-esm/lib/networkUtils.d.ts +0 -8
  213. package/build/runtime-esm/lib/networkUtils.js +0 -60
@@ -0,0 +1,26 @@
1
+ "use strict";
2
+ var __defProp = Object.defineProperty;
3
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
4
+ var __getOwnPropNames = Object.getOwnPropertyNames;
5
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
6
+ var __export = (target, all) => {
7
+ for (var name in all)
8
+ __defProp(target, name, { get: all[name], enumerable: true });
9
+ };
10
+ var __copyProps = (to, from, except, desc) => {
11
+ if (from && typeof from === "object" || typeof from === "function") {
12
+ for (let key of __getOwnPropNames(from))
13
+ if (!__hasOwnProp.call(to, key) && key !== except)
14
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
15
+ }
16
+ return to;
17
+ };
18
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
19
+ var config_exports = {};
20
+ __export(config_exports, {
21
+ default: () => config_default
22
+ });
23
+ module.exports = __toCommonJS(config_exports);
24
+ var config_default = {};
25
+ // Annotate the CommonJS export names for ESM import in node:
26
+ 0 && (module.exports = {});
@@ -1,6 +1,7 @@
1
- import { Cache as InternalCache } from './cache/cache';
1
+ import type { Cache as InternalCache } from './cache/cache';
2
2
  import type { CacheTypeDef } from './generated';
3
3
  import { Cache } from './public';
4
+ export * from './client';
4
5
  export * from './lib';
5
6
  export declare function graphql(str: string | TemplateStringsArray): any;
6
7
  export declare const cache: Cache<CacheTypeDef>;
@@ -32,6 +32,7 @@ __export(runtime_exports, {
32
32
  module.exports = __toCommonJS(runtime_exports);
33
33
  var import_cache = __toESM(require("./cache"), 1);
34
34
  var import_public = require("./public");
35
+ __reExport(runtime_exports, require("./client"), module.exports);
35
36
  __reExport(runtime_exports, require("./lib"), module.exports);
36
37
  function graphql(str) {
37
38
  if (globalThis?.process?.env?.HOUDINI_PLUGIN) {
@@ -1,11 +1,11 @@
1
- import { GraphQLSchema } from 'graphql';
2
- import { CachePolicy } from './types';
1
+ import type { GraphQLSchema } from 'graphql';
2
+ import type { CachePolicy } 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;
6
6
  export declare function keyFieldsForType(configFile: ConfigFile, type: string): string[];
7
7
  export declare function computeID(configFile: ConfigFile, type: string, data: any): string;
8
- export declare function getCurrentConfig(): Promise<ConfigFile>;
8
+ export declare function getCurrentConfig(): ConfigFile;
9
9
  export type ConfigFile = {
10
10
  /**
11
11
  * A glob pointing to all files that houdini should consider. Note, this must include .js files
@@ -140,4 +140,6 @@ export type ScalarSpec = {
140
140
  };
141
141
  export interface HoudiniPluginConfig {
142
142
  }
143
+ export interface HoudiniClientPluginConfig {
144
+ }
143
145
  export {};
@@ -32,12 +32,13 @@ __export(config_exports, {
32
32
  setMockConfig: () => setMockConfig
33
33
  });
34
34
  module.exports = __toCommonJS(config_exports);
35
+ var import_config = __toESM(require("../imports/config"), 1);
35
36
  let mockConfig = null;
36
37
  function getMockConfig() {
37
38
  return mockConfig;
38
39
  }
39
- function setMockConfig(config) {
40
- mockConfig = config;
40
+ function setMockConfig(config2) {
41
+ mockConfig = config2;
41
42
  }
42
43
  function defaultConfigValues(file) {
43
44
  return {
@@ -66,12 +67,12 @@ function computeID(configFile, type, data) {
66
67
  }
67
68
  return id.slice(0, -2);
68
69
  }
69
- async function getCurrentConfig() {
70
+ function getCurrentConfig() {
70
71
  const mockConfig2 = getMockConfig();
71
72
  if (mockConfig2) {
72
73
  return mockConfig2;
73
74
  }
74
- return defaultConfigValues((await import("HOUDINI_CONFIG_PATH")).default);
75
+ return defaultConfigValues(import_config.default);
75
76
  }
76
77
  // Annotate the CommonJS export names for ESM import in node:
77
78
  0 && (module.exports = {
@@ -1,8 +1,7 @@
1
1
  export * from './config';
2
2
  export * from './constants';
3
3
  export * from './deepEquals';
4
- export * from './errors';
5
4
  export * from './log';
6
- export * from './network';
7
5
  export * from './scalars';
8
6
  export * from './types';
7
+ export * from './store';
@@ -18,8 +18,7 @@ module.exports = __toCommonJS(lib_exports);
18
18
  __reExport(lib_exports, require("./config"), module.exports);
19
19
  __reExport(lib_exports, require("./constants"), module.exports);
20
20
  __reExport(lib_exports, require("./deepEquals"), module.exports);
21
- __reExport(lib_exports, require("./errors"), module.exports);
22
21
  __reExport(lib_exports, require("./log"), module.exports);
23
- __reExport(lib_exports, require("./network"), module.exports);
24
22
  __reExport(lib_exports, require("./scalars"), module.exports);
25
23
  __reExport(lib_exports, require("./types"), module.exports);
24
+ __reExport(lib_exports, require("./store"), module.exports);
@@ -1,14 +1,15 @@
1
- import { ConfigFile } from './config';
2
- import { MutationArtifact, QueryArtifact, SubscriptionArtifact, SubscriptionSelection } from './types';
1
+ import type { ConfigFile } from './config';
2
+ import type { MutationArtifact, QueryArtifact, SubscriptionArtifact, SubscriptionSelection } from './types';
3
3
  export declare function marshalSelection({ selection, data, }: {
4
4
  selection: SubscriptionSelection;
5
5
  data: any;
6
6
  }): Promise<{} | null | undefined>;
7
- export declare function marshalInputs<T>({ artifact, input, rootType, }: {
7
+ export declare function marshalInputs<T>({ artifact, input, config, rootType, }: {
8
8
  artifact: QueryArtifact | MutationArtifact | SubscriptionArtifact;
9
9
  input: unknown;
10
10
  rootType?: string;
11
- }): Promise<{} | null | undefined>;
11
+ config: ConfigFile;
12
+ }): {} | null | undefined;
12
13
  export declare function unmarshalSelection(config: ConfigFile, selection: SubscriptionSelection, data: any): {} | null | undefined;
13
14
  export declare function isScalar(config: ConfigFile, type: string): boolean;
14
15
  export declare function parseScalar(config: ConfigFile, type: string, value: string): string | number | boolean;
@@ -31,7 +31,7 @@ async function marshalSelection({
31
31
  selection,
32
32
  data
33
33
  }) {
34
- const config = await (0, import_config.getCurrentConfig)();
34
+ const config = (0, import_config.getCurrentConfig)();
35
35
  if (data === null || typeof data === "undefined") {
36
36
  return data;
37
37
  }
@@ -66,12 +66,12 @@ async function marshalSelection({
66
66
  )
67
67
  );
68
68
  }
69
- async function marshalInputs({
69
+ function marshalInputs({
70
70
  artifact,
71
71
  input,
72
+ config,
72
73
  rootType = "@root"
73
74
  }) {
74
- const config = await (0, import_config.getCurrentConfig)();
75
75
  if (input === null || typeof input === "undefined") {
76
76
  return input;
77
77
  }
@@ -80,30 +80,26 @@ async function marshalInputs({
80
80
  }
81
81
  const fields = rootType === "@root" ? artifact.input.fields : artifact.input.types[rootType];
82
82
  if (Array.isArray(input)) {
83
- return await Promise.all(
84
- input.map(async (val) => await marshalInputs({ artifact, input: val, rootType }))
85
- );
83
+ return input.map((val) => marshalInputs({ artifact, input: val, rootType, config }));
86
84
  }
87
85
  return Object.fromEntries(
88
- await Promise.all(
89
- Object.entries(input).map(async ([fieldName, value]) => {
90
- const type = fields?.[fieldName];
91
- if (!type) {
92
- return [fieldName, value];
93
- }
94
- const marshalFn = config.scalars?.[type]?.marshal;
95
- if (marshalFn) {
96
- if (Array.isArray(value)) {
97
- return [fieldName, value.map(marshalFn)];
98
- }
99
- return [fieldName, marshalFn(value)];
100
- }
101
- if (isScalar(config, type) || !artifact.input.types[type]) {
102
- return [fieldName, value];
86
+ Object.entries(input).map(([fieldName, value]) => {
87
+ const type = fields?.[fieldName];
88
+ if (!type) {
89
+ return [fieldName, value];
90
+ }
91
+ const marshalFn = config.scalars?.[type]?.marshal;
92
+ if (marshalFn) {
93
+ if (Array.isArray(value)) {
94
+ return [fieldName, value.map(marshalFn)];
103
95
  }
104
- return [fieldName, await marshalInputs({ artifact, input: value, rootType: type })];
105
- })
106
- )
96
+ return [fieldName, marshalFn(value)];
97
+ }
98
+ if (isScalar(config, type) || !artifact.input.types[type]) {
99
+ return [fieldName, value];
100
+ }
101
+ return [fieldName, marshalInputs({ artifact, input: value, rootType: type, config })];
102
+ })
107
103
  );
108
104
  }
109
105
  function unmarshalSelection(config, selection, data) {
@@ -1,2 +1,2 @@
1
- import { SubscriptionSelection } from './types';
1
+ import type { SubscriptionSelection } from './types';
2
2
  export declare function getFieldsForType(selection: SubscriptionSelection, __typename: string | undefined | null): Required<SubscriptionSelection>['fields'];
@@ -0,0 +1,19 @@
1
+ export declare class Writable<T> {
2
+ #private;
3
+ state: T;
4
+ constructor(value: T, start?: StartStopNotifier<T>);
5
+ set(new_value: T): void;
6
+ update(fn: Updater<T>): void;
7
+ subscribe(run: Subscriber<T>, invalidate?: Invalidator<T>): Unsubscriber;
8
+ }
9
+ /** Start and stop notification callbacks. */
10
+ type StartStopNotifier<T> = (set: Subscriber<T>) => Unsubscriber | void;
11
+ /** Callback to inform of a value updates. */
12
+ export type Subscriber<T> = (value: T) => void;
13
+ /** Unsubscribes from value updates. */
14
+ export type Unsubscriber = () => void;
15
+ /** Callback to update a value. */
16
+ type Updater<T> = (value: T) => T;
17
+ /** Cleanup logic callback. */
18
+ type Invalidator<T> = (value?: T) => void;
19
+ export {};
@@ -0,0 +1,81 @@
1
+ "use strict";
2
+ var __defProp = Object.defineProperty;
3
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
4
+ var __getOwnPropNames = Object.getOwnPropertyNames;
5
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
6
+ var __export = (target, all) => {
7
+ for (var name in all)
8
+ __defProp(target, name, { get: all[name], enumerable: true });
9
+ };
10
+ var __copyProps = (to, from, except, desc) => {
11
+ if (from && typeof from === "object" || typeof from === "function") {
12
+ for (let key of __getOwnPropNames(from))
13
+ if (!__hasOwnProp.call(to, key) && key !== except)
14
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
15
+ }
16
+ return to;
17
+ };
18
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
19
+ var store_exports = {};
20
+ __export(store_exports, {
21
+ Writable: () => Writable
22
+ });
23
+ module.exports = __toCommonJS(store_exports);
24
+ const subscriber_queue = [];
25
+ const noop = () => {
26
+ };
27
+ class Writable {
28
+ state;
29
+ #subscribers;
30
+ #stop;
31
+ #start;
32
+ constructor(value, start = noop) {
33
+ this.state = value;
34
+ this.#subscribers = /* @__PURE__ */ new Set();
35
+ this.#stop = null;
36
+ this.#start = start;
37
+ }
38
+ set(new_value) {
39
+ if (safe_not_equal(this.state, new_value)) {
40
+ this.state = new_value;
41
+ if (this.#stop) {
42
+ const run_queue = !subscriber_queue.length;
43
+ for (const subscriber of this.#subscribers) {
44
+ subscriber[1]();
45
+ subscriber_queue.push(subscriber, this.state);
46
+ }
47
+ if (run_queue) {
48
+ for (let i = 0; i < subscriber_queue.length; i += 2) {
49
+ subscriber_queue[i][0](subscriber_queue[i + 1]);
50
+ }
51
+ subscriber_queue.length = 0;
52
+ }
53
+ }
54
+ }
55
+ }
56
+ update(fn) {
57
+ this.set(fn(this.state));
58
+ }
59
+ subscribe(run, invalidate = noop) {
60
+ const subscriber = [run, invalidate];
61
+ this.#subscribers.add(subscriber);
62
+ if (this.#subscribers.size === 1) {
63
+ this.#stop = this.#start(this.set) || noop;
64
+ }
65
+ run(this.state);
66
+ return () => {
67
+ this.#subscribers.delete(subscriber);
68
+ if (this.#subscribers.size === 0) {
69
+ this.#stop?.();
70
+ this.#stop = null;
71
+ }
72
+ };
73
+ }
74
+ }
75
+ function safe_not_equal(a, b) {
76
+ return a != a ? b == b : a !== b || a && typeof a === "object" || typeof a === "function";
77
+ }
78
+ // Annotate the CommonJS export names for ESM import in node:
79
+ 0 && (module.exports = {
80
+ Writable
81
+ });
@@ -4,6 +4,22 @@ export declare enum CachePolicy {
4
4
  NetworkOnly = "NetworkOnly",
5
5
  CacheAndNetwork = "CacheAndNetwork"
6
6
  }
7
+ declare global {
8
+ namespace App {
9
+ interface Session {
10
+ }
11
+ interface Metadata {
12
+ }
13
+ interface Stuff {
14
+ inputs: {
15
+ init: boolean;
16
+ marshaled: Record<string, any>;
17
+ changed: boolean;
18
+ };
19
+ optimisticResponse?: GraphQLObject;
20
+ }
21
+ }
22
+ }
7
23
  export type Fragment<_Result> = {
8
24
  readonly shape?: _Result;
9
25
  };
@@ -65,6 +81,7 @@ export type BaseCompiledDocument = {
65
81
  paginated: boolean;
66
82
  direction?: 'forward' | 'backwards';
67
83
  };
84
+ pluginsData?: Record<string, any>;
68
85
  };
69
86
  export type HoudiniFetchContext = {
70
87
  variables: () => {};
@@ -150,7 +167,7 @@ export type FetchQueryResult<_Data> = {
150
167
  source: DataSource | null;
151
168
  partial: boolean;
152
169
  };
153
- export type QueryResult<_Data, _Input, _Extra = {}> = {
170
+ export type QueryResult<_Data = GraphQLObject, _Input = Record<string, any>> = {
154
171
  data: _Data | null;
155
172
  errors: {
156
173
  message: string;
@@ -158,16 +175,12 @@ export type QueryResult<_Data, _Input, _Extra = {}> = {
158
175
  fetching: boolean;
159
176
  partial: boolean;
160
177
  source: DataSource | null;
161
- variables: _Input;
162
- } & _Extra;
163
- export type RequestPayload<_Data = any> = {
164
- data: _Data | null;
178
+ variables: _Input | null;
179
+ };
180
+ export type RequestPayload<GraphQLObject = any> = {
181
+ data: GraphQLObject | null;
165
182
  errors: {
166
183
  message: string;
167
184
  }[] | null;
168
185
  };
169
- export type RequestPayloadMagic<_Data = any> = {
170
- ssr: boolean;
171
- body: RequestPayload<_Data>;
172
- };
173
186
  export {};
@@ -1,5 +1,5 @@
1
- import { Cache as _Cache } from '../cache/cache';
2
- import { SchemaManager, TypeInfo } from '../cache/schema';
1
+ import type { Cache as _Cache } from '../cache/cache';
2
+ import type { SchemaManager, TypeInfo } from '../cache/schema';
3
3
  import { ListCollection } from './list';
4
4
  import { Record } from './record';
5
5
  import type { CacheTypeDef, IDFields, TypeNames, ValidLists } from './types';
@@ -1,5 +1,5 @@
1
- import { Cache } from './cache';
2
- import { CacheTypeDef, ListType, ValidLists, ListFilters } from './types';
1
+ import type { Cache } from './cache';
2
+ import type { CacheTypeDef, ListType, ValidLists, ListFilters } from './types';
3
3
  export declare class ListCollection<Def extends CacheTypeDef, ListName extends ValidLists<Def>> {
4
4
  #private;
5
5
  constructor({ parentID, allLists, when, cache, name, }: {
@@ -21,7 +21,7 @@ __export(list_exports, {
21
21
  ListCollection: () => ListCollection
22
22
  });
23
23
  module.exports = __toCommonJS(list_exports);
24
- var import_lib = require("../lib");
24
+ var import_config = require("../lib/config");
25
25
  var import_cache = require("./cache");
26
26
  var import_record = require("./record");
27
27
  class ListCollection {
@@ -130,7 +130,7 @@ class ListCollection {
130
130
  if (!(record instanceof import_record.Record)) {
131
131
  throw new Error("You must provide a Record to a list operation");
132
132
  }
133
- const keys = (0, import_lib.keyFieldsForType)(this.#cache.config, record.type);
133
+ const keys = (0, import_config.keyFieldsForType)(this.#cache.config, record.type);
134
134
  selection.abstractFields.fields[record.type] = keys.reduce(
135
135
  (acc, key) => {
136
136
  const keyInfo = (0, import_cache._typeInfo)(this.#cache, record.type, key);
@@ -1,4 +1,4 @@
1
- import { Cache } from './cache';
1
+ import type { Cache } from './cache';
2
2
  import type { ArgType, CacheTypeDef, FieldType, TypeFieldNames, ValidTypes } from './types';
3
3
  export declare class Record<Def extends CacheTypeDef, Type extends ValidTypes<Def>> {
4
4
  #private;
@@ -25,7 +25,7 @@ __export(record_exports, {
25
25
  });
26
26
  module.exports = __toCommonJS(record_exports);
27
27
  var import_cache = require("../cache/cache");
28
- var import_lib = require("../lib");
28
+ var import_config = require("../lib/config");
29
29
  var import_cache2 = require("./cache");
30
30
  class Record {
31
31
  #id;
@@ -43,7 +43,7 @@ class Record {
43
43
  this.type = type;
44
44
  this.idFields = idFields;
45
45
  if (id !== import_cache.rootID) {
46
- for (const key of (0, import_lib.keyFieldsForType)(this.#cache.config, type)) {
46
+ for (const key of (0, import_config.keyFieldsForType)(this.#cache.config, type)) {
47
47
  if (!(key in idFields)) {
48
48
  throw new Error("Missing key in idFields: " + key);
49
49
  }
@@ -60,7 +60,7 @@ class Record {
60
60
  const typeInfo = (0, import_cache2._typeInfo)(this.#cache, this.type, field);
61
61
  let newValue;
62
62
  if (typeInfo.link) {
63
- const keys = (0, import_lib.keyFieldsForType)(this.#cache.config, typeInfo.type);
63
+ const keys = (0, import_config.keyFieldsForType)(this.#cache.config, typeInfo.type);
64
64
  typeInfo.selection = {
65
65
  fields: keys.reduce(
66
66
  (acc, key2) => {
@@ -123,7 +123,7 @@ class Record {
123
123
  const key = computeKey({ field, args });
124
124
  const typeInfo = (0, import_cache2._typeInfo)(this.#cache, this.type, field);
125
125
  if (typeInfo.link) {
126
- const keys = (0, import_lib.keyFieldsForType)(this.#cache.config, typeInfo.type);
126
+ const keys = (0, import_config.keyFieldsForType)(this.#cache.config, typeInfo.type);
127
127
  typeInfo.selection = {
128
128
  fields: keys.reduce(
129
129
  (acc, key2) => {
@@ -1,5 +1,5 @@
1
1
  import { Cache } from '../cache';
2
- import { Record } from '../record';
2
+ import type { Record } from '../record';
3
3
  type CacheTypeDef = {
4
4
  types: {
5
5
  __ROOT__: {
@@ -1,10 +1,12 @@
1
- import { ConfigFile } from '../lib/config';
2
- import { GraphQLObject, GraphQLValue, SubscriptionSelection, SubscriptionSpec } from '../lib/types';
1
+ import type { ConfigFile } from '../lib/config';
2
+ import type { GraphQLObject, GraphQLValue, SubscriptionSelection, SubscriptionSpec } from '../lib/types';
3
3
  import { GarbageCollector } from './gc';
4
- import { ListCollection, ListManager } from './lists';
4
+ import type { ListCollection } from './lists';
5
+ import { ListManager } from './lists';
5
6
  import { SchemaManager } from './schema';
6
- import { InMemoryStorage, Layer, LayerID } from './storage';
7
- import { InMemorySubscriptions } from './subscription';
7
+ import type { Layer, LayerID } from './storage';
8
+ import { InMemoryStorage } from './storage';
9
+ import { type FieldSelection, InMemorySubscriptions } from './subscription';
8
10
  export declare class Cache {
9
11
  _internal_unstable: CacheInternal;
10
12
  constructor(config?: ConfigFile);
@@ -59,10 +61,10 @@ declare class CacheInternal {
59
61
  parent?: string;
60
62
  root?: string;
61
63
  layer: Layer;
62
- toNotify?: SubscriptionSpec[];
64
+ toNotify?: FieldSelection[];
63
65
  applyUpdates?: boolean;
64
66
  forceNotify?: boolean;
65
- }): SubscriptionSpec[];
67
+ }): FieldSelection[];
66
68
  getSelection({ selection, parent, variables, stepsFromConnection, }: {
67
69
  selection: SubscriptionSelection;
68
70
  parent?: string;
@@ -94,7 +96,7 @@ declare class CacheInternal {
94
96
  linkedType: string;
95
97
  abstract: boolean;
96
98
  variables: {};
97
- specs: SubscriptionSpec[];
99
+ specs: FieldSelection[];
98
100
  applyUpdates: boolean;
99
101
  fields: SubscriptionSelection;
100
102
  layer: Layer;
@@ -28,7 +28,7 @@ class Cache {
28
28
  ...args
29
29
  }) {
30
30
  const layer = layerID ? this._internal_unstable.storage.getLayer(layerID) : this._internal_unstable.storage.topLayer;
31
- const subscribers = this._internal_unstable.writeSelection({ ...args, layer });
31
+ const subscribers = this._internal_unstable.writeSelection({ ...args, layer }).map((sub) => sub[0]);
32
32
  const notified = [];
33
33
  for (const spec of subscribers.concat(notifySubscribers)) {
34
34
  if (!notified.includes(spec.set)) {
@@ -166,6 +166,7 @@ class CacheInternal {
166
166
  link: !!fieldSelection
167
167
  });
168
168
  const currentSubscribers = this.subscriptions.get(parent, key);
169
+ const specs = currentSubscribers.map((sub) => sub[0]);
169
170
  const { value: previousValue, displayLayers } = this.storage.get(parent, key);
170
171
  const displayLayer = layer.isDisplayLayer(displayLayers);
171
172
  if (displayLayer) {
@@ -191,7 +192,7 @@ class CacheInternal {
191
192
  }
192
193
  const previousLinks = flattenList([previousValue]);
193
194
  for (const link of previousLinks) {
194
- this.subscriptions.remove(link, fieldSelection, currentSubscribers, variables);
195
+ this.subscriptions.remove(link, fieldSelection, specs, variables);
195
196
  }
196
197
  layer.writeLink(parent, key, null);
197
198
  toNotify.push(...currentSubscribers);
@@ -215,16 +216,10 @@ class CacheInternal {
215
216
  layer.writeLink(parent, key, linkedID);
216
217
  if (linkedID && displayLayer && (linkChange || forceNotify)) {
217
218
  if (previousValue && typeof previousValue === "string") {
218
- this.subscriptions.remove(
219
- previousValue,
220
- fieldSelection,
221
- currentSubscribers,
222
- variables
223
- );
219
+ this.subscriptions.remove(previousValue, fieldSelection, specs, variables);
224
220
  }
225
221
  this.subscriptions.addMany({
226
222
  parent: linkedID,
227
- selection: fieldSelection,
228
223
  subscribers: currentSubscribers,
229
224
  variables,
230
225
  parentType: linkedType
@@ -319,7 +314,7 @@ class CacheInternal {
319
314
  if (linkedIDs.includes(lostID) || !lostID) {
320
315
  continue;
321
316
  }
322
- this.subscriptions.remove(lostID, fieldSelection, currentSubscribers, variables);
317
+ this.subscriptions.remove(lostID, fieldSelection, specs, variables);
323
318
  }
324
319
  if (contentChanged || oldIDs.length === 0 && newIDs.length === 0) {
325
320
  layer.writeLink(parent, key, linkedIDs);
@@ -330,7 +325,6 @@ class CacheInternal {
330
325
  }
331
326
  this.subscriptions.addMany({
332
327
  parent: id,
333
- selection: fieldSelection,
334
328
  subscribers: currentSubscribers,
335
329
  variables,
336
330
  parentType: linkedType
@@ -1,4 +1,4 @@
1
- import { Cache } from './cache';
1
+ import type { Cache } from './cache';
2
2
  export declare class GarbageCollector {
3
3
  cache: Cache;
4
4
  private lifetimes;
@@ -1,5 +1,5 @@
1
- import { SubscriptionSelection, ListWhen, SubscriptionSpec } from '../lib/types';
2
- import { Cache } from './cache';
1
+ import type { SubscriptionSelection, ListWhen, SubscriptionSpec } from '../lib/types';
2
+ import type { Cache } from './cache';
3
3
  export declare class ListManager {
4
4
  rootID: string;
5
5
  cache: Cache;
@@ -257,11 +257,11 @@ class List {
257
257
  this.cache._internal_unstable.subscriptions.remove(
258
258
  targetID,
259
259
  this.connection ? this.selection.fields.edges.selection : this.selection,
260
- subscribers,
260
+ subscribers.map((sub) => sub[0]),
261
261
  variables
262
262
  );
263
263
  this.cache._internal_unstable.storage.remove(parentID, targetKey, targetID);
264
- for (const spec of subscribers) {
264
+ for (const [spec] of subscribers) {
265
265
  spec.set(
266
266
  this.cache._internal_unstable.getSelection({
267
267
  parent: spec.parentID || this.manager.rootID,
@@ -1,5 +1,5 @@
1
- import { ConfigFile } from '../lib';
2
- import { Cache } from './cache';
1
+ import type { ConfigFile } from '../lib/config';
2
+ import type { Cache } from './cache';
3
3
  export type TypeInfo = {
4
4
  type: string;
5
5
  nullable: boolean;
@@ -1,5 +1,5 @@
1
- import { GraphQLValue } from '../lib/types';
2
- import { LinkedList } from './cache';
1
+ import type { GraphQLValue } from '../lib/types';
2
+ import type { LinkedList } from './cache';
3
3
  export declare function flattenList<T>(source: LinkedList<T>): T[];
4
4
  export declare function evaluateKey(key: string, variables?: {
5
5
  [key: string]: GraphQLValue;