houdini 0.15.5 → 0.15.6

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 (102) hide show
  1. package/CHANGELOG.md +30 -0
  2. package/build/cmd/generate.js +18 -2
  3. package/build/cmd/generators/artifacts/index.d.ts +1 -0
  4. package/build/cmd/generators/artifacts/index.js +5 -0
  5. package/build/cmd/generators/artifacts/indexFile.js +3 -1
  6. package/build/cmd/generators/definitions/enums.js +1 -0
  7. package/build/cmd/generators/runtime/adapter.js +7 -8
  8. package/build/cmd/generators/runtime/copyRuntime.js +4 -1
  9. package/build/cmd/generators/stores/index.js +8 -4
  10. package/build/cmd/generators/typescript/index.js +3 -5
  11. package/build/cmd/init.d.ts +3 -3
  12. package/build/cmd/init.js +408 -93
  13. package/build/cmd/main.js +1 -1
  14. package/build/cmd/utils/cleanupFiles.d.ts +1 -0
  15. package/build/cmd/utils/cleanupFiles.js +23 -0
  16. package/build/cmd/utils/flattenSelections.js +1 -1
  17. package/build/cmd/utils/index.d.ts +4 -3
  18. package/build/cmd/utils/index.js +4 -3
  19. package/build/cmd/utils/readFile.d.ts +1 -0
  20. package/build/cmd/utils/readFile.js +15 -0
  21. package/build/cmd/utils/writeFile.js +4 -8
  22. package/build/cmd/utils/writeSchema.js +10 -11
  23. package/build/cmd.js +1951 -1878
  24. package/build/common/config.js +1 -1
  25. package/build/preprocess/index.js +1 -2
  26. package/build/preprocess/transforms/fragment.js +1 -1
  27. package/build/preprocess/transforms/index.js +8 -2
  28. package/build/preprocess/transforms/module.d.ts +3 -0
  29. package/build/preprocess/transforms/module.js +49 -0
  30. package/build/preprocess/transforms/query.js +13 -6
  31. package/build/preprocess/utils/walkTaggedDocuments.d.ts +1 -1
  32. package/build/preprocess/utils/walkTaggedDocuments.js +9 -3
  33. package/build/preprocess-cjs/index.js +1321 -1567
  34. package/build/preprocess-esm/index.js +1322 -1568
  35. package/build/runtime/adapter.d.ts +1 -0
  36. package/build/runtime/adapter.js +2 -1
  37. package/build/runtime/inline/query.d.ts +1 -0
  38. package/build/runtime/inline/query.js +2 -0
  39. package/build/runtime/lib/context.js +7 -4
  40. package/build/runtime/lib/network.d.ts +2 -1
  41. package/build/runtime/lib/network.js +20 -7
  42. package/build/runtime/lib/pagination.d.ts +26 -1
  43. package/build/runtime/lib/types.d.ts +22 -12
  44. package/build/runtime/stores/mutation.js +2 -1
  45. package/build/runtime/stores/query.js +95 -36
  46. package/build/runtime/stores/subscription.js +5 -0
  47. package/build/runtime-cjs/adapter.d.ts +1 -0
  48. package/build/runtime-cjs/adapter.js +2 -1
  49. package/build/runtime-cjs/inline/query.d.ts +1 -0
  50. package/build/runtime-cjs/inline/query.js +2 -0
  51. package/build/runtime-cjs/lib/context.js +7 -4
  52. package/build/runtime-cjs/lib/network.d.ts +2 -1
  53. package/build/runtime-cjs/lib/network.js +20 -7
  54. package/build/runtime-cjs/lib/pagination.d.ts +26 -1
  55. package/build/runtime-cjs/lib/types.d.ts +22 -12
  56. package/build/runtime-cjs/stores/mutation.js +2 -1
  57. package/build/runtime-cjs/stores/query.js +95 -36
  58. package/build/runtime-cjs/stores/subscription.js +5 -0
  59. package/build/runtime-esm/adapter.d.ts +1 -0
  60. package/build/runtime-esm/adapter.js +1 -0
  61. package/build/runtime-esm/inline/query.d.ts +1 -0
  62. package/build/runtime-esm/inline/query.js +2 -0
  63. package/build/runtime-esm/lib/context.js +7 -4
  64. package/build/runtime-esm/lib/network.d.ts +2 -1
  65. package/build/runtime-esm/lib/network.js +20 -7
  66. package/build/runtime-esm/lib/pagination.d.ts +26 -1
  67. package/build/runtime-esm/lib/types.d.ts +22 -12
  68. package/build/runtime-esm/stores/mutation.js +2 -1
  69. package/build/runtime-esm/stores/query.js +97 -38
  70. package/build/runtime-esm/stores/subscription.js +5 -0
  71. package/package.json +9 -3
  72. package/src/cmd/generate.ts +20 -2
  73. package/src/cmd/generators/artifacts/index.ts +8 -0
  74. package/src/cmd/generators/artifacts/indexFile.ts +3 -1
  75. package/src/cmd/generators/definitions/enums.ts +1 -0
  76. package/src/cmd/generators/runtime/adapter.ts +7 -7
  77. package/src/cmd/generators/runtime/copyRuntime.ts +4 -1
  78. package/src/cmd/generators/stores/index.ts +11 -7
  79. package/src/cmd/generators/typescript/index.ts +4 -6
  80. package/src/cmd/init.ts +486 -109
  81. package/src/cmd/main.ts +1 -1
  82. package/src/cmd/utils/cleanupFiles.ts +21 -0
  83. package/src/cmd/utils/flattenSelections.ts +2 -1
  84. package/src/cmd/utils/index.ts +4 -3
  85. package/src/cmd/utils/readFile.ts +8 -0
  86. package/src/cmd/utils/writeFile.ts +4 -9
  87. package/src/cmd/utils/writeSchema.ts +12 -11
  88. package/src/common/config.ts +1 -1
  89. package/src/preprocess/index.ts +1 -3
  90. package/src/preprocess/transforms/fragment.ts +1 -1
  91. package/src/preprocess/transforms/index.ts +9 -3
  92. package/src/preprocess/transforms/module.ts +39 -0
  93. package/src/preprocess/transforms/query.ts +22 -10
  94. package/src/preprocess/utils/walkTaggedDocuments.ts +11 -3
  95. package/src/runtime/adapter.ts +2 -0
  96. package/src/runtime/inline/query.ts +3 -0
  97. package/src/runtime/lib/context.ts +7 -4
  98. package/src/runtime/lib/network.ts +24 -9
  99. package/src/runtime/lib/types.ts +43 -29
  100. package/src/runtime/stores/mutation.ts +2 -0
  101. package/src/runtime/stores/query.ts +103 -38
  102. package/src/runtime/stores/subscription.ts +6 -0
package/CHANGELOG.md CHANGED
@@ -1,5 +1,35 @@
1
1
  # houdini
2
2
 
3
+ ## 0.15.6
4
+
5
+ ### Patch Changes
6
+
7
+ - [#426](https://github.com/HoudiniGraphql/houdini/pull/426) [`73b2467`](https://github.com/HoudiniGraphql/houdini/commit/73b2467e20f68b37ed0d3bb47f823361d685d026) Thanks [@AlecAivazis](https://github.com/AlecAivazis)! - fixed bug when generating list operation types without masking
8
+
9
+ * [#426](https://github.com/HoudiniGraphql/houdini/pull/426) [`73b2467`](https://github.com/HoudiniGraphql/houdini/commit/73b2467e20f68b37ed0d3bb47f823361d685d026) Thanks [@AlecAivazis](https://github.com/AlecAivazis)! - subscription.listen is a no-op on the server
10
+
11
+ - [#423](https://github.com/HoudiniGraphql/houdini/pull/423) [`ff44c42`](https://github.com/HoudiniGraphql/houdini/commit/ff44c42220dbc50ca6e23a7a2e40a93bb32f7a24) Thanks [@AlecAivazis](https://github.com/AlecAivazis)! - fix bug when computing variables in component queries
12
+
13
+ * [#419](https://github.com/HoudiniGraphql/houdini/pull/419) [`6363707`](https://github.com/HoudiniGraphql/houdini/commit/6363707d1a9471d9b8b62e8206d2660c316d9d05) Thanks [@jycouet](https://github.com/jycouet)! - feat: in summary a new log is displayed about what item was deleted
14
+
15
+ - [#397](https://github.com/HoudiniGraphql/houdini/pull/397) [`ed764a2`](https://github.com/HoudiniGraphql/houdini/commit/ed764a235c81442babd9c153960d0ef5452f379c) Thanks [@AlecAivazis](https://github.com/AlecAivazis)! - update init script to detect tooling automatically
16
+
17
+ * [#394](https://github.com/HoudiniGraphql/houdini/pull/394) [`96468da`](https://github.com/HoudiniGraphql/houdini/commit/96468dab8499085b9332044736b7c1b497d3fa58) Thanks [@david-plugge](https://github.com/david-plugge)! - export preprocessor types
18
+
19
+ - [#392](https://github.com/HoudiniGraphql/houdini/pull/392) [`17e50a9`](https://github.com/HoudiniGraphql/houdini/commit/17e50a925188c499dc865fc2d16bc248713d5c90) Thanks [@AlecAivazis](https://github.com/AlecAivazis)! - Add variable store to inline query result
20
+
21
+ * [#413](https://github.com/HoudiniGraphql/houdini/pull/413) [`8be5953`](https://github.com/HoudiniGraphql/houdini/commit/8be5953ae4237ef0f84346c595446ba8cd3feaee) Thanks [@jycouet](https://github.com/jycouet)! - improve: checking if you wrote an operation in a module, and warn you if it's the case
22
+
23
+ - [#409](https://github.com/HoudiniGraphql/houdini/pull/409) [`6f99e1f`](https://github.com/HoudiniGraphql/houdini/commit/6f99e1fd826c8476f62644a3991380c805272c7f) Thanks [@AlecAivazis](https://github.com/AlecAivazis)! - improved preprocessor performance
24
+
25
+ * [#405](https://github.com/HoudiniGraphql/houdini/pull/405) [`7eb7d39`](https://github.com/HoudiniGraphql/houdini/commit/7eb7d398174c796f6525de47aef08161e8b28ef3) Thanks [@AlecAivazis](https://github.com/AlecAivazis)! - Add support for query stores in endpoints
26
+
27
+ - [#403](https://github.com/HoudiniGraphql/houdini/pull/403) [`97ea10d`](https://github.com/HoudiniGraphql/houdini/commit/97ea10dc8eeb81eff437fd51d4d1eceece7376a9) Thanks [@AlecAivazis](https://github.com/AlecAivazis)! - fix error when prerendering queries
28
+
29
+ * [#416](https://github.com/HoudiniGraphql/houdini/pull/416) [`3f56c0d`](https://github.com/HoudiniGraphql/houdini/commit/3f56c0d6bf69690b617ce8d56c607acc5b6448b7) Thanks [@jycouet](https://github.com/jycouet)! - avoid clearing store state when there are all multiple subscribers
30
+
31
+ - [#419](https://github.com/HoudiniGraphql/houdini/pull/419) [`6363707`](https://github.com/HoudiniGraphql/houdini/commit/6363707d1a9471d9b8b62e8206d2660c316d9d05) Thanks [@jycouet](https://github.com/jycouet)! - improve: generate will write files only if it has changed
32
+
3
33
  ## 0.15.5
4
34
 
5
35
  ### Patch Changes
@@ -63,6 +63,7 @@ async function runPipeline(config, docs) {
63
63
  total: [],
64
64
  changed: [],
65
65
  new: [],
66
+ deleted: [],
66
67
  };
67
68
  // notify the user we are starting the generation process
68
69
  if (config.logLevel !== common_1.LogLevel.Quiet) {
@@ -78,9 +79,11 @@ async function runPipeline(config, docs) {
78
79
  // if the previous version is different from the current version
79
80
  const versionChanged = previousVersion && previousVersion !== 'HOUDINI_VERSION';
80
81
  await (0, common_1.runPipeline)(config, [
82
+ // validators
81
83
  validators.typeCheck,
82
84
  validators.uniqueNames,
83
85
  validators.noIDAlias,
86
+ // transforms
84
87
  transforms.internalSchema,
85
88
  transforms.addID,
86
89
  transforms.typename,
@@ -92,8 +95,9 @@ async function runPipeline(config, docs) {
92
95
  transforms.paginate,
93
96
  transforms.fragmentVariables,
94
97
  transforms.composeQueries,
95
- generators.artifacts(artifactStats),
98
+ // generators
96
99
  generators.runtime,
100
+ generators.artifacts(artifactStats),
97
101
  generators.typescript,
98
102
  generators.persistOutput,
99
103
  generators.definitions,
@@ -114,7 +118,10 @@ async function runPipeline(config, docs) {
114
118
  }
115
119
  else if ([common_1.LogLevel.Summary, common_1.LogLevel.ShortSummary].includes(config.logLevel)) {
116
120
  // count the number of unchanged
117
- const unchanged = artifactStats.total.length - artifactStats.changed.length - artifactStats.new.length;
121
+ const unchanged = artifactStats.total.length -
122
+ artifactStats.changed.length -
123
+ artifactStats.new.length -
124
+ artifactStats.deleted.length;
118
125
  // if we have any unchanged artifacts
119
126
  if (unchanged > 0) {
120
127
  console.log(`📃 Unchanged: ${unchanged}`);
@@ -131,6 +138,12 @@ async function runPipeline(config, docs) {
131
138
  logFirst5(artifactStats.new);
132
139
  }
133
140
  }
141
+ if (artifactStats.deleted.length > 0) {
142
+ console.log(`🧹 Deleted: ${artifactStats.deleted.length}`);
143
+ if (config.logLevel === common_1.LogLevel.Summary) {
144
+ logFirst5(artifactStats.deleted);
145
+ }
146
+ }
134
147
  }
135
148
  else if (config.logLevel === common_1.LogLevel.Full) {
136
149
  for (const artifact of artifactStats.total) {
@@ -142,6 +155,9 @@ async function runPipeline(config, docs) {
142
155
  else if (artifactStats.new.includes(artifact)) {
143
156
  emoji = '✨';
144
157
  }
158
+ else if (artifactStats.deleted.includes(artifact)) {
159
+ emoji = '🧹';
160
+ }
145
161
  // log the name
146
162
  console.log(`${emoji} ${artifact}`);
147
163
  }
@@ -4,4 +4,5 @@ export default function artifactGenerator(stats: {
4
4
  total: string[];
5
5
  new: string[];
6
6
  changed: string[];
7
+ deleted: string[];
7
8
  }): (config: Config, docs: CollectedGraphQLDocument[]) => Promise<void>;
@@ -39,6 +39,7 @@ const indexFile_1 = __importDefault(require("./indexFile"));
39
39
  const inputs_1 = require("./inputs");
40
40
  const utils_2 = require("./utils");
41
41
  const types_1 = require("../../../runtime/lib/types");
42
+ const cleanupFiles_1 = require("../../utils/cleanupFiles");
42
43
  const AST = recast.types.builders;
43
44
  // the artifact generator creates files in the runtime directory for each
44
45
  // document containing meta data that the preprocessor might use
@@ -103,6 +104,7 @@ function artifactGenerator(stats) {
103
104
  },
104
105
  });
105
106
  }
107
+ const listOfArtifacts = [];
106
108
  // we have everything we need to generate the artifacts
107
109
  await Promise.all([
108
110
  // generate the index file
@@ -270,6 +272,7 @@ function artifactGenerator(stats) {
270
272
  }
271
273
  // write the result to the artifact path we're configured to write to
272
274
  await (0, utils_1.writeFile)(artifactPath, recast.print(file).code);
275
+ listOfArtifacts.push(config.documentName(document));
273
276
  if (!countDocument) {
274
277
  return;
275
278
  }
@@ -281,6 +284,8 @@ function artifactGenerator(stats) {
281
284
  // regardless of wether it was changed or not, we need to track the total list of artifacts
282
285
  stats.total.push(artifact.name);
283
286
  })));
287
+ // cleanup files that are no more necessary!
288
+ stats.deleted = await (0, cleanupFiles_1.cleanupFiles)(config.artifactDirectory, listOfArtifacts);
284
289
  };
285
290
  }
286
291
  exports.default = artifactGenerator;
@@ -6,7 +6,9 @@ Object.defineProperty(exports, "__esModule", { value: true });
6
6
  const path_1 = __importDefault(require("path"));
7
7
  const utils_1 = require("../../utils");
8
8
  async function writeIndexFile(config, docs) {
9
- const docsToGenerate = docs.filter((doc) => doc.generateArtifact);
9
+ const docsToGenerate = docs
10
+ .filter((doc) => doc.generateArtifact)
11
+ .sort((a, b) => a.name.localeCompare(b.name));
10
12
  // we want to export every artifact from the index file.
11
13
  let body = config.module === 'esm'
12
14
  ? docsToGenerate.reduce((content, doc) => content + `\n export { default as ${doc.name}} from './${doc.name}'`, '')
@@ -49,6 +49,7 @@ async function definitionsGenerator(config) {
49
49
  }))).code;
50
50
  // generate the type definitions
51
51
  const typeDefinitions = enums
52
+ .sort((a, b) => a.name.value.localeCompare(b.name.value))
52
53
  .map((definition) => `
53
54
  export declare enum ${definition.name.value} {
54
55
  ${definition.values?.map((value) => ` ${value.name.value} = "${value.name.value}"`).join(',\n')}
@@ -5,17 +5,10 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
5
5
  Object.defineProperty(exports, "__esModule", { value: true });
6
6
  // external imports
7
7
  const path_1 = __importDefault(require("path"));
8
- const promises_1 = __importDefault(require("fs/promises"));
9
8
  const utils_1 = require("../../utils");
10
9
  async function generateAdapter(config) {
11
10
  // the location of the adapter
12
11
  const adapterLocation = path_1.default.join(config.runtimeDirectory, 'adapter.js');
13
- // delete the existing adapter
14
- try {
15
- await promises_1.default.stat(adapterLocation);
16
- await promises_1.default.rm(adapterLocation);
17
- }
18
- catch { }
19
12
  // figure out which adapter we need to lay down
20
13
  const adapter = {
21
14
  sapper: sapperAdapter,
@@ -44,11 +37,13 @@ export function goTo(location, options) {
44
37
  export const isBrowser = process.browser
45
38
 
46
39
  export const clientStarted = true; // Not tested in Sapper.
40
+
41
+ export const isPrerender = false
47
42
  `;
48
43
  const sveltekitAdapter = `import { goto as go } from '$app/navigation'
49
44
  import { page, session } from '$app/stores';
50
45
  import { get } from 'svelte/store';
51
- import { browser } from '$app/env'
46
+ import { browser, prerendering } from '$app/env'
52
47
 
53
48
  export function getSession() {
54
49
  return session
@@ -73,6 +68,8 @@ if (browser) {
73
68
  clientStarted = true;
74
69
  });
75
70
  }
71
+
72
+ export const isPrerender = prerendering
76
73
  `;
77
74
  const svelteAdapter = `
78
75
  import { readable, writable } from 'svelte/store'
@@ -95,4 +92,6 @@ export function goTo(location, options) {
95
92
  export const isBrowser = true
96
93
 
97
94
  export const clientStarted = true
95
+
96
+ export const isPrerender = false
98
97
  `;
@@ -75,7 +75,10 @@ async function recursiveCopy(config, source, target, notRoot) {
75
75
  : `var config = require('${relativePath}');`) +
76
76
  contents.replace('"use strict";', '');
77
77
  }
78
- await (0, utils_1.writeFile)(targetPath, contents);
78
+ // Do not write `/runtime/adapter.js` file. It will be generated later depending on the framework.
79
+ if (!targetPath.endsWith('/runtime/adapter.js')) {
80
+ await (0, utils_1.writeFile)(targetPath, contents);
81
+ }
79
82
  }
80
83
  }));
81
84
  }
@@ -6,6 +6,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
6
6
  const path_1 = __importDefault(require("path"));
7
7
  const types_1 = require("../../types");
8
8
  const utils_1 = require("../../utils");
9
+ const cleanupFiles_1 = require("../../utils/cleanupFiles");
9
10
  const fragment_1 = require("./fragment");
10
11
  const mutation_1 = require("./mutation");
11
12
  const query_1 = require("./query");
@@ -30,10 +31,10 @@ async function storesGenerator(config, docs) {
30
31
  listOfStores.push(await (0, fragment_1.generateFragmentStore)(config, doc));
31
32
  }
32
33
  }));
33
- const dataIndex = listOfStores
34
+ const listOfStoresOrdered = listOfStores
34
35
  .filter((c) => c !== null)
35
- .map((c) => `export * from './${c}'`)
36
- .join(`\n`);
36
+ .sort((a, b) => (a + '').localeCompare(b + ''));
37
+ const dataIndex = listOfStoresOrdered.map((c) => `export * from './${c}'`).join(`\n`);
37
38
  await (0, utils_1.writeFile)(path_1.default.join(config.rootDir, 'stores', `index.js`), dataIndex);
38
39
  const dataIndexDTs = `import type { DataSource } from '$houdini/runtime'
39
40
 
@@ -44,6 +45,9 @@ export type Result<DataType> = {
44
45
  data?: DataType | null
45
46
  error?: Error | null
46
47
  }`;
47
- await (0, utils_1.writeFile)(path_1.default.join(config.rootDir, 'stores', `index.d.ts`), dataIndexDTs + `\n` + dataIndex);
48
+ const storePath = path_1.default.join(config.rootDir, 'stores');
49
+ await (0, utils_1.writeFile)(path_1.default.join(storePath, `index.d.ts`), dataIndexDTs + `\n` + dataIndex);
50
+ // cleanup files that are no more necessary!
51
+ await (0, cleanupFiles_1.cleanupFiles)(storePath, listOfStoresOrdered);
48
52
  }
49
53
  exports.default = storesGenerator;
@@ -42,12 +42,9 @@ async function typescriptGenerator(config, docs) {
42
42
  // we need every fragment definition
43
43
  const fragmentDefinitions = {};
44
44
  for (const document of docs) {
45
- // look at the parsed document for a fragment definition
46
- const fragmentDefn = document.originalDocument.definitions.find(({ kind }) => kind === 'FragmentDefinition');
47
- if (!fragmentDefn) {
48
- continue;
45
+ for (const defn of document.originalDocument.definitions.filter(({ kind }) => kind === 'FragmentDefinition')) {
46
+ fragmentDefinitions[defn.name.value] = defn;
49
47
  }
50
- fragmentDefinitions[fragmentDefn.name.value] = fragmentDefn;
51
48
  }
52
49
  const missingScalars = new Set();
53
50
  // every document needs a generated type
@@ -90,6 +87,7 @@ async function typescriptGenerator(config, docs) {
90
87
  }));
91
88
  // now that we have every type generated, create an index file in the runtime root that exports the types
92
89
  const typeIndex = AST.program(typePaths
90
+ .sort((a, b) => a.localeCompare(b))
93
91
  .map((typePath) => {
94
92
  return AST.exportAllDeclaration(AST.literal('./' +
95
93
  path_1.default
@@ -1,4 +1,4 @@
1
- declare const _default: (_path: string | undefined, args: {
1
+ export default function init(_path: string | undefined, args: {
2
2
  pullHeader?: string[];
3
- }) => Promise<void>;
4
- export default _default;
3
+ yes: boolean;
4
+ }, withRunningCheck?: boolean): Promise<void>;