@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,52 +1,83 @@
1
- const { validateStudioNetwork, allowedStudioNetworks } = require('./studio')
1
+ import { validateStudioNetwork, allowedStudioNetworks } from './studio'
2
2
 
3
3
  describe('Version Command Helpers', () => {
4
4
  describe('validateStudioNetwork', () => {
5
5
  describe("When it's studio", () => {
6
6
  test("And it's Ethereum mainnet", () => {
7
- expect(() => validateStudioNetwork({
8
- studio: true,
9
- network: 'mainnet',
10
- }))
11
- .not
12
- .toThrow(new Error(`The Subgraph Studio only allows subgraphs for these networks: ${allowedStudioNetworks.join(', ')}`))
7
+ expect(() =>
8
+ validateStudioNetwork({
9
+ studio: true,
10
+ network: 'mainnet',
11
+ }),
12
+ ).not.toThrow(
13
+ new Error(
14
+ `The Subgraph Studio only allows subgraphs for these networks: ${allowedStudioNetworks.join(
15
+ ', ',
16
+ )}`,
17
+ ),
18
+ )
13
19
  })
14
20
 
15
21
  test("And it's Gnosis chain", () => {
16
- expect(() => validateStudioNetwork({
17
- studio: true,
18
- network: 'gnosis',
19
- }))
20
- .not
21
- .toThrow(new Error(`The Subgraph Studio only allows subgraphs for these networks: ${allowedStudioNetworks.join(', ')}`))
22
+ expect(() =>
23
+ validateStudioNetwork({
24
+ studio: true,
25
+ network: 'gnosis',
26
+ }),
27
+ ).not.toThrow(
28
+ new Error(
29
+ `The Subgraph Studio only allows subgraphs for these networks: ${allowedStudioNetworks.join(
30
+ ', ',
31
+ )}`,
32
+ ),
33
+ )
22
34
  })
23
35
 
24
36
  test("And it's NOT an allowed network", () => {
25
- expect(() => validateStudioNetwork({
26
- product: 'subgraph-studio',
27
- network: 'celo',
28
- }))
29
- .toThrow(new Error(`The Subgraph Studio only allows subgraphs for these networks: ${allowedStudioNetworks.join(', ')}`))
37
+ expect(() =>
38
+ validateStudioNetwork({
39
+ product: 'subgraph-studio',
40
+ network: 'celo',
41
+ }),
42
+ ).toThrow(
43
+ new Error(
44
+ `The Subgraph Studio only allows subgraphs for these networks: ${allowedStudioNetworks.join(
45
+ ', ',
46
+ )}`,
47
+ ),
48
+ )
30
49
  })
31
50
  })
32
51
 
33
52
  describe("When it's NOT studio", () => {
34
53
  test("And it's Rinkeby", () => {
35
- expect(() => validateStudioNetwork({
36
- studio: false,
37
- network: 'rinkeby',
38
- }))
39
- .not
40
- .toThrow(new Error(`The Subgraph Studio only allows subgraphs for these networks: ${allowedStudioNetworks.join(', ')}`))
54
+ expect(() =>
55
+ validateStudioNetwork({
56
+ studio: false,
57
+ network: 'rinkeby',
58
+ }),
59
+ ).not.toThrow(
60
+ new Error(
61
+ `The Subgraph Studio only allows subgraphs for these networks: ${allowedStudioNetworks.join(
62
+ ', ',
63
+ )}`,
64
+ ),
65
+ )
41
66
  })
42
67
 
43
68
  test("And it's NOT an allowed network", () => {
44
- expect(() => validateStudioNetwork({
45
- product: 'hosted-service',
46
- network: 'celo',
47
- }))
48
- .not
49
- .toThrow(new Error(`The Subgraph Studio only allows subgraphs for these networks: ${allowedStudioNetworks.join(', ')}`))
69
+ expect(() =>
70
+ validateStudioNetwork({
71
+ product: 'hosted-service',
72
+ network: 'celo',
73
+ }),
74
+ ).not.toThrow(
75
+ new Error(
76
+ `The Subgraph Studio only allows subgraphs for these networks: ${allowedStudioNetworks.join(
77
+ ', ',
78
+ )}`,
79
+ ),
80
+ )
50
81
  })
51
82
  })
52
83
  })
@@ -0,0 +1,20 @@
1
+ const allowedStudioNetworks = ['mainnet', 'rinkeby', 'goerli', 'gnosis'] as const
2
+
3
+ const validateStudioNetwork = ({ studio, product, network }:{
4
+ studio?: boolean
5
+ product?: 'subgraph-studio'
6
+ network: typeof allowedStudioNetworks[number]
7
+ }) => {
8
+ let isStudio = studio || product === 'subgraph-studio'
9
+ let isAllowedNetwork = allowedStudioNetworks.includes(network)
10
+
11
+ if (isStudio && !isAllowedNetwork) {
12
+ throw new Error(
13
+ `The Subgraph Studio only allows subgraphs for these networks: ${allowedStudioNetworks.join(
14
+ ', ',
15
+ )}`,
16
+ )
17
+ }
18
+ }
19
+
20
+ export { allowedStudioNetworks, validateStudioNetwork }
@@ -1,4 +1,7 @@
1
- const validateSubgraphName = (name, { allowSimpleName }) => {
1
+ const validateSubgraphName = (
2
+ name: string,
3
+ { allowSimpleName }: { allowSimpleName: string },
4
+ ) => {
2
5
  if (allowSimpleName) {
3
6
  return name
4
7
  } else {
@@ -13,12 +16,9 @@ You can bypass this check with --allow-simple-name.`)
13
16
  }
14
17
  }
15
18
 
16
- const getSubgraphBasename = name => {
19
+ const getSubgraphBasename = (name: string) => {
17
20
  let segments = name.split('/', 2)
18
21
  return segments[segments.length - 1]
19
22
  }
20
23
 
21
- module.exports = {
22
- validateSubgraphName,
23
- getSubgraphBasename,
24
- }
24
+ export { validateSubgraphName, getSubgraphBasename }
@@ -1,15 +1,12 @@
1
- const semver = require('semver')
2
- const graphTsUtil = require('../migrations/util/versions')
3
- const manifestUtil = require('../migrations/util/load-manifest')
1
+ import semver from 'semver'
2
+ import * as graphTsUtil from '../migrations/util/versions'
3
+ import * as manifestUtil from '../migrations/util/load-manifest'
4
4
 
5
5
  const assertManifestApiVersion = async (manifestPath, minimumApiVersion) => {
6
6
  let manifest = await manifestUtil.loadManifest(manifestPath)
7
7
 
8
8
  let lessThanMinimumVersion = manifestApiVersion =>
9
- semver.lt(
10
- manifestApiVersion,
11
- minimumApiVersion,
12
- )
9
+ semver.lt(manifestApiVersion, minimumApiVersion)
13
10
 
14
11
  let isLessThanMinimumVersion = false
15
12
 
@@ -20,25 +17,26 @@ const assertManifestApiVersion = async (manifestPath, minimumApiVersion) => {
20
17
  dataSource &&
21
18
  dataSource.mapping &&
22
19
  dataSource.mapping.apiVersion &&
23
- lessThanMinimumVersion(dataSource.mapping.apiVersion)
20
+ lessThanMinimumVersion(dataSource.mapping.apiVersion),
24
21
  )
25
22
  }
26
23
 
27
24
  if (manifest.templates && Array.isArray(manifest.templates)) {
28
- isLessThanMinimumVersion = isLessThanMinimumVersion ||
25
+ isLessThanMinimumVersion =
26
+ isLessThanMinimumVersion ||
29
27
  manifest.templates.some(
30
28
  template =>
31
29
  template &&
32
30
  template.mapping &&
33
31
  template.mapping.apiVersion &&
34
- lessThanMinimumVersion(template.mapping.apiVersion)
32
+ lessThanMinimumVersion(template.mapping.apiVersion),
35
33
  )
36
34
  }
37
35
  }
38
36
 
39
37
  if (isLessThanMinimumVersion) {
40
38
  throw new Error(
41
- `The current version of graph-cli can't be used with mappings on apiVersion less than '${minimumApiVersion}'`
39
+ `The current version of graph-cli can't be used with mappings on apiVersion less than '${minimumApiVersion}'`,
42
40
  )
43
41
  }
44
42
  }
@@ -57,12 +55,9 @@ const assertGraphTsVersion = async (sourceDir, minimumGraphTsVersion) => {
57
55
  if (graphTsVersion && semver.lt(semver.coerce(graphTsVersion), minimumGraphTsVersion)) {
58
56
  throw new Error(
59
57
  `To use this version of the graph-cli you must upgrade the graph-ts dependency to a version greater than or equal to ${minimumGraphTsVersion}
60
- Also, you'll probably need to take a look at our AssemblyScript migration guide because of language breaking changes: https://thegraph.com/docs/developer/assemblyscript-migration-guide`
58
+ Also, you'll probably need to take a look at our AssemblyScript migration guide because of language breaking changes: https://thegraph.com/docs/developer/assemblyscript-migration-guide`,
61
59
  )
62
60
  }
63
61
  }
64
62
 
65
- module.exports = {
66
- assertManifestApiVersion,
67
- assertGraphTsVersion,
68
- }
63
+ export { assertManifestApiVersion, assertGraphTsVersion }
@@ -1,6 +1,6 @@
1
- const { assertManifestApiVersion, assertGraphTsVersion } = require('./version')
2
- const loadManifestUtil = require('../migrations/util/load-manifest')
3
- const graphTsUtil = require('../migrations/util/versions')
1
+ import { assertManifestApiVersion, assertGraphTsVersion } from './version'
2
+ import * as loadManifestUtil from '../migrations/util/load-manifest'
3
+ import * as graphTsUtil from '../migrations/util/versions'
4
4
 
5
5
  describe('Version Command Helpers', () => {
6
6
  describe('assertManifestApiVersion', () => {
@@ -9,57 +9,64 @@ describe('Version Command Helpers', () => {
9
9
 
10
10
  describe('With just dataSources', () => {
11
11
  test('When all of them are less than minimum apiVersion', async () => {
12
- loadManifestUtil.loadManifest = jest.fn()
13
- .mockImplementation(() => Promise.resolve({
12
+ loadManifestUtil.loadManifest = jest.fn().mockImplementation(() =>
13
+ Promise.resolve({
14
14
  dataSources: [
15
15
  { mapping: { apiVersion: '0.0.1' } },
16
16
  { mapping: { apiVersion: '0.0.2' } },
17
17
  { mapping: { apiVersion: '0.0.3' } },
18
18
  ],
19
- }))
19
+ }),
20
+ )
20
21
 
21
- await expect(assertManifestApiVersion(fakeManifestPath, minimumApiVersion))
22
- .rejects
23
- .toThrow(new Error(
24
- `The current version of graph-cli can't be used with mappings on apiVersion less than '${minimumApiVersion}'`
25
- ))
22
+ await expect(
23
+ assertManifestApiVersion(fakeManifestPath, minimumApiVersion),
24
+ ).rejects.toThrow(
25
+ new Error(
26
+ `The current version of graph-cli can't be used with mappings on apiVersion less than '${minimumApiVersion}'`,
27
+ ),
28
+ )
26
29
  })
27
30
  test('When one of them is less than minimum apiVersion', async () => {
28
- loadManifestUtil.loadManifest = jest.fn()
29
- .mockImplementation(() => Promise.resolve({
31
+ loadManifestUtil.loadManifest = jest.fn().mockImplementation(() =>
32
+ Promise.resolve({
30
33
  dataSources: [
31
34
  { mapping: { apiVersion: '0.0.5' } },
32
35
  { mapping: { apiVersion: '0.0.2' } },
33
36
  { mapping: { apiVersion: '0.0.5' } },
34
37
  ],
35
- }))
38
+ }),
39
+ )
36
40
 
37
- await expect(assertManifestApiVersion(fakeManifestPath, minimumApiVersion))
38
- .rejects
39
- .toThrow(new Error(
40
- `The current version of graph-cli can't be used with mappings on apiVersion less than '${minimumApiVersion}'`
41
- ))
41
+ await expect(
42
+ assertManifestApiVersion(fakeManifestPath, minimumApiVersion),
43
+ ).rejects.toThrow(
44
+ new Error(
45
+ `The current version of graph-cli can't be used with mappings on apiVersion less than '${minimumApiVersion}'`,
46
+ ),
47
+ )
42
48
  })
43
49
  test('When none of them are less than minimum apiVersion', async () => {
44
- loadManifestUtil.loadManifest = jest.fn()
45
- .mockImplementation(() => Promise.resolve({
50
+ loadManifestUtil.loadManifest = jest.fn().mockImplementation(() =>
51
+ Promise.resolve({
46
52
  dataSources: [
47
53
  { mapping: { apiVersion: '0.0.5' } },
48
54
  { mapping: { apiVersion: '0.0.6' } },
49
55
  { mapping: { apiVersion: '0.0.5' } },
50
56
  ],
51
- }))
57
+ }),
58
+ )
52
59
 
53
- await expect(assertManifestApiVersion(fakeManifestPath, minimumApiVersion))
54
- .resolves
55
- .toBe(undefined)
60
+ await expect(
61
+ assertManifestApiVersion(fakeManifestPath, minimumApiVersion),
62
+ ).resolves.toBe(undefined)
56
63
  })
57
64
  })
58
65
  describe('With dataSources and templates', () => {
59
66
  describe('And the dataSources have a lower apiVersion', () => {
60
67
  test('When all of the templates are less than minimum apiVersion', async () => {
61
- loadManifestUtil.loadManifest = jest.fn()
62
- .mockImplementation(() => Promise.resolve({
68
+ loadManifestUtil.loadManifest = jest.fn().mockImplementation(() =>
69
+ Promise.resolve({
63
70
  dataSources: [
64
71
  { mapping: { apiVersion: '0.0.5' } },
65
72
  { mapping: { apiVersion: '0.0.5' } },
@@ -70,17 +77,20 @@ describe('Version Command Helpers', () => {
70
77
  { mapping: { apiVersion: '0.0.2' } },
71
78
  { mapping: { apiVersion: '0.0.3' } },
72
79
  ],
73
- }))
80
+ }),
81
+ )
74
82
 
75
- await expect(assertManifestApiVersion(fakeManifestPath, minimumApiVersion))
76
- .rejects
77
- .toThrow(new Error(
78
- `The current version of graph-cli can't be used with mappings on apiVersion less than '${minimumApiVersion}'`
79
- ))
83
+ await expect(
84
+ assertManifestApiVersion(fakeManifestPath, minimumApiVersion),
85
+ ).rejects.toThrow(
86
+ new Error(
87
+ `The current version of graph-cli can't be used with mappings on apiVersion less than '${minimumApiVersion}'`,
88
+ ),
89
+ )
80
90
  })
81
91
  test('When one of the templates is less than minimum apiVersion', async () => {
82
- loadManifestUtil.loadManifest = jest.fn()
83
- .mockImplementation(() => Promise.resolve({
92
+ loadManifestUtil.loadManifest = jest.fn().mockImplementation(() =>
93
+ Promise.resolve({
84
94
  dataSources: [
85
95
  { mapping: { apiVersion: '0.0.5' } },
86
96
  { mapping: { apiVersion: '0.0.5' } },
@@ -91,17 +101,20 @@ describe('Version Command Helpers', () => {
91
101
  { mapping: { apiVersion: '0.0.2' } },
92
102
  { mapping: { apiVersion: '0.0.5' } },
93
103
  ],
94
- }))
104
+ }),
105
+ )
95
106
 
96
- await expect(assertManifestApiVersion(fakeManifestPath, minimumApiVersion))
97
- .rejects
98
- .toThrow(new Error(
99
- `The current version of graph-cli can't be used with mappings on apiVersion less than '${minimumApiVersion}'`
100
- ))
107
+ await expect(
108
+ assertManifestApiVersion(fakeManifestPath, minimumApiVersion),
109
+ ).rejects.toThrow(
110
+ new Error(
111
+ `The current version of graph-cli can't be used with mappings on apiVersion less than '${minimumApiVersion}'`,
112
+ ),
113
+ )
101
114
  })
102
115
  test('When none of the templates are less than minimum apiVersion', async () => {
103
- loadManifestUtil.loadManifest = jest.fn()
104
- .mockImplementation(() => Promise.resolve({
116
+ loadManifestUtil.loadManifest = jest.fn().mockImplementation(() =>
117
+ Promise.resolve({
105
118
  dataSources: [
106
119
  { mapping: { apiVersion: '0.0.5' } },
107
120
  { mapping: { apiVersion: '0.0.5' } },
@@ -112,19 +125,22 @@ describe('Version Command Helpers', () => {
112
125
  { mapping: { apiVersion: '0.0.6' } },
113
126
  { mapping: { apiVersion: '0.0.5' } },
114
127
  ],
115
- }))
128
+ }),
129
+ )
116
130
 
117
- await expect(assertManifestApiVersion(fakeManifestPath, minimumApiVersion))
118
- .rejects
119
- .toThrow(new Error(
120
- `The current version of graph-cli can't be used with mappings on apiVersion less than '${minimumApiVersion}'`
121
- ))
131
+ await expect(
132
+ assertManifestApiVersion(fakeManifestPath, minimumApiVersion),
133
+ ).rejects.toThrow(
134
+ new Error(
135
+ `The current version of graph-cli can't be used with mappings on apiVersion less than '${minimumApiVersion}'`,
136
+ ),
137
+ )
122
138
  })
123
139
  })
124
140
  describe('And the dataSources do NOT have a lower apiVersion', () => {
125
141
  test('When all of the templates are less than minimum apiVersion', async () => {
126
- loadManifestUtil.loadManifest = jest.fn()
127
- .mockImplementation(() => Promise.resolve({
142
+ loadManifestUtil.loadManifest = jest.fn().mockImplementation(() =>
143
+ Promise.resolve({
128
144
  dataSources: [
129
145
  { mapping: { apiVersion: '0.0.5' } },
130
146
  { mapping: { apiVersion: '0.0.5' } },
@@ -135,17 +151,20 @@ describe('Version Command Helpers', () => {
135
151
  { mapping: { apiVersion: '0.0.2' } },
136
152
  { mapping: { apiVersion: '0.0.3' } },
137
153
  ],
138
- }))
154
+ }),
155
+ )
139
156
 
140
- await expect(assertManifestApiVersion(fakeManifestPath, minimumApiVersion))
141
- .rejects
142
- .toThrow(new Error(
143
- `The current version of graph-cli can't be used with mappings on apiVersion less than '${minimumApiVersion}'`
144
- ))
157
+ await expect(
158
+ assertManifestApiVersion(fakeManifestPath, minimumApiVersion),
159
+ ).rejects.toThrow(
160
+ new Error(
161
+ `The current version of graph-cli can't be used with mappings on apiVersion less than '${minimumApiVersion}'`,
162
+ ),
163
+ )
145
164
  })
146
165
  test('When one of the templates is less than minimum apiVersion', async () => {
147
- loadManifestUtil.loadManifest = jest.fn()
148
- .mockImplementation(() => Promise.resolve({
166
+ loadManifestUtil.loadManifest = jest.fn().mockImplementation(() =>
167
+ Promise.resolve({
149
168
  dataSources: [
150
169
  { mapping: { apiVersion: '0.0.5' } },
151
170
  { mapping: { apiVersion: '0.0.5' } },
@@ -156,17 +175,20 @@ describe('Version Command Helpers', () => {
156
175
  { mapping: { apiVersion: '0.0.2' } },
157
176
  { mapping: { apiVersion: '0.0.5' } },
158
177
  ],
159
- }))
178
+ }),
179
+ )
160
180
 
161
- await expect(assertManifestApiVersion(fakeManifestPath, minimumApiVersion))
162
- .rejects
163
- .toThrow(new Error(
164
- `The current version of graph-cli can't be used with mappings on apiVersion less than '${minimumApiVersion}'`
165
- ))
181
+ await expect(
182
+ assertManifestApiVersion(fakeManifestPath, minimumApiVersion),
183
+ ).rejects.toThrow(
184
+ new Error(
185
+ `The current version of graph-cli can't be used with mappings on apiVersion less than '${minimumApiVersion}'`,
186
+ ),
187
+ )
166
188
  })
167
189
  test('When none of the templates are less than minimum apiVersion', async () => {
168
- loadManifestUtil.loadManifest = jest.fn()
169
- .mockImplementation(() => Promise.resolve({
190
+ loadManifestUtil.loadManifest = jest.fn().mockImplementation(() =>
191
+ Promise.resolve({
170
192
  dataSources: [
171
193
  { mapping: { apiVersion: '0.0.5' } },
172
194
  { mapping: { apiVersion: '0.0.5' } },
@@ -177,11 +199,12 @@ describe('Version Command Helpers', () => {
177
199
  { mapping: { apiVersion: '0.0.6' } },
178
200
  { mapping: { apiVersion: '0.0.5' } },
179
201
  ],
180
- }))
202
+ }),
203
+ )
181
204
 
182
- await expect(assertManifestApiVersion(fakeManifestPath, minimumApiVersion))
183
- .resolves
184
- .toBe(undefined)
205
+ await expect(
206
+ assertManifestApiVersion(fakeManifestPath, minimumApiVersion),
207
+ ).resolves.toBe(undefined)
185
208
  })
186
209
  })
187
210
  })
@@ -190,22 +213,28 @@ describe('Version Command Helpers', () => {
190
213
  const fakeNodeModulesDir = 'fake/path/to/node/modules'
191
214
  const minimumGraphTsVersion = '0.22.0'
192
215
 
193
- test('When the installed graph-ts version is less than what\'s supported', async () => {
194
- graphTsUtil.getGraphTsVersion = jest.fn().mockImplementation(() => Promise.resolve('0.19.0'))
216
+ test("When the installed graph-ts version is less than what's supported", async () => {
217
+ graphTsUtil.getGraphTsVersion = jest
218
+ .fn()
219
+ .mockImplementation(() => Promise.resolve('0.19.0'))
195
220
 
196
- await expect(assertGraphTsVersion(fakeNodeModulesDir, minimumGraphTsVersion))
197
- .rejects
198
- .toThrow(new Error(
221
+ await expect(
222
+ assertGraphTsVersion(fakeNodeModulesDir, minimumGraphTsVersion),
223
+ ).rejects.toThrow(
224
+ new Error(
199
225
  `To use this version of the graph-cli you must upgrade the graph-ts dependency to a version greater than or equal to ${minimumGraphTsVersion}
200
- Also, you'll probably need to take a look at our AssemblyScript migration guide because of language breaking changes: https://thegraph.com/docs/developer/assemblyscript-migration-guide`
201
- ))
226
+ Also, you'll probably need to take a look at our AssemblyScript migration guide because of language breaking changes: https://thegraph.com/docs/developer/assemblyscript-migration-guide`,
227
+ ),
228
+ )
202
229
  })
203
230
  test('When the installed graph-ts version is a supported one', async () => {
204
- graphTsUtil.getGraphTsVersion = jest.fn().mockImplementation(() => Promise.resolve('0.22.0'))
231
+ graphTsUtil.getGraphTsVersion = jest
232
+ .fn()
233
+ .mockImplementation(() => Promise.resolve('0.22.0'))
205
234
 
206
- await expect(assertGraphTsVersion(fakeNodeModulesDir, minimumGraphTsVersion))
207
- .resolves
208
- .toBe(undefined)
235
+ await expect(
236
+ assertGraphTsVersion(fakeNodeModulesDir, minimumGraphTsVersion),
237
+ ).resolves.toBe(undefined)
209
238
  })
210
239
  })
211
240
  })