@toptal/davinci-graphql-codegen 0.2.5 → 0.2.6-alpha-fx-2755-interactive-workflow-generation.4

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.
@@ -7,5 +7,5 @@ const codegenGenerateOperationsCreator = require('../src/commands/generate-opera
7
7
 
8
8
  cliEngine.loadCommands([
9
9
  codegenGenerateSchemaCreator,
10
- codegenGenerateOperationsCreator
10
+ codegenGenerateOperationsCreator,
11
11
  ])
package/esbuild.js CHANGED
@@ -11,6 +11,6 @@ esbuild
11
11
  platform: 'node',
12
12
  sourcemap: true,
13
13
  target: 'node14',
14
- plugins: [nodeExternalsPlugin()]
14
+ plugins: [nodeExternalsPlugin()],
15
15
  })
16
16
  .catch(() => process.exit(1))
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@toptal/davinci-graphql-codegen",
3
- "version": "0.2.5",
3
+ "version": "0.2.6-alpha-fx-2755-interactive-workflow-generation.4+46405792",
4
4
  "description": "Codegen",
5
5
  "author": "Toptal",
6
6
  "license": "ISC",
@@ -29,9 +29,10 @@
29
29
  "@graphql-codegen/typescript-operations": "^2.3.5",
30
30
  "@graphql-codegen/typescript-resolvers": "^2.2.1",
31
31
  "@graphql-typed-document-node/core": "^3.1.0",
32
- "@toptal/davinci-cli-shared": "^1.5.2",
33
- "@toptal/davinci-monorepo": "6.5.1",
32
+ "@toptal/davinci-cli-shared": "1.5.3-alpha-fx-2755-interactive-workflow-generation.4+46405792",
33
+ "@toptal/davinci-monorepo": "6.5.2-alpha-fx-2755-interactive-workflow-generation.4+46405792",
34
34
  "chalk": "^4.1.2",
35
35
  "graphql": "^15.7.1"
36
- }
36
+ },
37
+ "gitHead": "46405792bfc49fdb4b954b2ca9ddbb9ce8660801"
37
38
  }
@@ -10,7 +10,7 @@ const codegenGenerateOperations = async ({ config, extension = '.ts' }) => {
10
10
  await generateOperations({
11
11
  schema,
12
12
  documents,
13
- extension
13
+ extension,
14
14
  })
15
15
  }
16
16
  }
@@ -21,18 +21,18 @@ const codegenGenerateOperationsCreator = {
21
21
  options: [
22
22
  {
23
23
  label: `Path to your custom ${chalk.green('codegen.json')} config file`,
24
- name: '--config <config-path>'
24
+ name: '--config <config-path>',
25
25
  },
26
26
  {
27
27
  label: `Custom extension that generated files will have. Defaults to ${chalk.green(
28
28
  '.ts'
29
29
  )}`,
30
- name: '--extension <extension>'
31
- }
30
+ name: '--extension <extension>',
31
+ },
32
32
  ],
33
33
  action: ({ options }) => {
34
34
  codegenGenerateOperations(options)
35
- }
35
+ },
36
36
  }
37
37
 
38
38
  module.exports = codegenGenerateOperationsCreator
@@ -11,7 +11,7 @@ const codegenGenerateSchema = async ({ projectId = 'toptal-hub', config }) => {
11
11
  schema,
12
12
  documents,
13
13
  target,
14
- projectId
14
+ projectId,
15
15
  })
16
16
  }
17
17
  }
@@ -24,16 +24,16 @@ const codegenGenerateSchemaCreator = {
24
24
  label: `roject ID inside Google Storage Bucket. Defaults to ${chalk.green(
25
25
  'toptal-hub'
26
26
  )}`,
27
- name: '--projectId <id>'
27
+ name: '--projectId <id>',
28
28
  },
29
29
  {
30
30
  label: `Path to your custom ${chalk.green('codegen.json')} config file`,
31
- name: '--config <file-path>'
32
- }
31
+ name: '--config <file-path>',
32
+ },
33
33
  ],
34
34
  action: ({ options }) => {
35
35
  codegenGenerateSchema(options)
36
- }
36
+ },
37
37
  }
38
38
 
39
39
  module.exports = codegenGenerateSchemaCreator
@@ -4,10 +4,10 @@ const commonTypesConfig = {
4
4
  avoidOptionals: {
5
5
  field: true,
6
6
  inputValue: false,
7
- object: true
7
+ object: true,
8
8
  },
9
9
  namingConvention: {
10
- enumValues: 'upper-case#upperCase'
10
+ enumValues: 'upper-case#upperCase',
11
11
  },
12
12
  scalars: {
13
13
  BigDecimal: 'string',
@@ -19,8 +19,8 @@ const commonTypesConfig = {
19
19
  PageSize: 'number',
20
20
  Time: 'string',
21
21
  TimeOfDay: 'string',
22
- Upload: 'unknown'
23
- }
22
+ Upload: 'unknown',
23
+ },
24
24
  }
25
25
 
26
26
  const commonSchemaTypesConfig = {
@@ -30,21 +30,21 @@ const commonSchemaTypesConfig = {
30
30
  allowParentTypeOverride: false,
31
31
  noSchemaStitching: true,
32
32
  optionalInfoArgument: true,
33
- optionalResolveType: true
33
+ optionalResolveType: true,
34
34
  }
35
35
 
36
36
  const commonOperationTypesConfig = {
37
37
  ...commonTypesConfig,
38
- dedupeFragments: true
38
+ dedupeFragments: true,
39
39
  }
40
40
 
41
41
  const autoGenerationComments = [
42
42
  '/* eslint-disable */',
43
- '/* ⚠️ THIS IS AN AUTOGENERATED FILE, DO NOT EDIT ⚠️ */'
43
+ '/* ⚠️ THIS IS AN AUTOGENERATED FILE, DO NOT EDIT ⚠️ */',
44
44
  ]
45
45
 
46
46
  module.exports = {
47
47
  commonOperationTypesConfig,
48
48
  commonSchemaTypesConfig,
49
- autoGenerationComments
49
+ autoGenerationComments,
50
50
  }
@@ -3,7 +3,7 @@ const { generate } = require('@graphql-codegen/cli')
3
3
 
4
4
  const {
5
5
  commonOperationTypesConfig,
6
- autoGenerationComments
6
+ autoGenerationComments,
7
7
  } = require('../config/config')
8
8
  const getSchemaPath = require('../services/get-schema-path')
9
9
  const getRelativeFilePath = require('../utils/get-relative-file-path')
@@ -20,7 +20,7 @@ const generateOperations = async ({ schema, documents, extension }) => {
20
20
  {
21
21
  documents: docsPath,
22
22
  config: {
23
- ...commonOperationTypesConfig
23
+ ...commonOperationTypesConfig,
24
24
  },
25
25
  generates: {
26
26
  [schemaPath]: {
@@ -28,22 +28,22 @@ const generateOperations = async ({ schema, documents, extension }) => {
28
28
  preset: 'near-operation-file',
29
29
  presetConfig: {
30
30
  extension,
31
- baseTypesPath: `~${schema}/schema`
31
+ baseTypesPath: `~${schema}/schema`,
32
32
  },
33
33
  plugins: [
34
34
  'typescript-operations',
35
35
  'typed-document-node',
36
36
  {
37
37
  add: {
38
- content: autoGenerationComments
39
- }
40
- }
41
- ]
42
- }
38
+ content: autoGenerationComments,
39
+ },
40
+ },
41
+ ],
42
+ },
43
43
  },
44
44
  hooks: {
45
- afterAllFileWrite: 'prettier --write'
46
- }
45
+ afterAllFileWrite: 'prettier --write',
46
+ },
47
47
  },
48
48
  true
49
49
  )
@@ -3,7 +3,7 @@ const chalk = require('chalk')
3
3
 
4
4
  const {
5
5
  commonSchemaTypesConfig,
6
- autoGenerationComments
6
+ autoGenerationComments,
7
7
  } = require('../config/config')
8
8
  const schemaLoader = require('../services/schema-loader')
9
9
  const { isSchemaFromHttp } = require('../utils/detect-schema-source')
@@ -30,18 +30,18 @@ const generateSchema = async ({ schema, target, projectId }) => {
30
30
  'typescript-resolvers',
31
31
  {
32
32
  add: {
33
- content: autoGenerationComments
34
- }
35
- }
36
- ]
37
- }
33
+ content: autoGenerationComments,
34
+ },
35
+ },
36
+ ],
37
+ },
38
38
  },
39
39
  hooks: {
40
- afterAllFileWrite: 'prettier --write'
40
+ afterAllFileWrite: 'prettier --write',
41
41
  },
42
42
  config: {
43
- ...commonSchemaTypesConfig
44
- }
43
+ ...commonSchemaTypesConfig,
44
+ },
45
45
  },
46
46
  true
47
47
  )
package/src/index.js CHANGED
@@ -2,5 +2,5 @@ const codegenGenerateSchemaCreator = require('./commands/generate-schema')
2
2
  const codegenGenerateOperationsCreator = require('./commands/generate-operations')
3
3
 
4
4
  module.exports = {
5
- commands: [codegenGenerateSchemaCreator, codegenGenerateOperationsCreator]
5
+ commands: [codegenGenerateSchemaCreator, codegenGenerateOperationsCreator],
6
6
  }
@@ -1,5 +1,5 @@
1
1
  const {
2
- utils: { checkIfMonorepo }
2
+ utils: { checkIfMonorepo },
3
3
  } = require('@toptal/davinci-monorepo')
4
4
 
5
5
  const getMonorepoSchemaPath = require('./get-monorepo-schema-path')
@@ -13,7 +13,7 @@ const gsSchemaLoader = async (projectId, source, destination) => {
13
13
  .bucket(bucketName)
14
14
  .file(fileName)
15
15
  .download({
16
- destination: getRelativeFilePath(destination)
16
+ destination: getRelativeFilePath(destination),
17
17
  })
18
18
  }
19
19
 
@@ -6,7 +6,7 @@ const getRelativeFilePath = require('../utils/get-relative-file-path')
6
6
  const {
7
7
  isSchemaFromBucket,
8
8
  isLocalSchema,
9
- isSchemaFromHttp
9
+ isSchemaFromHttp,
10
10
  } = require('../utils/detect-schema-source')
11
11
 
12
12
  module.exports = async (schema, target, projectId) => {
@@ -39,6 +39,6 @@ module.exports = async (schema, target, projectId) => {
39
39
 
40
40
  return {
41
41
  schema: schemaPath,
42
- destination: destinationPathTs
42
+ destination: destinationPathTs,
43
43
  }
44
44
  }
@@ -13,5 +13,5 @@ const isLocalSchema = schema => {
13
13
  module.exports = {
14
14
  isSchemaFromBucket,
15
15
  isSchemaFromHttp,
16
- isLocalSchema
16
+ isLocalSchema,
17
17
  }
@@ -9,7 +9,7 @@ const parseGSURI = source => {
9
9
 
10
10
  return {
11
11
  bucketName,
12
- fileName
12
+ fileName,
13
13
  }
14
14
  }
15
15
 
@@ -1,37 +0,0 @@
1
- {
2
- "name": "@toptal/davinci-graphql-codegen",
3
- "version": "0.2.5",
4
- "description": "Codegen",
5
- "author": "Toptal",
6
- "license": "ISC",
7
- "homepage": "https://github.com/toptal/davinci/tree/master/packages/graphql-codegen#readme",
8
- "publishConfig": {
9
- "access": "public"
10
- },
11
- "bin": {
12
- "davinci-graphql-codegen": "./bin/davinci-graphql-codegen.js"
13
- },
14
- "main": "./src/index.js",
15
- "scripts": {
16
- "build:package": "../../bin/build-package.js",
17
- "prepublishOnly": "../../bin/prepublish.js",
18
- "test": "echo \"Error: no test specified\" && exit 1"
19
- },
20
- "sideEffects": false,
21
- "dependencies": {
22
- "@google-cloud/storage": "^6.0.0",
23
- "@graphql-codegen/add": "^3.1.0",
24
- "@graphql-codegen/cli": "^2.2.0",
25
- "@graphql-codegen/introspection": "^2.1.0",
26
- "@graphql-codegen/near-operation-file-preset": "^2.2.8",
27
- "@graphql-codegen/typed-document-node": "^2.2.8",
28
- "@graphql-codegen/typescript": "^2.2.2",
29
- "@graphql-codegen/typescript-operations": "^2.3.5",
30
- "@graphql-codegen/typescript-resolvers": "^2.2.1",
31
- "@graphql-typed-document-node/core": "^3.1.0",
32
- "@toptal/davinci-cli-shared": "^1.5.2",
33
- "@toptal/davinci-monorepo": "6.5.1",
34
- "chalk": "^4.1.2",
35
- "graphql": "^15.7.1"
36
- }
37
- }
@@ -1,59 +0,0 @@
1
- jest.mock('@toptal/davinci-monorepo', () => ({
2
- commands: [],
3
- utils: { checkIfMonorepo: jest.fn() }
4
- }))
5
-
6
- jest.mock('./get-monorepo-schema-path', () =>
7
- jest.fn(() => ({
8
- target: 'talent',
9
- schemaPath: '@toptal/modularity-template-graphql',
10
- schemaPathResolution:
11
- 'home/users/alexvcasillas/toptal/libs/graphql/schema.graphql'
12
- }))
13
- )
14
-
15
- jest.mock('./get-monolith-schema-path', () =>
16
- jest.fn(() => ({
17
- target: 'src/modules/graphql',
18
- schemaPath: 'src/modules/graphql',
19
- schemaPathResolution:
20
- 'home/users/alexvcasillas/toptal/screening-wizard/src/modules/graphql/schema.graphql'
21
- }))
22
- )
23
-
24
- const {
25
- utils: { checkIfMonorepo }
26
- } = require('@toptal/davinci-monorepo')
27
-
28
- const getSchemaPath = require('./get-schema-path')
29
-
30
- const monorepoSchema = '@toptal/modularity-template-graphql/talent'
31
- const monolithSchema = 'src/modules/graphql'
32
-
33
- describe('getSchemaPath', () => {
34
- it('returns target, schemaPath and schemaPathResolution for monorepo', () => {
35
- checkIfMonorepo.mockReturnValue(() => true)
36
-
37
- const { target, schemaPath, schemaPathResolution } =
38
- getSchemaPath(monorepoSchema)
39
-
40
- expect(target).toBe('talent')
41
- expect(schemaPath).toBe('@toptal/modularity-template-graphql')
42
- expect(schemaPathResolution).toBe(
43
- 'home/users/alexvcasillas/toptal/libs/graphql/schema.graphql'
44
- )
45
- })
46
-
47
- it('returns target, schemaPath and schemaPathResolution for monolith', () => {
48
- checkIfMonorepo.mockReturnValue(false)
49
-
50
- const { target, schemaPath, schemaPathResolution } =
51
- getSchemaPath(monolithSchema)
52
-
53
- expect(target).toBe('src/modules/graphql')
54
- expect(schemaPath).toBe('src/modules/graphql')
55
- expect(schemaPathResolution).toBe(
56
- 'home/users/alexvcasillas/toptal/screening-wizard/src/modules/graphql/schema.graphql'
57
- )
58
- })
59
- })
@@ -1,29 +0,0 @@
1
- const {
2
- isSchemaFromBucket,
3
- isSchemaFromHttp,
4
- isLocalSchema
5
- } = require('./detect-schema-source')
6
-
7
- const gsBucketSchema = 'gs://toptal.net/gateway/graphql/talent'
8
- const httpSchema = 'https://toptal.net/gateway/graphql/talent'
9
- const localSchema = '../../graphql/talent'
10
-
11
- describe('Detect Schema Sources', () => {
12
- it('detects that schema is from GS Bucket', () => {
13
- expect(isSchemaFromBucket(gsBucketSchema)).toBe(true)
14
- expect(isSchemaFromHttp(gsBucketSchema)).toBe(false)
15
- expect(isLocalSchema(gsBucketSchema)).toBe(false)
16
- })
17
-
18
- it('detects that schema is from http', () => {
19
- expect(isSchemaFromBucket(httpSchema)).toBe(false)
20
- expect(isSchemaFromHttp(httpSchema)).toBe(true)
21
- expect(isLocalSchema(httpSchema)).toBe(false)
22
- })
23
-
24
- it('detects that schema is from local folder', () => {
25
- expect(isSchemaFromBucket(localSchema)).toBe(false)
26
- expect(isSchemaFromHttp(localSchema)).toBe(false)
27
- expect(isLocalSchema(localSchema)).toBe(true)
28
- })
29
- })
@@ -1,12 +0,0 @@
1
- const parseGSURI = require('./parse-gs-uri')
2
-
3
- const bucketURI = 'gs://gqlgw-introspection/staging_talent_schema.graphql'
4
-
5
- describe('Parse Google Storage Bucket URI', () => {
6
- it('parses a Google Storage Bucket URI correctly', () => {
7
- const { bucketName, fileName } = parseGSURI(bucketURI)
8
-
9
- expect(bucketName).toBe('gqlgw-introspection')
10
- expect(fileName).toBe('staging_talent_schema.graphql')
11
- })
12
- })
@@ -1,10 +0,0 @@
1
- const processArgs = require('./process-args')
2
-
3
- describe('Argument processor', () => {
4
- it('process arguments correctly', () => {
5
- const args = processArgs(['generate-operations', '--projectId=toptal'])
6
-
7
- expect(args.operation).toBe('generate-operations')
8
- expect(args.projectId).toBe('toptal')
9
- })
10
- })
@@ -1,15 +0,0 @@
1
- const toArray = require('./to-array')
2
-
3
- describe('toArray', () => {
4
- it("converts a value into an array if it's not one", () => {
5
- const asArray = toArray('hello')
6
-
7
- expect(Array.isArray(asArray)).toBe(true)
8
- })
9
-
10
- it("returns the array as is if it's an array", () => {
11
- const asArray = toArray(['hello', 'there'])
12
-
13
- expect(Array.isArray(asArray)).toBe(true)
14
- })
15
- })