houdini 0.17.8 → 0.17.10

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 (148) hide show
  1. package/README.md +33 -0
  2. package/build/cmd-cjs/index.js +124 -38
  3. package/build/cmd-esm/index.js +124 -38
  4. package/build/codegen-cjs/index.js +112 -36
  5. package/build/codegen-esm/index.js +112 -36
  6. package/build/lib/config.d.ts +3 -0
  7. package/build/lib-cjs/index.js +31 -12
  8. package/build/lib-esm/index.js +31 -12
  9. package/build/runtime/cache/cache.d.ts +1 -1
  10. package/build/runtime/cache/lists.d.ts +1 -1
  11. package/build/runtime/lib/config.d.ts +10 -2
  12. package/build/runtime/lib/types.d.ts +1 -0
  13. package/build/runtime-cjs/cache/cache.d.ts +1 -1
  14. package/build/runtime-cjs/cache/cache.js +6 -6
  15. package/build/runtime-cjs/cache/lists.d.ts +1 -1
  16. package/build/runtime-cjs/cache/lists.js +15 -6
  17. package/build/runtime-cjs/cache/tests/list.test.js +160 -70
  18. package/build/runtime-cjs/lib/config.d.ts +10 -2
  19. package/build/runtime-cjs/lib/types.d.ts +1 -0
  20. package/build/runtime-esm/cache/cache.d.ts +1 -1
  21. package/build/runtime-esm/cache/cache.js +6 -6
  22. package/build/runtime-esm/cache/lists.d.ts +1 -1
  23. package/build/runtime-esm/cache/lists.js +15 -6
  24. package/build/runtime-esm/cache/tests/list.test.js +160 -70
  25. package/build/runtime-esm/lib/config.d.ts +10 -2
  26. package/build/runtime-esm/lib/types.d.ts +1 -0
  27. package/build/test-cjs/index.js +122 -36
  28. package/build/test-esm/index.js +122 -36
  29. package/build/vite-cjs/index.js +122 -36
  30. package/build/vite-esm/index.js +122 -36
  31. package/package.json +16 -1
  32. package/.turbo/turbo-compile.log +0 -5
  33. package/.turbo/turbo-typedefs.log +0 -5
  34. package/CHANGELOG.md +0 -367
  35. package/src/cmd/generate.ts +0 -54
  36. package/src/cmd/index.ts +0 -60
  37. package/src/cmd/init.ts +0 -637
  38. package/src/cmd/pullSchema.ts +0 -40
  39. package/src/codegen/generators/artifacts/artifacts.test.ts +0 -2978
  40. package/src/codegen/generators/artifacts/fieldKey.ts +0 -60
  41. package/src/codegen/generators/artifacts/index.ts +0 -330
  42. package/src/codegen/generators/artifacts/indexFile.ts +0 -24
  43. package/src/codegen/generators/artifacts/inputs.ts +0 -81
  44. package/src/codegen/generators/artifacts/operations.ts +0 -263
  45. package/src/codegen/generators/artifacts/pagination.test.ts +0 -664
  46. package/src/codegen/generators/artifacts/policy.test.ts +0 -298
  47. package/src/codegen/generators/artifacts/selection.ts +0 -208
  48. package/src/codegen/generators/artifacts/utils.test.ts +0 -118
  49. package/src/codegen/generators/artifacts/utils.ts +0 -108
  50. package/src/codegen/generators/definitions/enums.test.ts +0 -61
  51. package/src/codegen/generators/definitions/enums.ts +0 -68
  52. package/src/codegen/generators/definitions/index.ts +0 -11
  53. package/src/codegen/generators/definitions/schema.test.ts +0 -227
  54. package/src/codegen/generators/index.ts +0 -6
  55. package/src/codegen/generators/indexFile/index.ts +0 -63
  56. package/src/codegen/generators/indexFile/indexFile.test.ts +0 -72
  57. package/src/codegen/generators/persistedQueries/index.ts +0 -55
  58. package/src/codegen/generators/persistedQueries/persistedQuery.test.ts +0 -26
  59. package/src/codegen/generators/runtime/index.test.ts +0 -74
  60. package/src/codegen/generators/runtime/index.ts +0 -64
  61. package/src/codegen/generators/runtime/runtime.test.ts +0 -25
  62. package/src/codegen/generators/typescript/addReferencedInputTypes.ts +0 -77
  63. package/src/codegen/generators/typescript/index.ts +0 -412
  64. package/src/codegen/generators/typescript/inlineType.ts +0 -409
  65. package/src/codegen/generators/typescript/typeReference.ts +0 -44
  66. package/src/codegen/generators/typescript/types.ts +0 -81
  67. package/src/codegen/generators/typescript/typescript.test.ts +0 -1434
  68. package/src/codegen/index.ts +0 -406
  69. package/src/codegen/transforms/addID.test.ts +0 -93
  70. package/src/codegen/transforms/addID.ts +0 -86
  71. package/src/codegen/transforms/composeQueries.test.ts +0 -50
  72. package/src/codegen/transforms/composeQueries.ts +0 -154
  73. package/src/codegen/transforms/fragmentVariables.test.ts +0 -636
  74. package/src/codegen/transforms/fragmentVariables.ts +0 -417
  75. package/src/codegen/transforms/index.ts +0 -7
  76. package/src/codegen/transforms/list.ts +0 -485
  77. package/src/codegen/transforms/lists.test.ts +0 -530
  78. package/src/codegen/transforms/paginate.test.ts +0 -1481
  79. package/src/codegen/transforms/paginate.ts +0 -750
  80. package/src/codegen/transforms/schema.test.ts +0 -136
  81. package/src/codegen/transforms/schema.ts +0 -104
  82. package/src/codegen/transforms/typename.test.ts +0 -125
  83. package/src/codegen/transforms/typename.ts +0 -55
  84. package/src/codegen/utils/commonjs.ts +0 -26
  85. package/src/codegen/utils/flattenSelections.ts +0 -179
  86. package/src/codegen/utils/graphql.test.ts +0 -35
  87. package/src/codegen/utils/graphql.ts +0 -79
  88. package/src/codegen/utils/index.ts +0 -5
  89. package/src/codegen/utils/moduleExport.ts +0 -27
  90. package/src/codegen/utils/murmur.ts +0 -79
  91. package/src/codegen/validators/index.ts +0 -4
  92. package/src/codegen/validators/noIDAlias.test.ts +0 -71
  93. package/src/codegen/validators/noIDAlias.ts +0 -39
  94. package/src/codegen/validators/plugins.ts +0 -25
  95. package/src/codegen/validators/typeCheck.test.ts +0 -904
  96. package/src/codegen/validators/typeCheck.ts +0 -1031
  97. package/src/codegen/validators/uniqueNames.test.ts +0 -59
  98. package/src/codegen/validators/uniqueNames.ts +0 -39
  99. package/src/lib/cleanupFiles.ts +0 -20
  100. package/src/lib/config.test.ts +0 -13
  101. package/src/lib/config.ts +0 -943
  102. package/src/lib/constants.ts +0 -11
  103. package/src/lib/error.ts +0 -24
  104. package/src/lib/fs.ts +0 -285
  105. package/src/lib/graphql.test.ts +0 -211
  106. package/src/lib/graphql.ts +0 -200
  107. package/src/lib/imports.ts +0 -82
  108. package/src/lib/index.ts +0 -17
  109. package/src/lib/introspection.ts +0 -39
  110. package/src/lib/parse.test.ts +0 -75
  111. package/src/lib/parse.ts +0 -23
  112. package/src/lib/path.ts +0 -49
  113. package/src/lib/pipeline.ts +0 -17
  114. package/src/lib/types.ts +0 -34
  115. package/src/lib/walk.ts +0 -104
  116. package/src/runtime/cache/cache.ts +0 -1023
  117. package/src/runtime/cache/gc.ts +0 -56
  118. package/src/runtime/cache/index.ts +0 -3
  119. package/src/runtime/cache/lists.ts +0 -502
  120. package/src/runtime/cache/storage.ts +0 -574
  121. package/src/runtime/cache/stuff.ts +0 -77
  122. package/src/runtime/cache/subscription.ts +0 -329
  123. package/src/runtime/cache/tests/availability.test.ts +0 -408
  124. package/src/runtime/cache/tests/gc.test.ts +0 -319
  125. package/src/runtime/cache/tests/keys.test.ts +0 -36
  126. package/src/runtime/cache/tests/list.test.ts +0 -3747
  127. package/src/runtime/cache/tests/readwrite.test.ts +0 -1201
  128. package/src/runtime/cache/tests/scalars.test.ts +0 -218
  129. package/src/runtime/cache/tests/storage.test.ts +0 -426
  130. package/src/runtime/cache/tests/subscriptions.test.ts +0 -1757
  131. package/src/runtime/index.ts +0 -29
  132. package/src/runtime/lib/config.ts +0 -201
  133. package/src/runtime/lib/constants.ts +0 -17
  134. package/src/runtime/lib/deepEquals.ts +0 -32
  135. package/src/runtime/lib/errors.ts +0 -8
  136. package/src/runtime/lib/index.ts +0 -8
  137. package/src/runtime/lib/log.ts +0 -69
  138. package/src/runtime/lib/network.ts +0 -303
  139. package/src/runtime/lib/networkUtils.ts +0 -151
  140. package/src/runtime/lib/scalars.test.ts +0 -877
  141. package/src/runtime/lib/scalars.ts +0 -195
  142. package/src/runtime/lib/types.ts +0 -194
  143. package/src/test/index.ts +0 -294
  144. package/src/vite/ast.ts +0 -107
  145. package/src/vite/houdini.ts +0 -113
  146. package/src/vite/imports.ts +0 -129
  147. package/src/vite/index.ts +0 -55
  148. package/src/vite/schema.ts +0 -80
@@ -1,11 +0,0 @@
1
- export const siteURL = 'https://houdinigraphql.com'
2
-
3
- export const houdini_mode = {
4
- /**
5
- * to set the testing mode do like this:
6
- * `process.env.HOUDINI_TEST = 'true'`
7
- */
8
- get is_testing() {
9
- return process.env.HOUDINI_TEST === 'true'
10
- },
11
- }
package/src/lib/error.ts DELETED
@@ -1,24 +0,0 @@
1
- // any error that the compiler could fire
2
- export class HoudiniError extends Error {
3
- filepath: string | null = null
4
- description: string | null = null
5
-
6
- constructor({
7
- filepath,
8
- message,
9
- description,
10
- }: {
11
- filepath?: string | null
12
- message: string
13
- description?: string | null
14
- }) {
15
- super(message)
16
-
17
- if (filepath) {
18
- this.filepath = filepath
19
- }
20
- if (description) {
21
- this.description = description
22
- }
23
- }
24
- }
package/src/lib/fs.ts DELETED
@@ -1,285 +0,0 @@
1
- import fsExtra from 'fs-extra'
2
- import fs from 'fs/promises'
3
- import { glob as G } from 'glob'
4
- import { fs as memfs, vol } from 'memfs'
5
- import { promisify } from 'util'
6
-
7
- import { houdini_mode } from './constants'
8
- import * as path from './path'
9
-
10
- export function copyFileSync(src: string, dest: string): void | null {
11
- if (houdini_mode.is_testing) {
12
- try {
13
- if (src.includes('build/runtime') || dest.includes('build/runtime')) {
14
- fsExtra.copyFileSync(src, dest)
15
- return
16
- }
17
-
18
- memfs.copyFileSync(src, dest)
19
- return
20
- } catch (e) {
21
- return null
22
- }
23
- }
24
- try {
25
- fsExtra.copyFileSync(src, dest)
26
- return
27
- } catch (e) {}
28
-
29
- return null
30
- }
31
-
32
- export async function copyFile(src: string, dest: string): Promise<void | null> {
33
- if (houdini_mode.is_testing) {
34
- try {
35
- if (src.includes('build/runtime') || dest.includes('build/runtime')) {
36
- await fs.copyFile(src, dest)
37
- return
38
- }
39
-
40
- await memfs.copyFile(src, dest, (err) => {
41
- throw err
42
- })
43
- return
44
- } catch (e) {
45
- return null
46
- }
47
- }
48
- try {
49
- await fs.copyFile(src, dest)
50
- return
51
- } catch (e) {}
52
-
53
- return null
54
- }
55
-
56
- export async function readFile(filepath: string): Promise<string | null> {
57
- if (houdini_mode.is_testing) {
58
- try {
59
- if (filepath.includes('build/runtime')) {
60
- return await fs.readFile(filepath, 'utf-8')
61
- }
62
-
63
- return memfs.readFileSync(filepath, 'utf-8')!.toString()
64
- } catch (e) {
65
- return null
66
- }
67
- }
68
-
69
- try {
70
- return await fs.readFile(filepath, 'utf8')
71
- } catch (error) {}
72
-
73
- return null
74
- }
75
-
76
- export function readFileSync(filepath: string): string | null {
77
- if (houdini_mode.is_testing) {
78
- try {
79
- if (filepath.includes('build/runtime')) {
80
- return fsExtra.readFileSync(filepath, 'utf-8')
81
- }
82
-
83
- return memfs.readFileSync(filepath, 'utf-8')!.toString()
84
- } catch (e) {
85
- return null
86
- }
87
- }
88
-
89
- try {
90
- return fsExtra.readFileSync(filepath, 'utf-8')
91
- } catch (error) {}
92
-
93
- return null
94
- }
95
-
96
- export async function writeFile(filepath: string, data: string) {
97
- const existingFileData = await readFile(filepath)
98
- if (data === existingFileData) {
99
- return
100
- }
101
-
102
- // no mock in tests
103
- if (houdini_mode.is_testing) {
104
- return memfs.writeFileSync(filepath, data)
105
- }
106
-
107
- return await fs.writeFile(filepath, data, 'utf8')
108
- }
109
-
110
- export async function access(filepath: string) {
111
- // no mock in production
112
- if (!houdini_mode.is_testing) {
113
- return await fs.access(filepath)
114
- }
115
-
116
- if (filepath.includes('build/runtime')) {
117
- return await fs.access(filepath)
118
- }
119
-
120
- // split up the path in accessors and keep going until we get undefined
121
- // or we get a value
122
- return memfs.statSync(filepath)
123
- }
124
-
125
- export async function mkdirp(filepath: string) {
126
- // no mock in production
127
- if (!houdini_mode.is_testing) {
128
- return await fsExtra.mkdirp(filepath)
129
- }
130
-
131
- return memfs.mkdirpSync(filepath)
132
- }
133
-
134
- export async function mkdirpSync(filepath: string) {
135
- // no mock in production
136
- if (!houdini_mode.is_testing) {
137
- return fsExtra.mkdirpSync(filepath)
138
- }
139
-
140
- return memfs.mkdirpSync(filepath)
141
- }
142
-
143
- export async function mkdir(filepath: string) {
144
- // no mock in production
145
- if (!houdini_mode.is_testing) {
146
- return await fs.mkdir(filepath)
147
- }
148
-
149
- return memfs.mkdirSync(filepath)
150
- }
151
-
152
- export async function rmdir(filepath: string) {
153
- // no mock in production
154
- if (!houdini_mode.is_testing) {
155
- return await fs.rm(filepath, {
156
- recursive: true,
157
- })
158
- }
159
-
160
- return await promisify(memfs.rmdir)(filepath)
161
- }
162
-
163
- export async function stat(filepath: string) {
164
- // no mock in production
165
- if (!houdini_mode.is_testing) {
166
- return await fs.stat(filepath)
167
- }
168
-
169
- // if the filepath points to a built package, use the real filesystem
170
- if (filepath.includes('build/runtime')) {
171
- return await fs.stat(filepath)
172
- }
173
-
174
- return memfs.statSync(filepath)
175
- }
176
-
177
- export function existsSync(dirPath: string) {
178
- // no mock in production
179
- if (!houdini_mode.is_testing) {
180
- return fsExtra.existsSync(dirPath)
181
- }
182
-
183
- return memfs.existsSync(dirPath)
184
- }
185
-
186
- export async function readdir(filepath: string): Promise<string[]> {
187
- // no mock in production
188
- if (!houdini_mode.is_testing) {
189
- return await fs.readdir(filepath)
190
- }
191
- if (filepath.includes('build/runtime')) {
192
- return await fs.readdir(filepath)
193
- }
194
-
195
- try {
196
- return memfs.readdirSync(filepath) as string[]
197
- } catch {
198
- return []
199
- }
200
- }
201
-
202
- export async function remove(filepath: string) {
203
- // no mock in production
204
- if (!houdini_mode.is_testing) {
205
- return await fs.rm(filepath)
206
- }
207
-
208
- return vol.rmSync(filepath)
209
- }
210
-
211
- type MockFilesystem = { [key: string]: string | MockFilesystem }
212
-
213
- export async function mock(target: MockFilesystem[string], filepath: string = '') {
214
- // assuming mock is always called with an object, process every key
215
- await Promise.all(
216
- Object.entries(target).map(async ([key, value]) => {
217
- const childPath = path.join(filepath, key)
218
- // if our value is a string, we need to write the contents
219
- if (typeof value === 'string') {
220
- await writeFile(childPath, value)
221
- } else {
222
- // the key is the new directory name
223
- await mkdirp(childPath)
224
- return await mock(value, childPath)
225
- }
226
- })
227
- )
228
- }
229
-
230
- export async function recursiveCopy(
231
- source: string,
232
- target: string,
233
- transforms?: Record<string, (content: string) => string>,
234
- notRoot?: boolean
235
- ) {
236
- // if the folder containing the target doesn't exist, then we need to create it
237
- let parentDir = path.join(target, path.basename(source))
238
- // if we are at the root, then go up one
239
- if (!notRoot) {
240
- parentDir = path.join(parentDir, '..')
241
- }
242
- try {
243
- await access(parentDir)
244
- // the parent directory does not exist
245
- } catch (e) {
246
- await mkdirp(parentDir)
247
- }
248
- // check if we are copying a directory
249
- if ((await stat(source)).isDirectory()) {
250
- // look in the contents of the source directory
251
- await Promise.all(
252
- (
253
- await readdir(source)
254
- ).map(async (child) => {
255
- // figure out the full path of the source
256
- const childPath = path.join(source, child)
257
-
258
- // if the child is a directory
259
- if ((await stat(childPath)).isDirectory()) {
260
- // keep walking down
261
- await recursiveCopy(childPath, parentDir, transforms, true)
262
- }
263
- // the child is a file, copy it to the parent directory
264
- else {
265
- const targetPath = path.join(parentDir, child)
266
-
267
- // we might have to transform the value before copying it
268
- let original = (await readFile(childPath)) || ''
269
- if (transforms?.[childPath]) {
270
- original = transforms[childPath](original)
271
- }
272
-
273
- await writeFile(targetPath, original)
274
- }
275
- })
276
- )
277
- }
278
- }
279
-
280
- // wrap glob in a promise and enforce that the paths are always posix-style
281
- export async function glob(pattern: string) {
282
- return await promisify(G)(path.posixify(pattern))
283
- }
284
-
285
- glob.hasMagic = G.hasMagic
@@ -1,211 +0,0 @@
1
- import * as graphql from 'graphql'
2
- import { test, expect } from 'vitest'
3
-
4
- import { parentTypeFromAncestors } from './graphql'
5
-
6
- test('can find ancestor from type', function () {
7
- // define a schema we'll test against
8
- const schema = graphql.buildSchema(`
9
- type User {
10
- id: ID!
11
- name: String!
12
- }
13
-
14
- type Query {
15
- users: [User!]!
16
- }
17
- `)
18
-
19
- const doc = graphql.parse(`
20
- query {
21
- users {
22
- id
23
- }
24
- }
25
- `)
26
-
27
- // we should
28
- let foundType = ''
29
-
30
- graphql.visit(doc, {
31
- Field(node, key, parent, path, ancestors) {
32
- if (node.name.value === 'id') {
33
- foundType = parentTypeFromAncestors(schema, '', ancestors).name
34
- }
35
- },
36
- })
37
-
38
- expect(foundType).toEqual('User')
39
- })
40
-
41
- test('inline fragments', function () {
42
- // define a schema we'll test against
43
- const schema = graphql.buildSchema(`
44
- type User implements Node {
45
- id: ID!
46
- name: String!
47
- }
48
-
49
- interface Node {
50
- id: ID!
51
- }
52
-
53
- type Query {
54
- nodes: [Node!]!
55
- }
56
- `)
57
-
58
- const doc = graphql.parse(`
59
- query {
60
- nodes {
61
- ... on User {
62
- id
63
- }
64
- }
65
- }
66
- `)
67
-
68
- // we should
69
- let foundType = ''
70
-
71
- graphql.visit(doc, {
72
- Field(node, key, parent, path, ancestors) {
73
- if (node.name.value === 'id') {
74
- foundType = parentTypeFromAncestors(schema, '', ancestors).name
75
- }
76
- },
77
- })
78
-
79
- expect(foundType).toEqual('User')
80
- })
81
-
82
- test('nested inline fragments', function () {
83
- // define a schema we'll test against
84
- const schema = graphql.buildSchema(`
85
- type User implements Node {
86
- id: ID!
87
- name: String!
88
- }
89
-
90
- interface Node {
91
- id: ID!
92
- }
93
-
94
- type Query {
95
- nodes: [Node!]!
96
- }
97
- `)
98
-
99
- const doc = graphql.parse(`
100
- query {
101
- nodes {
102
- ... on User {
103
- ... on Node {
104
- id
105
- }
106
- }
107
- }
108
- }
109
- `)
110
-
111
- // we should
112
- let foundType = ''
113
-
114
- graphql.visit(doc, {
115
- Field(node, key, parent, path, ancestors) {
116
- if (node.name.value === 'id') {
117
- foundType = parentTypeFromAncestors(schema, '', ancestors).name
118
- }
119
- },
120
- })
121
-
122
- expect(foundType).toEqual('Node')
123
- })
124
-
125
- test('can find interface ancestor from type', function () {
126
- // define a schema we'll test against
127
- const schema = graphql.buildSchema(`
128
- type User implements Node {
129
- id: ID!
130
- name: String!
131
- }
132
-
133
- interface Node {
134
- id: ID!
135
- }
136
-
137
- type Query {
138
- nodes: [Node!]!
139
- }
140
- `)
141
-
142
- const doc = graphql.parse(`
143
- query {
144
- nodes {
145
- id
146
- }
147
- }
148
- `)
149
-
150
- // we should
151
- let foundType = ''
152
-
153
- graphql.visit(doc, {
154
- Field(node, key, parent, path, ancestors) {
155
- if (node.name.value === 'id') {
156
- foundType = parentTypeFromAncestors(schema, '', ancestors).name
157
- }
158
- },
159
- })
160
-
161
- expect(foundType).toEqual('Node')
162
- })
163
-
164
- test('union ancestor', function () {
165
- const schema = graphql.buildSchema(`
166
- union UnionType = TypeB | TypeA
167
-
168
- type TypeA {
169
- id: String
170
- objective: TypeB
171
- }
172
-
173
- type TypeB {
174
- family: TypeA
175
- objective: TypeB
176
- id: String
177
- }
178
-
179
-
180
- type Query {
181
- types: [UnionType]
182
- }
183
- `)
184
-
185
- const doc = graphql.parse(`
186
- query Friends {
187
- types {
188
- ... on TypeA {
189
- objective {
190
- id
191
- }
192
- }
193
- }
194
- }
195
- `)
196
-
197
- let foundType = ''
198
-
199
- // make sure its valid first
200
- expect(graphql.validate(schema, doc)).toHaveLength(0)
201
-
202
- graphql.visit(doc, {
203
- Field(node, key, parent, path, ancestors) {
204
- if (node.name.value === 'id') {
205
- foundType = parentTypeFromAncestors(schema, '', ancestors).name
206
- }
207
- },
208
- })
209
-
210
- expect(foundType).toEqual('TypeB')
211
- })