@graphprotocol/graph-cli 0.37.2 → 0.37.3-alpha-20230110163550-d64bef6

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 (206) hide show
  1. package/CHANGELOG.md +7 -0
  2. package/babel.config.js +3 -0
  3. package/dist/bin.js +6 -0
  4. package/dist/cli.js +32 -0
  5. package/dist/codegen/schema.js +250 -0
  6. package/dist/codegen/schema.test.js +458 -0
  7. package/dist/codegen/template.js +65 -0
  8. package/dist/codegen/types/conversions.js +359 -0
  9. package/dist/codegen/types/index.js +71 -0
  10. package/dist/codegen/types/index.test.js +563 -0
  11. package/dist/codegen/typescript.js +200 -0
  12. package/dist/codegen/util.js +46 -0
  13. package/dist/codegen/util.test.js +93 -0
  14. package/dist/command-helpers/abi.js +78 -0
  15. package/dist/command-helpers/auth.js +77 -0
  16. package/dist/command-helpers/compiler.js +66 -0
  17. package/dist/command-helpers/data-sources.js +29 -0
  18. package/dist/command-helpers/fs.js +9 -0
  19. package/dist/command-helpers/gluegun.js +49 -0
  20. package/dist/command-helpers/ipfs.js +5 -0
  21. package/dist/command-helpers/jsonrpc.js +29 -0
  22. package/dist/command-helpers/network.js +93 -0
  23. package/dist/command-helpers/network.test.js +86 -0
  24. package/dist/command-helpers/node.js +40 -0
  25. package/dist/command-helpers/scaffold.js +112 -0
  26. package/dist/command-helpers/spinner.js +84 -0
  27. package/dist/command-helpers/studio.js +13 -0
  28. package/dist/command-helpers/studio.test.js +41 -0
  29. package/dist/command-helpers/subgraph.js +24 -0
  30. package/dist/command-helpers/version.js +74 -0
  31. package/dist/command-helpers/version.test.js +179 -0
  32. package/dist/commands/add.js +190 -0
  33. package/dist/commands/auth.js +127 -0
  34. package/dist/commands/build.js +140 -0
  35. package/dist/commands/codegen.js +135 -0
  36. package/dist/commands/create.js +86 -0
  37. package/dist/commands/deploy.js +334 -0
  38. package/dist/commands/init.js +788 -0
  39. package/dist/commands/local.js +387 -0
  40. package/dist/commands/remove.js +86 -0
  41. package/dist/commands/test.js +295 -0
  42. package/dist/compiler/asc.js +83 -0
  43. package/dist/compiler/index.js +474 -0
  44. package/dist/debug.js +16 -0
  45. package/dist/migrations/mapping_api_version_0_0_1.js +78 -0
  46. package/dist/migrations/mapping_api_version_0_0_2.js +76 -0
  47. package/dist/migrations/mapping_api_version_0_0_3.js +78 -0
  48. package/dist/migrations/mapping_api_version_0_0_4.js +80 -0
  49. package/dist/migrations/mapping_api_version_0_0_5.js +80 -0
  50. package/dist/migrations/spec_version_0_0_2.js +49 -0
  51. package/dist/migrations/spec_version_0_0_3.js +54 -0
  52. package/dist/migrations/util/load-manifest.js +18 -0
  53. package/dist/migrations/util/versions.js +29 -0
  54. package/dist/migrations.js +56 -0
  55. package/dist/protocols/arweave/manifest.graphql +57 -0
  56. package/dist/protocols/arweave/scaffold/manifest.js +18 -0
  57. package/dist/protocols/arweave/scaffold/mapping.js +52 -0
  58. package/dist/protocols/arweave/subgraph.js +23 -0
  59. package/dist/protocols/cosmos/manifest.graphql +76 -0
  60. package/dist/protocols/cosmos/scaffold/manifest.js +15 -0
  61. package/dist/protocols/cosmos/scaffold/mapping.js +38 -0
  62. package/dist/protocols/cosmos/subgraph.js +25 -0
  63. package/dist/protocols/ethereum/abi.js +140 -0
  64. package/dist/protocols/ethereum/codegen/abi.js +451 -0
  65. package/dist/protocols/ethereum/codegen/abi.test.js +328 -0
  66. package/dist/protocols/ethereum/codegen/template.js +50 -0
  67. package/dist/protocols/ethereum/contract.js +20 -0
  68. package/dist/protocols/ethereum/manifest.graphql +94 -0
  69. package/dist/protocols/ethereum/scaffold/manifest.js +32 -0
  70. package/dist/protocols/ethereum/scaffold/mapping.js +65 -0
  71. package/dist/protocols/ethereum/subgraph.js +171 -0
  72. package/dist/protocols/ethereum/type-generator.js +125 -0
  73. package/dist/protocols/index.js +268 -0
  74. package/dist/protocols/ipfs/codegen/file_template.js +50 -0
  75. package/dist/protocols/near/contract.js +41 -0
  76. package/dist/protocols/near/manifest.graphql +64 -0
  77. package/dist/protocols/near/scaffold/manifest.js +16 -0
  78. package/dist/protocols/near/scaffold/mapping.js +38 -0
  79. package/dist/protocols/near/subgraph.js +20 -0
  80. package/dist/protocols/subgraph.js +2 -0
  81. package/dist/protocols/substreams/manifest.graphql +45 -0
  82. package/dist/protocols/substreams/scaffold/manifest.js +12 -0
  83. package/dist/protocols/substreams/subgraph.js +23 -0
  84. package/dist/scaffold/cosmos.test.js +83 -0
  85. package/dist/scaffold/ethereum.test.js +505 -0
  86. package/dist/scaffold/index.js +128 -0
  87. package/dist/scaffold/mapping.js +61 -0
  88. package/dist/scaffold/near.test.js +86 -0
  89. package/dist/scaffold/schema.js +83 -0
  90. package/dist/scaffold/tests.js +175 -0
  91. package/dist/schema.js +54 -0
  92. package/dist/subgraph.js +249 -0
  93. package/dist/type-generator.js +224 -0
  94. package/dist/validation/contract.js +46 -0
  95. package/dist/validation/index.js +8 -0
  96. package/dist/validation/manifest.js +271 -0
  97. package/dist/validation/schema.js +796 -0
  98. package/dist/validation/schema.test.js +35 -0
  99. package/dist/watcher.js +79 -0
  100. package/jest.config.js +1 -1
  101. package/package.json +16 -9
  102. package/{bin/graph → src/bin.ts} +2 -1
  103. package/src/cli.ts +36 -0
  104. package/src/codegen/schema.js +23 -22
  105. package/src/codegen/schema.test.js +33 -27
  106. package/src/codegen/{template.js → template.ts} +8 -6
  107. package/src/codegen/types/conversions.ts +382 -0
  108. package/src/codegen/types/index.js +4 -7
  109. package/src/codegen/types/index.test.js +10 -4
  110. package/src/codegen/{typescript.js → typescript.ts} +44 -26
  111. package/src/codegen/util.js +1 -1
  112. package/src/codegen/util.test.js +5 -2
  113. package/src/command-helpers/abi.js +46 -30
  114. package/src/command-helpers/auth.js +6 -9
  115. package/src/command-helpers/compiler.js +4 -6
  116. package/src/command-helpers/data-sources.js +8 -11
  117. package/src/command-helpers/fs.ts +5 -0
  118. package/src/command-helpers/gluegun.js +2 -4
  119. package/src/command-helpers/ipfs.ts +3 -0
  120. package/src/command-helpers/{jsonrpc.js → jsonrpc.ts} +11 -16
  121. package/src/command-helpers/network.js +58 -44
  122. package/src/command-helpers/network.test.js +23 -19
  123. package/src/command-helpers/node.js +3 -7
  124. package/src/command-helpers/scaffold.js +34 -25
  125. package/src/command-helpers/{spinner.js → spinner.ts} +10 -10
  126. package/src/command-helpers/studio.test.js +61 -30
  127. package/src/command-helpers/studio.ts +20 -0
  128. package/src/command-helpers/{subgraph.js → subgraph.ts} +6 -6
  129. package/src/command-helpers/version.js +11 -16
  130. package/src/command-helpers/version.test.js +111 -82
  131. package/src/commands/add.js +49 -35
  132. package/src/commands/auth.js +13 -25
  133. package/src/commands/build.js +9 -9
  134. package/src/commands/codegen.js +12 -12
  135. package/src/commands/create.js +22 -22
  136. package/src/commands/deploy.js +39 -34
  137. package/src/commands/init.js +21 -24
  138. package/src/commands/local.js +15 -14
  139. package/src/commands/remove.js +22 -22
  140. package/src/commands/test.js +86 -70
  141. package/src/compiler/{asc.js → asc.ts} +29 -16
  142. package/src/compiler/index.js +18 -18
  143. package/src/{debug.js → debug.ts} +2 -2
  144. package/src/migrations/mapping_api_version_0_0_1.js +7 -7
  145. package/src/migrations/mapping_api_version_0_0_2.js +5 -5
  146. package/src/migrations/mapping_api_version_0_0_3.js +7 -7
  147. package/src/migrations/mapping_api_version_0_0_4.js +7 -7
  148. package/src/migrations/mapping_api_version_0_0_5.js +7 -7
  149. package/src/migrations/spec_version_0_0_2.js +5 -5
  150. package/src/migrations/spec_version_0_0_3.js +5 -5
  151. package/src/migrations/util/load-manifest.js +6 -9
  152. package/src/migrations/util/versions.js +5 -10
  153. package/src/{migrations.js → migrations.ts} +14 -15
  154. package/src/protocols/arweave/scaffold/manifest.js +1 -4
  155. package/src/protocols/arweave/scaffold/mapping.js +1 -3
  156. package/src/protocols/arweave/subgraph.ts +22 -0
  157. package/src/protocols/cosmos/scaffold/manifest.js +1 -4
  158. package/src/protocols/cosmos/scaffold/mapping.js +1 -3
  159. package/src/protocols/cosmos/subgraph.js +2 -2
  160. package/src/protocols/ethereum/abi.js +7 -13
  161. package/src/protocols/ethereum/codegen/abi.js +219 -222
  162. package/src/protocols/ethereum/codegen/abi.test.js +6 -6
  163. package/src/protocols/ethereum/codegen/template.js +3 -5
  164. package/src/protocols/ethereum/contract.js +3 -2
  165. package/src/protocols/ethereum/scaffold/manifest.js +4 -7
  166. package/src/protocols/ethereum/scaffold/mapping.js +4 -11
  167. package/src/protocols/ethereum/subgraph.js +21 -20
  168. package/src/protocols/ethereum/type-generator.js +24 -30
  169. package/src/protocols/{index.js → index.ts} +65 -46
  170. package/src/protocols/ipfs/codegen/file_template.js +2 -2
  171. package/src/protocols/near/{contract.js → contract.ts} +16 -12
  172. package/src/protocols/near/scaffold/manifest.js +2 -5
  173. package/src/protocols/near/scaffold/mapping.js +1 -3
  174. package/src/protocols/near/subgraph.js +3 -6
  175. package/src/protocols/subgraph.ts +12 -0
  176. package/src/protocols/substreams/scaffold/{manifest.js → manifest.ts} +2 -7
  177. package/src/protocols/substreams/subgraph.ts +22 -0
  178. package/src/scaffold/cosmos.test.js +3 -3
  179. package/src/scaffold/ethereum.test.js +4 -4
  180. package/src/scaffold/index.js +7 -7
  181. package/src/scaffold/mapping.js +3 -3
  182. package/src/scaffold/near.test.js +3 -3
  183. package/src/scaffold/schema.js +4 -4
  184. package/src/scaffold/tests.js +72 -58
  185. package/src/schema.ts +26 -0
  186. package/src/{subgraph.js → subgraph.ts} +80 -60
  187. package/src/type-generator.js +20 -20
  188. package/src/validation/contract.js +2 -6
  189. package/src/validation/index.js +1 -1
  190. package/src/validation/manifest.js +24 -22
  191. package/src/validation/schema.test.js +1 -1
  192. package/src/validation/{schema.js → schema.ts} +268 -221
  193. package/src/{watcher.js → watcher.ts} +23 -12
  194. package/tests/cli/globalSetup.js +2 -2
  195. package/tests/cli/globalTeardown.js +2 -2
  196. package/tests/cli/init.test.js +2 -2
  197. package/tests/cli/util.js +7 -13
  198. package/tsconfig.json +18 -0
  199. package/src/cli.js +0 -38
  200. package/src/codegen/types/conversions.js +0 -329
  201. package/src/command-helpers/fs.js +0 -8
  202. package/src/command-helpers/ipfs.js +0 -6
  203. package/src/command-helpers/studio.js +0 -15
  204. package/src/protocols/arweave/subgraph.js +0 -20
  205. package/src/protocols/substreams/subgraph.js +0 -17
  206. package/src/schema.js +0 -23
@@ -1,6 +1,6 @@
1
- const fs = require('fs')
2
- const graphql = require('graphql/language')
3
- const immutable = require('immutable')
1
+ import fs from 'fs'
2
+ import * as graphql from 'graphql/language'
3
+ import immutable from 'immutable'
4
4
 
5
5
  const List = immutable.List
6
6
  const Set = immutable.Set
@@ -53,12 +53,12 @@ const RESERVED_TYPE = '_Schema_'
53
53
  * Returns a GraphQL type suggestion for a given input type.
54
54
  * Returns `undefined` if no suggestion is available for the type.
55
55
  */
56
- const typeSuggestion = typeName =>
56
+ export const typeSuggestion = (typeName: string) =>
57
57
  TYPE_SUGGESTIONS.filter(([pattern, _]) => {
58
58
  return typeof pattern === 'string' ? pattern === typeName : typeName.match(pattern)
59
59
  }).map(([_, suggestion]) => suggestion)[0]
60
60
 
61
- const loadSchema = filename => {
61
+ const loadSchema = (filename: string) => {
62
62
  try {
63
63
  return fs.readFileSync(filename, 'utf-8')
64
64
  } catch (e) {
@@ -66,7 +66,7 @@ const loadSchema = filename => {
66
66
  }
67
67
  }
68
68
 
69
- const parseSchema = doc => {
69
+ const parseSchema = (doc: string) => {
70
70
  try {
71
71
  return graphql.parse(doc)
72
72
  } catch (e) {
@@ -74,19 +74,19 @@ const parseSchema = doc => {
74
74
  }
75
75
  }
76
76
 
77
- const validateEntityDirective = def =>
78
- def.directives.find(directive => directive.name.value === 'entity')
77
+ const validateEntityDirective = (def: any) =>
78
+ def.directives.find((directive: any) => directive.name.value === 'entity')
79
79
  ? List()
80
80
  : immutable.fromJS([
81
- {
82
- loc: def.loc,
83
- entity: def.name.value,
84
- message: `Defined without @entity directive`,
85
- },
86
- ])
81
+ {
82
+ loc: def.loc,
83
+ entity: def.name.value,
84
+ message: `Defined without @entity directive`,
85
+ },
86
+ ])
87
87
 
88
- const validateEntityID = def => {
89
- let idField = def.fields.find(field => field.name.value === 'id')
88
+ const validateEntityID = (def: any) => {
89
+ let idField = def.fields.find((field: any) => field.name.value === 'id')
90
90
 
91
91
  if (idField === undefined) {
92
92
  return immutable.fromJS([
@@ -117,24 +117,24 @@ const validateEntityID = def => {
117
117
  }
118
118
  }
119
119
 
120
- const validateListFieldType = (def, field) =>
120
+ const validateListFieldType = (def: any, field: any) =>
121
121
  field.type.kind === 'NonNullType' &&
122
- field.type.kind === 'ListType' &&
123
- field.type.type.kind !== 'NonNullType'
122
+ field.type.kind === 'ListType' &&
123
+ field.type.type.kind !== 'NonNullType'
124
124
  ? immutable.fromJS([
125
- {
126
- loc: field.loc,
127
- entity: def.name.value,
128
- message: `\
125
+ {
126
+ loc: field.loc,
127
+ entity: def.name.value,
128
+ message: `\
129
129
  Field '${field.name.value}':
130
130
  Field has type [${field.type.type.name.value}]! but
131
131
  must have type [${field.type.type.name.value}!]!
132
132
 
133
133
  Reason: Lists with null elements are not supported.`,
134
- },
135
- ])
134
+ },
135
+ ])
136
136
  : field.type.kind === 'ListType' && field.type.type.kind !== 'NonNullType'
137
- ? immutable.fromJS([
137
+ ? immutable.fromJS([
138
138
  {
139
139
  loc: field.loc,
140
140
  entity: def.name.value,
@@ -146,15 +146,15 @@ must have type [${field.type.type.name.value}!]
146
146
  Reason: Lists with null elements are not supported.`,
147
147
  },
148
148
  ])
149
- : List()
149
+ : List()
150
150
 
151
- const unwrapType = type => {
152
- let innerTypeFromList = listType =>
151
+ const unwrapType = (type: any) => {
152
+ let innerTypeFromList = (listType: any): any =>
153
153
  listType.type.kind === 'NonNullType'
154
154
  ? innerTypeFromNonNull(listType.type)
155
155
  : listType.type
156
156
 
157
- let innerTypeFromNonNull = nonNullType =>
157
+ let innerTypeFromNonNull = (nonNullType: any): any =>
158
158
  nonNullType.type.kind === 'ListType'
159
159
  ? innerTypeFromList(nonNullType.type)
160
160
  : nonNullType.type
@@ -163,11 +163,11 @@ const unwrapType = type => {
163
163
  return type.kind === 'NonNullType'
164
164
  ? innerTypeFromNonNull(type)
165
165
  : type.kind === 'ListType'
166
- ? innerTypeFromList(type)
167
- : type
166
+ ? innerTypeFromList(type)
167
+ : type
168
168
  }
169
169
 
170
- const gatherLocalTypes = defs =>
170
+ const gatherLocalTypes = (defs: readonly graphql.DefinitionNode[]) =>
171
171
  defs
172
172
  .filter(
173
173
  def =>
@@ -175,50 +175,56 @@ const gatherLocalTypes = defs =>
175
175
  def.kind === 'EnumTypeDefinition' ||
176
176
  def.kind === 'InterfaceTypeDefinition',
177
177
  )
178
- .map(def => def.name.value)
178
+ .map(
179
+ def =>
180
+ // @ts-expect-error TODO: name field does not exist on definition, really?
181
+ def.name.value,
182
+ )
179
183
 
180
- const gatherImportedTypes = defs =>
184
+ const gatherImportedTypes = (defs: readonly graphql.DefinitionNode[]) =>
181
185
  defs
182
186
  .filter(
183
187
  def =>
184
188
  def.kind === 'ObjectTypeDefinition' &&
185
189
  def.name.value == RESERVED_TYPE &&
186
- def.directives.find(
187
- directive =>
190
+ def.directives?.find(
191
+ (directive: any) =>
188
192
  directive.name.value == 'import' &&
189
- directive.arguments.find(argument => argument.name.value == 'types'),
193
+ directive.arguments.find((argument: any) => argument.name.value == 'types'),
190
194
  ),
191
195
  )
192
196
  .map(def =>
197
+ // @ts-expect-error TODO: directives field does not exist on definition, really?
193
198
  def.directives
194
199
  .filter(
195
- directive =>
200
+ (directive: any) =>
196
201
  directive.name.value == 'import' &&
197
- directive.arguments.find(argument => argument.name.value == 'types'),
202
+ directive.arguments.find((argument: any) => argument.name.value == 'types'),
198
203
  )
199
- .map(imp =>
204
+ .map((imp: any) =>
200
205
  imp.arguments.find(
201
- argument =>
206
+ (argument: any) =>
202
207
  argument.name.value == 'types' && argument.value.kind == 'ListValue',
203
208
  ),
204
209
  )
205
- .map(arg =>
206
- arg.value.values.map(type =>
210
+ .map((arg: any) =>
211
+ arg.value.values.map((type: any) =>
207
212
  type.kind == 'StringValue'
208
213
  ? type.value
209
214
  : type.kind == 'ObjectValue' &&
210
215
  type.fields.find(
211
- field => field.name.value == 'as' && field.value.kind == 'StringValue',
216
+ (field: any) =>
217
+ field.name.value == 'as' && field.value.kind == 'StringValue',
212
218
  )
213
- ? type.fields.find(field => field.name.value == 'as').value.value
214
- : undefined,
219
+ ? type.fields.find((field: any) => field.name.value == 'as').value.value
220
+ : undefined,
215
221
  ),
216
222
  ),
217
223
  )
218
224
  .reduce(
219
225
  (flattened, types_args) =>
220
226
  flattened.concat(
221
- types_args.reduce((flattened, types_arg) => {
227
+ types_args.reduce((flattened: any, types_arg: any[]) => {
222
228
  types_arg.forEach(type => (type ? flattened.push(type) : undefined))
223
229
  return flattened
224
230
  }, []),
@@ -226,21 +232,22 @@ const gatherImportedTypes = defs =>
226
232
  [],
227
233
  )
228
234
 
229
- const entityTypeByName = (defs, name) =>
235
+ const entityTypeByName = (defs: any[], name: string) =>
230
236
  defs
231
237
  .filter(
232
238
  def =>
233
239
  def.kind === 'InterfaceTypeDefinition' ||
234
- (def.kind === 'ObjectTypeDefinition' && def.directives.find(directive => directive.name.value === 'entity'))
240
+ (def.kind === 'ObjectTypeDefinition' &&
241
+ def.directives.find((directive: any) => directive.name.value === 'entity')),
235
242
  )
236
243
  .find(def => def.name.value === name)
237
244
 
238
- const fieldTargetEntityName = field => unwrapType(field.type).name.value
245
+ const fieldTargetEntityName = (field: any) => unwrapType(field.type).name.value
239
246
 
240
- const fieldTargetEntity = (defs, field) =>
247
+ const fieldTargetEntity = (defs: any[], field: any) =>
241
248
  entityTypeByName(defs, fieldTargetEntityName(field))
242
249
 
243
- const validateInnerFieldType = (defs, def, field) => {
250
+ const validateInnerFieldType = (defs: any[], def: any, field: any) => {
244
251
  let innerType = unwrapType(field.type)
245
252
 
246
253
  // Get the name of the type
@@ -260,40 +267,43 @@ const validateInnerFieldType = (defs, def, field) => {
260
267
  return availableTypes.includes(typeName)
261
268
  ? List()
262
269
  : immutable.fromJS([
263
- {
264
- loc: field.loc,
265
- entity: def.name.value,
266
- message: `\
270
+ {
271
+ loc: field.loc,
272
+ entity: def.name.value,
273
+ message: `\
267
274
  Field '${field.name.value}': \
268
- Unknown type '${typeName}'.${suggestion !== undefined ? ` Did you mean '${suggestion}'?` : ''
275
+ Unknown type '${typeName}'.${
276
+ suggestion !== undefined ? ` Did you mean '${suggestion}'?` : ''
269
277
  }`,
270
- },
271
- ])
278
+ },
279
+ ])
272
280
  }
273
281
 
274
- const validateEntityFieldType = (defs, def, field) =>
282
+ const validateEntityFieldType = (defs: any[], def: any, field: any) =>
275
283
  List.of(
276
284
  ...validateListFieldType(def, field),
277
285
  ...validateInnerFieldType(defs, def, field),
278
286
  )
279
287
 
280
- const validateEntityFieldArguments = (defs, def, field) =>
288
+ const validateEntityFieldArguments = (_defs: any[], def: any, field: any) =>
281
289
  field.arguments.length > 0
282
290
  ? immutable.fromJS([
283
- {
284
- loc: field.loc,
285
- entity: def.name.value,
286
- message: `\
291
+ {
292
+ loc: field.loc,
293
+ entity: def.name.value,
294
+ message: `\
287
295
  Field '${field.name.value}': \
288
296
  Field arguments are not supported.`,
289
- },
290
- ])
297
+ },
298
+ ])
291
299
  : List()
292
300
 
293
- const entityFieldExists = (entityDef, name) =>
294
- entityDef.fields.find(field => field.name.value === name) !== undefined
295
-
296
- const validateDerivedFromDirective = (defs, def, field, directive) => {
301
+ const validateDerivedFromDirective = (
302
+ defs: any[],
303
+ def: any,
304
+ field: any,
305
+ directive: any,
306
+ ) => {
297
307
  // Validate that there is a `field` argument and nothing else
298
308
  if (directive.arguments.length !== 1 || directive.arguments[0].name.value !== 'field') {
299
309
  return immutable.fromJS([
@@ -329,7 +339,7 @@ Value of the @derivedFrom 'field' argument must be a string`,
329
339
  }
330
340
 
331
341
  let derivedFromField = targetEntity.fields.find(
332
- field => field.name.value === directive.arguments[0].value.value,
342
+ (field: any) => field.name.value === directive.arguments[0].value.value,
333
343
  )
334
344
 
335
345
  if (derivedFromField === undefined) {
@@ -350,7 +360,11 @@ does not exist on type '${targetEntity.name.value}'`,
350
360
 
351
361
  // The field we are deriving from must either have type 'def' or one of the
352
362
  // interface types that 'def' is implementing
353
- if (!backRefEntity || (backRefEntity.name.value !== def.name.value && !def.interfaces.find(intf => intf.name.value === backRefEntity.name.value))) {
363
+ if (
364
+ !backRefEntity ||
365
+ (backRefEntity.name.value !== def.name.value &&
366
+ !def.interfaces.find((intf: any) => intf.name.value === backRefEntity.name.value))
367
+ ) {
354
368
  return immutable.fromJS([
355
369
  {
356
370
  loc: directive.loc,
@@ -368,21 +382,26 @@ or one of the interface types that '${def.name.value}' implements`,
368
382
  return List()
369
383
  }
370
384
 
371
- const validateEntityFieldDirective = (defs, def, field, directive) =>
385
+ const validateEntityFieldDirective = (
386
+ defs: any[],
387
+ def: any,
388
+ field: any,
389
+ directive: any,
390
+ ) =>
372
391
  directive.name.value === 'derivedFrom'
373
392
  ? validateDerivedFromDirective(defs, def, field, directive)
374
393
  : List()
375
394
 
376
- const validateEntityFieldDirectives = (defs, def, field) =>
395
+ const validateEntityFieldDirectives = (defs: any[], def: any, field: any) =>
377
396
  field.directives.reduce(
378
- (errors, directive) =>
397
+ (errors: any[], directive: any) =>
379
398
  errors.concat(validateEntityFieldDirective(defs, def, field, directive)),
380
399
  List(),
381
400
  )
382
401
 
383
- const validateEntityFields = (defs, def) =>
402
+ const validateEntityFields = (defs: any, def: any) =>
384
403
  def.fields.reduce(
385
- (errors, field) =>
404
+ (errors: any[], field: any) =>
386
405
  errors
387
406
  .concat(validateEntityFieldType(defs, def, field))
388
407
  .concat(validateEntityFieldArguments(defs, def, field))
@@ -390,92 +409,94 @@ const validateEntityFields = (defs, def) =>
390
409
  List(),
391
410
  )
392
411
 
393
- const validateNoImportDirective = def =>
394
- def.directives.find(directive => directive.name.value == 'import')
412
+ const validateNoImportDirective = (def: any) =>
413
+ def.directives.find((directive: any) => directive.name.value == 'import')
395
414
  ? List([
396
- immutable.fromJS({
397
- loc: def.name.loc,
398
- entity: def.name.value,
399
- message: `@import directive only allowed on '${RESERVED_TYPE}' type`,
400
- }),
401
- ])
415
+ immutable.fromJS({
416
+ loc: def.name.loc,
417
+ entity: def.name.value,
418
+ message: `@import directive only allowed on '${RESERVED_TYPE}' type`,
419
+ }),
420
+ ])
402
421
  : List()
403
422
 
404
- const validateNoFulltext = def =>
405
- def.directives.find(directive => directive.name.value == 'fulltext')
423
+ const validateNoFulltext = (def: any) =>
424
+ def.directives.find((directive: any) => directive.name.value == 'fulltext')
406
425
  ? List([
407
- immutable.fromJS({
408
- loc: def.name.loc,
409
- entity: def.name.value,
410
- message: `@fulltext directive only allowed on '${RESERVED_TYPE}' type`,
411
- }),
412
- ])
426
+ immutable.fromJS({
427
+ loc: def.name.loc,
428
+ entity: def.name.value,
429
+ message: `@fulltext directive only allowed on '${RESERVED_TYPE}' type`,
430
+ }),
431
+ ])
413
432
  : List()
414
433
 
415
- const validateFulltextFields = (def, directive) => {
416
- return directive.arguments.reduce((errors, argument) => {
434
+ const validateFulltextFields = (def: any, directive: any) => {
435
+ return directive.arguments.reduce((errors: any[], argument: any) => {
417
436
  return errors.concat(
418
437
  ['name', 'language', 'algorithm', 'include'].includes(argument.name.value)
419
438
  ? List([])
420
439
  : List([
421
- immutable.fromJS({
422
- loc: directive.name.loc,
423
- entity: def.name.value,
424
- directive: fulltextDirectiveName(directive),
425
- message: `found invalid argument: '${argument.name.value}', @fulltext directives only allow 'name', 'language', 'algorithm', and 'includes' arguments`,
426
- }),
427
- ]),
440
+ immutable.fromJS({
441
+ loc: directive.name.loc,
442
+ entity: def.name.value,
443
+ directive: fulltextDirectiveName(directive),
444
+ message: `found invalid argument: '${argument.name.value}', @fulltext directives only allow 'name', 'language', 'algorithm', and 'includes' arguments`,
445
+ }),
446
+ ]),
428
447
  )
429
448
  }, List([]))
430
449
  }
431
450
 
432
- const validateFulltextName = (def, directive) => {
433
- let name = directive.arguments.find(argument => argument.name.value == 'name')
451
+ const validateFulltextName = (def: any, directive: any) => {
452
+ let name = directive.arguments.find((argument: any) => argument.name.value == 'name')
434
453
  return name
435
454
  ? validateFulltextArgumentName(def, directive, name)
436
455
  : List([
437
- immutable.fromJS({
438
- loc: directive.name.loc,
439
- entity: def.name.value,
440
- directive: fulltextDirectiveName(directive),
441
- message: `@fulltext argument 'name' must be specified`,
442
- }),
443
- ])
456
+ immutable.fromJS({
457
+ loc: directive.name.loc,
458
+ entity: def.name.value,
459
+ directive: fulltextDirectiveName(directive),
460
+ message: `@fulltext argument 'name' must be specified`,
461
+ }),
462
+ ])
444
463
  }
445
464
 
446
- const validateFulltextArgumentName = (def, directive, argument) => {
465
+ const validateFulltextArgumentName = (def: any, directive: any, argument: any) => {
447
466
  return argument.value.kind != 'StringValue'
448
467
  ? List([
449
- immutable.fromJS({
450
- loc: directive.name.loc,
451
- entity: def.name.value,
452
- directive: fulltextDirectiveName(directive),
453
- message: `@fulltext argument 'name' must be a string`,
454
- }),
455
- ])
468
+ immutable.fromJS({
469
+ loc: directive.name.loc,
470
+ entity: def.name.value,
471
+ directive: fulltextDirectiveName(directive),
472
+ message: `@fulltext argument 'name' must be a string`,
473
+ }),
474
+ ])
456
475
  : List([])
457
476
  }
458
477
 
459
- const fulltextDirectiveName = directive => {
460
- let arg = directive.arguments.find(argument => argument.name.value == 'name')
478
+ const fulltextDirectiveName = (directive: any) => {
479
+ let arg = directive.arguments.find((argument: any) => argument.name.value == 'name')
461
480
  return arg ? arg.value.value : 'Other'
462
481
  }
463
482
 
464
- const validateFulltextLanguage = (def, directive) => {
465
- let language = directive.arguments.find(argument => argument.name.value == 'language')
483
+ const validateFulltextLanguage = (def: any, directive: any) => {
484
+ let language = directive.arguments.find(
485
+ (argument: any) => argument.name.value == 'language',
486
+ )
466
487
  return language
467
488
  ? validateFulltextArgumentLanguage(def, directive, language)
468
489
  : List([
469
- immutable.fromJS({
470
- loc: directive.name.loc,
471
- entity: def.name.value,
472
- directive: fulltextDirectiveName(directive),
473
- message: `@fulltext argument 'language' must be specified`,
474
- }),
475
- ])
490
+ immutable.fromJS({
491
+ loc: directive.name.loc,
492
+ entity: def.name.value,
493
+ directive: fulltextDirectiveName(directive),
494
+ message: `@fulltext argument 'language' must be specified`,
495
+ }),
496
+ ])
476
497
  }
477
498
 
478
- const validateFulltextArgumentLanguage = (def, directive, argument) => {
499
+ const validateFulltextArgumentLanguage = (def: any, directive: any, argument: any) => {
479
500
  let languages = [
480
501
  'simple',
481
502
  'da',
@@ -519,21 +540,23 @@ const validateFulltextArgumentLanguage = (def, directive, argument) => {
519
540
  }
520
541
  }
521
542
 
522
- const validateFulltextAlgorithm = (def, directive) => {
523
- let algorithm = directive.arguments.find(argument => argument.name.value == 'algorithm')
543
+ const validateFulltextAlgorithm = (def: any, directive: any) => {
544
+ let algorithm = directive.arguments.find(
545
+ (argument: any) => argument.name.value == 'algorithm',
546
+ )
524
547
  return algorithm
525
548
  ? validateFulltextArgumentAlgorithm(def, directive, algorithm)
526
549
  : List([
527
- immutable.fromJS({
528
- loc: directive.name.loc,
529
- entity: def.name.value,
530
- directive: fulltextDirectiveName(directive),
531
- message: `@fulltext argument 'algorithm' must be specified`,
532
- }),
533
- ])
550
+ immutable.fromJS({
551
+ loc: directive.name.loc,
552
+ entity: def.name.value,
553
+ directive: fulltextDirectiveName(directive),
554
+ message: `@fulltext argument 'algorithm' must be specified`,
555
+ }),
556
+ ])
534
557
  }
535
558
 
536
- const validateFulltextArgumentAlgorithm = (def, directive, argument) => {
559
+ const validateFulltextArgumentAlgorithm = (def: any, directive: any, argument: any) => {
537
560
  if (argument.value.kind != 'EnumValue') {
538
561
  return List([
539
562
  immutable.fromJS({
@@ -557,8 +580,10 @@ const validateFulltextArgumentAlgorithm = (def, directive, argument) => {
557
580
  }
558
581
  }
559
582
 
560
- const validateFulltextInclude = (def, directive) => {
561
- let include = directive.arguments.find(argument => argument.name.value == 'include')
583
+ const validateFulltextInclude = (def: any, directive: any) => {
584
+ let include = directive.arguments.find(
585
+ (argument: any) => argument.name.value == 'include',
586
+ )
562
587
  if (include) {
563
588
  if (include.value.kind != 'ListValue') {
564
589
  return List([
@@ -571,7 +596,7 @@ const validateFulltextInclude = (def, directive) => {
571
596
  ])
572
597
  }
573
598
  return include.value.values.reduce(
574
- (errors, type) =>
599
+ (errors: any, type: any) =>
575
600
  errors.concat(validateFulltextArgumentInclude(def, directive, type)),
576
601
  List(),
577
602
  )
@@ -587,7 +612,7 @@ const validateFulltextInclude = (def, directive) => {
587
612
  }
588
613
  }
589
614
 
590
- const validateFulltextArgumentInclude = (def, directive, argument) => {
615
+ const validateFulltextArgumentInclude = (def: any, directive: any, argument: any) => {
591
616
  if (argument.kind != 'ObjectValue') {
592
617
  return List([
593
618
  immutable.fromJS({
@@ -609,13 +634,13 @@ const validateFulltextArgumentInclude = (def, directive, argument) => {
609
634
  ])
610
635
  }
611
636
  return argument.fields.reduce(
612
- (errors, field) =>
637
+ (errors: any[], field: any) =>
613
638
  errors.concat(validateFulltextArgumentIncludeFields(def, directive, field)),
614
639
  List([]),
615
640
  )
616
641
  }
617
642
 
618
- const validateFulltextArgumentIncludeFields = (def, directive, field) => {
643
+ const validateFulltextArgumentIncludeFields = (def: any, directive: any, field: any) => {
619
644
  if (!['entity', 'fields'].includes(field.name.value)) {
620
645
  return List([
621
646
  immutable.fromJS({
@@ -646,7 +671,7 @@ const validateFulltextArgumentIncludeFields = (def, directive, field) => {
646
671
  ])
647
672
  } else if (field.name.value == 'fields' && field.value.kind == 'ListValue') {
648
673
  return field.value.values.reduce(
649
- (errors, field) =>
674
+ (errors: any[], field: any) =>
650
675
  errors.concat(
651
676
  validateFulltextArgumentIncludeFieldsObjects(def, directive, field),
652
677
  ),
@@ -657,7 +682,11 @@ const validateFulltextArgumentIncludeFields = (def, directive, field) => {
657
682
  }
658
683
  }
659
684
 
660
- const validateFulltextArgumentIncludeFieldsObjects = (def, directive, argument) => {
685
+ const validateFulltextArgumentIncludeFieldsObjects = (
686
+ def: any,
687
+ directive: any,
688
+ argument: any,
689
+ ) => {
661
690
  if (argument.kind != 'ObjectValue') {
662
691
  return List([
663
692
  immutable.fromJS({
@@ -669,7 +698,7 @@ const validateFulltextArgumentIncludeFieldsObjects = (def, directive, argument)
669
698
  ])
670
699
  } else {
671
700
  return argument.fields.reduce(
672
- (errors, field) =>
701
+ (errors: any[], field: any) =>
673
702
  errors.concat(
674
703
  validateFulltextArgumentIncludeArgumentFieldsObject(def, directive, field),
675
704
  ),
@@ -678,7 +707,11 @@ const validateFulltextArgumentIncludeFieldsObjects = (def, directive, argument)
678
707
  }
679
708
  }
680
709
 
681
- const validateFulltextArgumentIncludeArgumentFieldsObject = (def, directive, field) => {
710
+ const validateFulltextArgumentIncludeArgumentFieldsObject = (
711
+ def: any,
712
+ directive: any,
713
+ field: any,
714
+ ) => {
682
715
  if (!['name'].includes(field.name.value)) {
683
716
  return List([
684
717
  immutable.fromJS({
@@ -703,8 +736,8 @@ const validateFulltextArgumentIncludeArgumentFieldsObject = (def, directive, fie
703
736
  }
704
737
 
705
738
  const importDirectiveTypeValidators = {
706
- StringValue: (_def, _directive, _type) => List(),
707
- ObjectValue: (def, directive, type) => {
739
+ StringValue: (_def: any, _directive: any, _type: any) => List(),
740
+ ObjectValue: (def: any, directive: any, type: any) => {
708
741
  let errors = List()
709
742
  if (type.fields.length != 2) {
710
743
  return errors.push(
@@ -715,7 +748,7 @@ const importDirectiveTypeValidators = {
715
748
  }),
716
749
  )
717
750
  }
718
- return type.fields.reduce((errors, field) => {
751
+ return type.fields.reduce((errors: any[], field: any) => {
719
752
  if (!['name', 'as'].includes(field.name.value)) {
720
753
  return errors.push(
721
754
  immutable.fromJS({
@@ -739,19 +772,27 @@ const importDirectiveTypeValidators = {
739
772
  },
740
773
  }
741
774
 
742
- const validateImportDirectiveType = (def, directive, type) => {
775
+ const validateImportDirectiveType = (
776
+ def: any,
777
+ directive: any,
778
+ type: { kind: keyof typeof importDirectiveTypeValidators },
779
+ ) => {
743
780
  return importDirectiveTypeValidators[type.kind]
744
781
  ? importDirectiveTypeValidators[type.kind](def, directive, type)
745
782
  : List([
746
- immutable.fromJS({
747
- loc: directive.name.loc,
748
- entity: def.name.value,
749
- message: `Import must be one of "Name" or { name: "Name", as: "Alias" }`,
750
- }),
751
- ])
783
+ immutable.fromJS({
784
+ loc: directive.name.loc,
785
+ entity: def.name.value,
786
+ message: `Import must be one of "Name" or { name: "Name", as: "Alias" }`,
787
+ }),
788
+ ])
752
789
  }
753
790
 
754
- const validateImportDirectiveArgumentTypes = (def, directive, argument) => {
791
+ const validateImportDirectiveArgumentTypes = (
792
+ def: any,
793
+ directive: any,
794
+ argument: any,
795
+ ) => {
755
796
  if (argument.value.kind != 'ListValue') {
756
797
  return List([
757
798
  immutable.fromJS({
@@ -763,12 +804,13 @@ const validateImportDirectiveArgumentTypes = (def, directive, argument) => {
763
804
  }
764
805
 
765
806
  return argument.value.values.reduce(
766
- (errors, type) => errors.concat(validateImportDirectiveType(def, directive, type)),
807
+ (errors: any[], type: any) =>
808
+ errors.concat(validateImportDirectiveType(def, directive, type)),
767
809
  List(),
768
810
  )
769
811
  }
770
812
 
771
- const validateImportDirectiveArgumentFrom = (def, directive, argument) => {
813
+ const validateImportDirectiveArgumentFrom = (def: any, directive: any, argument: any) => {
772
814
  if (argument.value.kind != 'ObjectValue') {
773
815
  return List([
774
816
  immutable.fromJS({
@@ -789,7 +831,7 @@ const validateImportDirectiveArgumentFrom = (def, directive, argument) => {
789
831
  ])
790
832
  }
791
833
 
792
- return argument.value.fields.reduce((errors, field) => {
834
+ return argument.value.fields.reduce((errors: any[], field: any) => {
793
835
  if (!['name', 'id'].includes(field.name.value)) {
794
836
  return errors.push(
795
837
  immutable.fromJS({
@@ -812,56 +854,56 @@ const validateImportDirectiveArgumentFrom = (def, directive, argument) => {
812
854
  }, List())
813
855
  }
814
856
 
815
- const validateImportDirectiveFields = (def, directive) => {
816
- return directive.arguments.reduce((errors, argument) => {
857
+ const validateImportDirectiveFields = (def: any, directive: any) => {
858
+ return directive.arguments.reduce((errors: any[], argument: any) => {
817
859
  return errors.concat(
818
860
  ['types', 'from'].includes(argument.name.value)
819
861
  ? List([])
820
862
  : List([
821
- immutable.fromJS({
822
- loc: directive.name.loc,
823
- entity: def.name.value,
824
- message: `found invalid argument: '${argument.name.value}', @import directives only allow 'types' and 'from' arguments`,
825
- }),
826
- ]),
863
+ immutable.fromJS({
864
+ loc: directive.name.loc,
865
+ entity: def.name.value,
866
+ message: `found invalid argument: '${argument.name.value}', @import directives only allow 'types' and 'from' arguments`,
867
+ }),
868
+ ]),
827
869
  )
828
870
  }, List([]))
829
871
  }
830
872
 
831
- const validateImportDirectiveTypes = (def, directive) => {
832
- let types = directive.arguments.find(argument => argument.name.value == 'types')
873
+ const validateImportDirectiveTypes = (def: any, directive: any) => {
874
+ let types = directive.arguments.find((argument: any) => argument.name.value == 'types')
833
875
  return types
834
876
  ? validateImportDirectiveArgumentTypes(def, directive, types)
835
877
  : List([
836
- immutable.fromJS({
837
- loc: directive.name.loc,
838
- entity: def.name.value,
839
- message: `@import argument 'types' must be specified`,
840
- }),
841
- ])
878
+ immutable.fromJS({
879
+ loc: directive.name.loc,
880
+ entity: def.name.value,
881
+ message: `@import argument 'types' must be specified`,
882
+ }),
883
+ ])
842
884
  }
843
885
 
844
- const validateImportDirectiveFrom = (def, directive) => {
845
- let from = directive.arguments.find(argument => argument.name.value == 'from')
886
+ const validateImportDirectiveFrom = (def: any, directive: any) => {
887
+ let from = directive.arguments.find((argument: any) => argument.name.value == 'from')
846
888
  return from
847
889
  ? validateImportDirectiveArgumentFrom(def, directive, from)
848
890
  : List([
849
- immutable.fromJS({
850
- loc: directive.name.loc,
851
- entity: def.name.value,
852
- message: `@import argument 'from' must be specified`,
853
- }),
854
- ])
891
+ immutable.fromJS({
892
+ loc: directive.name.loc,
893
+ entity: def.name.value,
894
+ message: `@import argument 'from' must be specified`,
895
+ }),
896
+ ])
855
897
  }
856
898
 
857
- const validateImportDirective = (def, directive) =>
899
+ const validateImportDirective = (def: any, directive: any) =>
858
900
  List.of(
859
901
  ...validateImportDirectiveFields(def, directive),
860
902
  ...validateImportDirectiveTypes(def, directive),
861
903
  ...validateImportDirectiveFrom(def, directive),
862
904
  )
863
905
 
864
- const validateFulltext = (def, directive) =>
906
+ const validateFulltext = (def: any, directive: any) =>
865
907
  List.of(
866
908
  ...validateFulltextFields(def, directive),
867
909
  ...validateFulltextName(def, directive),
@@ -870,7 +912,7 @@ const validateFulltext = (def, directive) =>
870
912
  ...validateFulltextInclude(def, directive),
871
913
  )
872
914
 
873
- const validateSubgraphSchemaDirective = (def, directive) => {
915
+ const validateSubgraphSchemaDirective = (def: any, directive: any) => {
874
916
  if (directive.name.value == 'import') {
875
917
  return validateImportDirective(def, directive)
876
918
  } else if (directive.name.value == 'fulltext') {
@@ -886,51 +928,58 @@ const validateSubgraphSchemaDirective = (def, directive) => {
886
928
  }
887
929
  }
888
930
 
889
- const validateSubgraphSchemaDirectives = def =>
931
+ const validateSubgraphSchemaDirectives = (def: any) =>
890
932
  def.directives.reduce(
891
- (errors, directive) => errors.concat(validateSubgraphSchemaDirective(def, directive)),
933
+ (errors: any[], directive: any) =>
934
+ errors.concat(validateSubgraphSchemaDirective(def, directive)),
892
935
  List(),
893
936
  )
894
937
 
895
- const validateTypeHasNoFields = def =>
938
+ const validateTypeHasNoFields = (def: any) =>
896
939
  def.fields.length
897
940
  ? List([
898
- immutable.fromJS({
899
- loc: def.name.loc,
900
- entity: def.name.value,
901
- message: `${def.name.value} type is not allowed any fields by convention`,
902
- }),
903
- ])
941
+ immutable.fromJS({
942
+ loc: def.name.loc,
943
+ entity: def.name.value,
944
+ message: `${def.name.value} type is not allowed any fields by convention`,
945
+ }),
946
+ ])
904
947
  : List()
905
948
 
906
- const validateAtLeastOneExtensionField = def => List()
949
+ const validateAtLeastOneExtensionField = (_def: any) => List()
907
950
 
908
951
  const typeDefinitionValidators = {
909
- ObjectTypeDefinition: (defs, def) =>
952
+ ObjectTypeDefinition: (defs: any[], def: any) =>
910
953
  def.name && def.name.value == RESERVED_TYPE
911
954
  ? List.of(...validateSubgraphSchemaDirectives(def), ...validateTypeHasNoFields(def))
912
955
  : List.of(
913
- ...validateEntityDirective(def),
914
- ...validateEntityID(def),
915
- ...validateEntityFields(defs, def),
916
- ...validateNoImportDirective(def),
917
- ...validateNoFulltext(def),
918
- ),
919
- ObjectTypeExtension: (_defs, def) => validateAtLeastOneExtensionField(def),
956
+ ...validateEntityDirective(def),
957
+ ...validateEntityID(def),
958
+ ...validateEntityFields(defs, def),
959
+ ...validateNoImportDirective(def),
960
+ ...validateNoFulltext(def),
961
+ ),
962
+ ObjectTypeExtension: (_defs: any[], def: any) => validateAtLeastOneExtensionField(def),
920
963
  }
921
964
 
922
- const validateTypeDefinition = (defs, def) =>
965
+ const validateTypeDefinition = (
966
+ defs: any,
967
+ def: { kind: keyof typeof typeDefinitionValidators },
968
+ ) =>
923
969
  typeDefinitionValidators[def.kind] !== undefined
924
970
  ? typeDefinitionValidators[def.kind](defs, def)
925
971
  : List()
926
972
 
927
- const validateTypeDefinitions = defs =>
928
- defs.reduce((errors, def) => errors.concat(validateTypeDefinition(defs, def)), List())
973
+ const validateTypeDefinitions = (defs: any) =>
974
+ defs.reduce(
975
+ (errors: any[], def: any) => errors.concat(validateTypeDefinition(defs, def)),
976
+ List(),
977
+ )
929
978
 
930
- const validateNamingCollisionsInTypes = types => {
979
+ const validateNamingCollisionsInTypes = (types: any) => {
931
980
  let seen = Set()
932
981
  let conflicting = Set()
933
- return types.reduce((errors, type) => {
982
+ return types.reduce((errors: immutable.List<any>, type: any) => {
934
983
  if (seen.has(type) && !conflicting.has(type)) {
935
984
  errors = errors.push(
936
985
  immutable.fromJS({
@@ -947,10 +996,10 @@ const validateNamingCollisionsInTypes = types => {
947
996
  }, List())
948
997
  }
949
998
 
950
- const validateNamingCollisions = (local, imported) =>
999
+ const validateNamingCollisions = (local: any[], imported: any) =>
951
1000
  validateNamingCollisionsInTypes(local.concat(imported))
952
1001
 
953
- const validateSchema = filename => {
1002
+ export const validateSchema = (filename: string) => {
954
1003
  let doc = loadSchema(filename)
955
1004
  let schema = parseSchema(doc)
956
1005
  return List.of(
@@ -961,5 +1010,3 @@ const validateSchema = filename => {
961
1010
  ),
962
1011
  )
963
1012
  }
964
-
965
- module.exports = { typeSuggestion, validateSchema }