@vladimirdev635/gql-codegen 0.0.97 → 0.0.98

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 (57) hide show
  1. package/actors/ts/formatters/eslint/index.d.ts +1 -1
  2. package/actors/ts/formatters/index.d.ts +1 -0
  3. package/actors/ts/formatters/index.js +1 -0
  4. package/actors/ts/formatters/oxfmt/formatter.d.ts +3 -0
  5. package/actors/ts/formatters/oxfmt/formatter.js +20 -0
  6. package/actors/ts/formatters/oxfmt/index.d.ts +2 -0
  7. package/actors/ts/formatters/oxfmt/index.js +1 -0
  8. package/actors/ts/formatters/oxfmt/types.d.ts +20 -0
  9. package/actors/ts/formatters/oxfmt/types.js +1 -0
  10. package/actors/ts/gql-client/actor.js +1 -1
  11. package/actors/ts/gql-client/generators/main.js +25 -21
  12. package/actors/ts/gql-client/index.d.ts +1 -1
  13. package/actors/ts/gql-client/index.js +1 -1
  14. package/actors/ts/gql-client-react/actor.js +1 -1
  15. package/actors/ts/gql-client-react/generators/main.js +20 -14
  16. package/actors/ts/gql-client-react/index.d.ts +1 -1
  17. package/actors/ts/gql-client-react/index.js +1 -1
  18. package/actors/ts/graphql/actor.js +1 -1
  19. package/actors/ts/graphql/generators/client/fragments.js +53 -31
  20. package/actors/ts/graphql/generators/client/main.js +5 -5
  21. package/actors/ts/graphql/generators/client/operations.js +29 -13
  22. package/actors/ts/graphql/generators/main.js +2 -2
  23. package/actors/ts/graphql/generators/server/enums.js +1 -1
  24. package/actors/ts/graphql/generators/server/inputs.js +11 -8
  25. package/actors/ts/graphql/generators/server/main.js +13 -10
  26. package/actors/ts/graphql/generators/server/objects.js +15 -11
  27. package/actors/ts/graphql/generators/server/scalars/additional.js +23 -5
  28. package/actors/ts/graphql/generators/server/scalars/index.d.ts +1 -1
  29. package/actors/ts/graphql/generators/server/scalars/index.js +1 -1
  30. package/actors/ts/graphql/generators/server/scalars/mapping.js +1 -1
  31. package/actors/ts/graphql/generators/server/shared.js +6 -4
  32. package/actors/ts/graphql/generators/server/unions.js +5 -5
  33. package/actors/ts/graphql/generators/shared.js +6 -6
  34. package/actors/ts/graphql/index.d.ts +1 -1
  35. package/actors/ts/graphql/index.js +1 -1
  36. package/actors/ts/utils.js +3 -3
  37. package/config.d.ts +0 -2
  38. package/index.d.ts +1 -1
  39. package/index.js +1 -1
  40. package/package.json +23 -21
  41. package/schema/client/argument.d.ts +2 -2
  42. package/schema/client/argument.js +3 -3
  43. package/schema/client/directive.d.ts +2 -2
  44. package/schema/client/directive.js +1 -1
  45. package/schema/client/fragment.d.ts +5 -5
  46. package/schema/client/fragment.js +10 -10
  47. package/schema/client/operation.d.ts +3 -3
  48. package/schema/client/root.d.ts +6 -6
  49. package/schema/client/root.js +1 -1
  50. package/schema/server.d.ts +36 -36
  51. package/schema/server.js +13 -13
  52. package/schema/shared.d.ts +6 -6
  53. package/schema/shared.js +7 -7
  54. package/schema/test-client.json +52031 -1
  55. package/schema/test-server.json +38289 -1
  56. package/schema/utils.js +78 -67
  57. package/utils.js +1 -2
@@ -1,4 +1,4 @@
1
1
  import ts from 'typescript';
2
2
  export function generateEnumDefinition(e) {
3
- return ts.factory.createEnumDeclaration(ts.factory.createModifiersFromModifierFlags(ts.ModifierFlags.Export), e.name, e.values.map(value => ts.factory.createEnumMember(value, ts.factory.createStringLiteral(value))));
3
+ return ts.factory.createEnumDeclaration(ts.factory.createModifiersFromModifierFlags(ts.ModifierFlags.Export), e.name, e.values.map((value) => ts.factory.createEnumMember(value, ts.factory.createStringLiteral(value))));
4
4
  }
@@ -8,7 +8,8 @@ function generateZodInputTypeSpec(scalarsMapping, type) {
8
8
  return ts.factory.createCallExpression(ts.factory.createPropertyAccessExpression(ts.factory.createIdentifier('z'), 'enum'), undefined, [ts.factory.createIdentifier(type.name)]);
9
9
  }
10
10
  case 'Scalar': {
11
- return getScalarSpecFromMapping(scalarsMapping, type.name).inputSchema;
11
+ return getScalarSpecFromMapping(scalarsMapping, type.name)
12
+ .inputSchema;
12
13
  }
13
14
  case 'InputType': {
14
15
  return ts.factory.createIdentifier(generateSchemaName(type.name));
@@ -34,30 +35,32 @@ function generateZodInputField(scalarsMapping, field) {
34
35
  }
35
36
  function isFieldLazy(spec) {
36
37
  switch (spec._type) {
37
- case 'literal': return spec.type._type === 'InputType';
38
- case 'array': return isFieldLazy(spec.type);
38
+ case 'literal':
39
+ return spec.type._type === 'InputType';
40
+ case 'array':
41
+ return isFieldLazy(spec.type);
39
42
  }
40
43
  }
41
44
  export function generateInputTypeDefinitionFields(scalarsMapping, fields) {
42
45
  return Object.entries(fields).map(([name, field]) => {
43
46
  const fieldSpec = generateZodInputField(scalarsMapping, field);
44
47
  if (isFieldLazy(field.spec)) {
45
- return ts.factory.createGetAccessorDeclaration([], name, [], undefined, ts.factory.createBlock([
46
- ts.factory.createReturnStatement(fieldSpec)
47
- ], true));
48
+ return ts.factory.createGetAccessorDeclaration([], name, [], undefined, ts.factory.createBlock([ts.factory.createReturnStatement(fieldSpec)], true));
48
49
  }
49
50
  return ts.factory.createPropertyAssignment(name, fieldSpec);
50
51
  });
51
52
  }
52
53
  function generateZodInputTypeDefinition(scalarsMapping, name, fields) {
53
54
  return ts.factory.createVariableStatement([ts.factory.createToken(ts.SyntaxKind.ExportKeyword)], ts.factory.createVariableDeclarationList([
54
- ts.factory.createVariableDeclaration(generateSchemaName(name), undefined, undefined, ts.factory.createCallExpression(ts.factory.createPropertyAccessExpression(ts.factory.createIdentifier('z'), ts.factory.createIdentifier('object')), undefined, [ts.factory.createObjectLiteralExpression(generateInputTypeDefinitionFields(scalarsMapping, fields), true)]))
55
+ ts.factory.createVariableDeclaration(generateSchemaName(name), undefined, undefined, ts.factory.createCallExpression(ts.factory.createPropertyAccessExpression(ts.factory.createIdentifier('z'), ts.factory.createIdentifier('object')), undefined, [
56
+ ts.factory.createObjectLiteralExpression(generateInputTypeDefinitionFields(scalarsMapping, fields), true),
57
+ ])),
55
58
  ], ts.NodeFlags.Const));
56
59
  }
57
60
  export function generateInputTypeDefinitions(scalarsMapping, input) {
58
61
  return [
59
62
  generateZodInputTypeDefinition(scalarsMapping, input.name, input.fields),
60
63
  generateZodInferTypeAlias('input', input.name, generateSchemaName(input.name)),
61
- ts.factory.createIdentifier('\n')
64
+ ts.factory.createIdentifier('\n'),
62
65
  ];
63
66
  }
@@ -6,17 +6,20 @@ import { addNewLineBetweenNodes } from '../../../shared.js';
6
6
  import { generateObjectTypeNodes } from './objects.js';
7
7
  export function generateServerNodes(config, context) {
8
8
  return [
9
- ...addNewLineBetweenNodes(Object.values(context.schema.server.enums)
10
- .map(generateEnumDefinition)),
9
+ ...addNewLineBetweenNodes(Object.values(context.schema.server.enums).map(generateEnumDefinition)),
11
10
  ts.factory.createIdentifier('\n'),
12
- ...!config.onlyRequiredForOperations ?
13
- Object.values(context.schema.server.objects)
14
- .map(object => generateObjectTypeNodes(config.scalarsMapping, object)).flat() : [],
15
- ...!config.onlyRequiredForOperations ?
16
- Object.values(context.schema.server.unions)
17
- .map(union => generateUnionTypeDefinitions(config.scalarsMapping, context.schema.server.objects, union)).flat() : [],
11
+ ...(!config.onlyRequiredForOperations
12
+ ? Object.values(context.schema.server.objects)
13
+ .map((object) => generateObjectTypeNodes(config.scalarsMapping, object))
14
+ .flat()
15
+ : []),
16
+ ...(!config.onlyRequiredForOperations
17
+ ? Object.values(context.schema.server.unions)
18
+ .map((union) => generateUnionTypeDefinitions(config.scalarsMapping, context.schema.server.objects, union))
19
+ .flat()
20
+ : []),
18
21
  ...Object.values(context.schema.server.inputs)
19
- .map(input => generateInputTypeDefinitions(config.scalarsMapping, input))
20
- .flat()
22
+ .map((input) => generateInputTypeDefinitions(config.scalarsMapping, input))
23
+ .flat(),
21
24
  ];
22
25
  }
@@ -10,7 +10,8 @@ function generateZodObjectTypeSpec(scalarsMapping, type) {
10
10
  return ts.factory.createCallExpression(ts.factory.createPropertyAccessExpression(ts.factory.createIdentifier('z'), 'enum'), undefined, [ts.factory.createIdentifier(type.name)]);
11
11
  }
12
12
  case 'Scalar': {
13
- return getScalarSpecFromMapping(scalarsMapping, type.name).outputSchema;
13
+ return getScalarSpecFromMapping(scalarsMapping, type.name)
14
+ .outputSchema;
14
15
  }
15
16
  case 'Union':
16
17
  case 'InterfaceType':
@@ -63,9 +64,12 @@ const lazyTypes = [
63
64
  ];
64
65
  function isFieldLazy(spec) {
65
66
  switch (spec._type) {
66
- case 'literal': return lazyTypes.includes(spec.type._type);
67
- case 'array': return isFieldLazy(spec.type);
68
- case 'callable': return isFieldLazy(spec.returnType);
67
+ case 'literal':
68
+ return lazyTypes.includes(spec.type._type);
69
+ case 'array':
70
+ return isFieldLazy(spec.type);
71
+ case 'callable':
72
+ return isFieldLazy(spec.returnType);
69
73
  }
70
74
  }
71
75
  function generateObjectTypeDefinitionFields(scalarsMapping, fields, typename) {
@@ -78,26 +82,26 @@ function generateObjectTypeDefinitionFields(scalarsMapping, fields, typename) {
78
82
  ...Object.entries(fields).map(([name, field]) => {
79
83
  const fieldSpec = generateZodObjectFieldSpec(scalarsMapping, field);
80
84
  if (isFieldLazy(field.spec)) {
81
- return ts.factory.createGetAccessorDeclaration([], name, [], undefined, ts.factory.createBlock([
82
- ts.factory.createReturnStatement(fieldSpec)
83
- ], true));
85
+ return ts.factory.createGetAccessorDeclaration([], name, [], undefined, ts.factory.createBlock([ts.factory.createReturnStatement(fieldSpec)], true));
84
86
  }
85
87
  return ts.factory.createPropertyAssignment(name, fieldSpec);
86
- })
88
+ }),
87
89
  ];
88
90
  }
89
91
  export function generateZodObjectTypeExpression(scalarsMapping, object, includeTypename = false) {
90
- return ts.factory.createCallExpression(ts.factory.createPropertyAccessExpression(ts.factory.createIdentifier('z'), ts.factory.createIdentifier('object')), undefined, [ts.factory.createObjectLiteralExpression(generateObjectTypeDefinitionFields(scalarsMapping, object.fields, includeTypename ? object.name : undefined), true)]);
92
+ return ts.factory.createCallExpression(ts.factory.createPropertyAccessExpression(ts.factory.createIdentifier('z'), ts.factory.createIdentifier('object')), undefined, [
93
+ ts.factory.createObjectLiteralExpression(generateObjectTypeDefinitionFields(scalarsMapping, object.fields, includeTypename ? object.name : undefined), true),
94
+ ]);
91
95
  }
92
96
  export function generateZodObjectTypeNode(scalarsMapping, object) {
93
97
  return ts.factory.createVariableStatement([ts.factory.createToken(ts.SyntaxKind.ExportKeyword)], ts.factory.createVariableDeclarationList([
94
- ts.factory.createVariableDeclaration(generateSchemaName(object.name), undefined, undefined, generateZodObjectTypeExpression(scalarsMapping, object))
98
+ ts.factory.createVariableDeclaration(generateSchemaName(object.name), undefined, undefined, generateZodObjectTypeExpression(scalarsMapping, object)),
95
99
  ], ts.NodeFlags.Const));
96
100
  }
97
101
  export function generateObjectTypeNodes(scalarsMapping, object) {
98
102
  return [
99
103
  generateZodObjectTypeNode(scalarsMapping, object),
100
104
  generateZodInferTypeAlias('output', object.name, generateSchemaName(object.name)),
101
- ts.factory.createIdentifier('\n')
105
+ ts.factory.createIdentifier('\n'),
102
106
  ];
103
107
  }
@@ -8,18 +8,36 @@ export const additionalScalarsMapping = {
8
8
  UUID: builtinScalarsMapping.String,
9
9
  Datetime: {
10
10
  inputSchema: invokeMethod(ts.factory.createIdentifier('z'), 'date', []),
11
- outputSchema: invokeMethod(invokeMethod(ts.factory.createIdentifier('z'), 'string', []), 'transform', [ts.factory.createArrowFunction(undefined, undefined, [ts.factory.createParameterDeclaration(undefined, undefined, 'v')], undefined, ts.factory.createToken(ts.SyntaxKind.EqualsGreaterThanToken), ts.factory.createNewExpression(ts.factory.createIdentifier('Date'), [], [ts.factory.createIdentifier('v')]))])
11
+ outputSchema: invokeMethod(invokeMethod(ts.factory.createIdentifier('z'), 'string', []), 'transform', [
12
+ ts.factory.createArrowFunction(undefined, undefined, [
13
+ ts.factory.createParameterDeclaration(undefined, undefined, 'v'),
14
+ ], undefined, ts.factory.createToken(ts.SyntaxKind.EqualsGreaterThanToken), ts.factory.createNewExpression(ts.factory.createIdentifier('Date'), [], [ts.factory.createIdentifier('v')])),
15
+ ]),
12
16
  },
13
17
  Upload: buildSymmetricScalarSpec(ts.factory.createCallExpression(ts.factory.createPropertyAccessExpression(ts.factory.createIdentifier('z'), 'file'), undefined, [])),
14
18
  Url: {
15
- inputSchema: invokeMethod(ts.factory.createCallExpression(ts.factory.createPropertyAccessExpression(ts.factory.createIdentifier('z'), 'custom'), [ts.factory.createTypeReferenceNode('URL')], []), 'transform', [ts.factory.createArrowFunction(undefined, undefined, [ts.factory.createParameterDeclaration(undefined, undefined, 'url')], undefined, ts.factory.createToken(ts.SyntaxKind.EqualsGreaterThanToken), invokeMethod(ts.factory.createIdentifier('url'), 'toString', []))]),
16
- outputSchema: invokeMethod(ts.factory.createCallExpression(ts.factory.createPropertyAccessExpression(ts.factory.createIdentifier('z'), 'string'), [], []), 'transform', [ts.factory.createArrowFunction(undefined, undefined, [ts.factory.createParameterDeclaration(undefined, undefined, 'v')], undefined, ts.factory.createToken(ts.SyntaxKind.EqualsGreaterThanToken), ts.factory.createNewExpression(ts.factory.createIdentifier('URL'), undefined, [ts.factory.createIdentifier('v')]))]),
19
+ inputSchema: invokeMethod(ts.factory.createCallExpression(ts.factory.createPropertyAccessExpression(ts.factory.createIdentifier('z'), 'custom'), [ts.factory.createTypeReferenceNode('URL')], []), 'transform', [
20
+ ts.factory.createArrowFunction(undefined, undefined, [
21
+ ts.factory.createParameterDeclaration(undefined, undefined, 'url'),
22
+ ], undefined, ts.factory.createToken(ts.SyntaxKind.EqualsGreaterThanToken), invokeMethod(ts.factory.createIdentifier('url'), 'toString', [])),
23
+ ]),
24
+ outputSchema: invokeMethod(ts.factory.createCallExpression(ts.factory.createPropertyAccessExpression(ts.factory.createIdentifier('z'), 'string'), [], []), 'transform', [
25
+ ts.factory.createArrowFunction(undefined, undefined, [
26
+ ts.factory.createParameterDeclaration(undefined, undefined, 'v'),
27
+ ], undefined, ts.factory.createToken(ts.SyntaxKind.EqualsGreaterThanToken), ts.factory.createNewExpression(ts.factory.createIdentifier('URL'), undefined, [ts.factory.createIdentifier('v')])),
28
+ ]),
17
29
  },
18
30
  Void: buildSymmetricScalarSpec(ts.factory.createCallExpression(ts.factory.createPropertyAccessExpression(ts.factory.createIdentifier('z'), 'any'), undefined, [])),
19
31
  Date: {
20
32
  inputSchema: invokeMethod(invokeMethod(ts.factory.createIdentifier('z'), 'date', []), 'transform', [
21
- ts.factory.createArrowFunction(undefined, undefined, [ts.factory.createParameterDeclaration(undefined, undefined, 'v')], undefined, ts.factory.createToken(ts.SyntaxKind.EqualsGreaterThanToken), ts.factory.createElementAccessExpression(invokeMethod(invokeMethod(ts.factory.createIdentifier('v'), 'toISOString', []), 'split', [ts.factory.createStringLiteral('T')]), ts.factory.createNumericLiteral(0)))
33
+ ts.factory.createArrowFunction(undefined, undefined, [
34
+ ts.factory.createParameterDeclaration(undefined, undefined, 'v'),
35
+ ], undefined, ts.factory.createToken(ts.SyntaxKind.EqualsGreaterThanToken), ts.factory.createElementAccessExpression(invokeMethod(invokeMethod(ts.factory.createIdentifier('v'), 'toISOString', []), 'split', [ts.factory.createStringLiteral('T')]), ts.factory.createNumericLiteral(0))),
36
+ ]),
37
+ outputSchema: invokeMethod(invokeMethod(ts.factory.createIdentifier('z'), 'string', []), 'transform', [
38
+ ts.factory.createArrowFunction(undefined, undefined, [
39
+ ts.factory.createParameterDeclaration(undefined, undefined, 'v'),
40
+ ], undefined, ts.factory.createToken(ts.SyntaxKind.EqualsGreaterThanToken), ts.factory.createNewExpression(ts.factory.createIdentifier('Date'), [], [ts.factory.createIdentifier('v')])),
22
41
  ]),
23
- outputSchema: invokeMethod(invokeMethod(ts.factory.createIdentifier('z'), 'string', []), 'transform', [ts.factory.createArrowFunction(undefined, undefined, [ts.factory.createParameterDeclaration(undefined, undefined, 'v')], undefined, ts.factory.createToken(ts.SyntaxKind.EqualsGreaterThanToken), ts.factory.createNewExpression(ts.factory.createIdentifier('Date'), [], [ts.factory.createIdentifier('v')]))])
24
42
  },
25
43
  };
@@ -1,3 +1,3 @@
1
1
  export { builtinScalarsMapping } from './builtin.js';
2
- export { type BuiltinScalarName, type ScalarSpec, type ScalarsMapping, buildSymmetricScalarSpec, getScalarSpecFromMapping } from './mapping.js';
2
+ export { type BuiltinScalarName, type ScalarSpec, type ScalarsMapping, buildSymmetricScalarSpec, getScalarSpecFromMapping, } from './mapping.js';
3
3
  export { additionalScalarsMapping } from './additional.js';
@@ -1,3 +1,3 @@
1
1
  export { builtinScalarsMapping } from './builtin.js';
2
- export { buildSymmetricScalarSpec, getScalarSpecFromMapping } from './mapping.js';
2
+ export { buildSymmetricScalarSpec, getScalarSpecFromMapping, } from './mapping.js';
3
3
  export { additionalScalarsMapping } from './additional.js';
@@ -1,7 +1,7 @@
1
1
  export function buildSymmetricScalarSpec(specType) {
2
2
  return {
3
3
  inputSchema: specType,
4
- outputSchema: specType
4
+ outputSchema: specType,
5
5
  };
6
6
  }
7
7
  export function getScalarSpecFromMapping(scalarsMapping, name) {
@@ -9,12 +9,14 @@ export function generateNonCallableFieldSpec(scalars, spec) {
9
9
  }
10
10
  }
11
11
  export function wrapInMaybeIfNullable(spec, nullable) {
12
- return nullable ?
13
- ts.factory.createTypeReferenceNode('Maybe', [spec]) :
14
- spec;
12
+ return nullable
13
+ ? ts.factory.createTypeReferenceNode('Maybe', [spec])
14
+ : spec;
15
15
  }
16
16
  export function generateZodInferTypeAlias(inferType, name, typeName) {
17
- return ts.factory.createTypeAliasDeclaration(ts.factory.createModifiersFromModifierFlags(ts.ModifierFlags.Export), name, undefined, ts.factory.createTypeReferenceNode('z.' + inferType, [ts.factory.createTypeQueryNode(ts.factory.createIdentifier(typeName), undefined)]));
17
+ return ts.factory.createTypeAliasDeclaration(ts.factory.createModifiersFromModifierFlags(ts.ModifierFlags.Export), name, undefined, ts.factory.createTypeReferenceNode('z.' + inferType, [
18
+ ts.factory.createTypeQueryNode(ts.factory.createIdentifier(typeName), undefined),
19
+ ]));
18
20
  }
19
21
  export function generateSchemaName(name) {
20
22
  return name[0].toLowerCase() + name.slice(1) + 'Schema';
@@ -3,16 +3,16 @@ import { generateSchemaName, generateZodInferTypeAlias } from './shared.js';
3
3
  import { generateZodObjectTypeExpression } from './objects.js';
4
4
  function generateZodUnionTypeNode(scalarsMapping, objects, union) {
5
5
  return ts.factory.createVariableStatement([ts.factory.createToken(ts.SyntaxKind.ExportKeyword)], ts.factory.createVariableDeclarationList([
6
- ts.factory.createVariableDeclaration(generateSchemaName(union.name), undefined, undefined, ts.factory.createCallExpression(ts.factory.createPropertyAccessExpression(ts.factory.createIdentifier('z'), ts.factory.createIdentifier('discriminatedUnion')), undefined, [ts.factory.createStringLiteral(union.name),
7
- ts.factory.createArrayLiteralExpression(Object.keys(union.items)
8
- .map(item => generateZodObjectTypeExpression(scalarsMapping, objects[item], true)), true)
9
- ]))
6
+ ts.factory.createVariableDeclaration(generateSchemaName(union.name), undefined, undefined, ts.factory.createCallExpression(ts.factory.createPropertyAccessExpression(ts.factory.createIdentifier('z'), ts.factory.createIdentifier('discriminatedUnion')), undefined, [
7
+ ts.factory.createStringLiteral(union.name),
8
+ ts.factory.createArrayLiteralExpression(Object.keys(union.items).map((item) => generateZodObjectTypeExpression(scalarsMapping, objects[item], true)), true),
9
+ ])),
10
10
  ], ts.NodeFlags.Const));
11
11
  }
12
12
  export function generateUnionTypeDefinitions(scalarsMapping, objects, union) {
13
13
  return [
14
14
  generateZodUnionTypeNode(scalarsMapping, objects, union),
15
15
  generateZodInferTypeAlias('output', union.name, generateSchemaName(union.name)),
16
- ts.factory.createIdentifier('\n')
16
+ ts.factory.createIdentifier('\n'),
17
17
  ];
18
18
  }
@@ -1,8 +1,8 @@
1
1
  import ts from 'typescript';
2
2
  export function createQuestionTokenIfNullable(nullable) {
3
- return nullable ?
4
- ts.factory.createToken(ts.SyntaxKind.QuestionToken) :
5
- undefined;
3
+ return nullable
4
+ ? ts.factory.createToken(ts.SyntaxKind.QuestionToken)
5
+ : undefined;
6
6
  }
7
7
  export function createTypenamePropertySignature(name, optional, alias) {
8
8
  return ts.factory.createPropertySignature(undefined, alias || '__typename', createQuestionTokenIfNullable(optional), ts.factory.createLiteralTypeNode(ts.factory.createStringLiteral(name)));
@@ -18,7 +18,7 @@ export function generateTypeReferenceNode(scalars, name) {
18
18
  export function generateStringOrTemplate(value, values) {
19
19
  if (values.length === 0)
20
20
  return ts.factory.createStringLiteral(value);
21
- return ts.factory.createTemplateExpression(ts.factory.createTemplateHead(value), values.map((item, index) => ts.factory.createTemplateSpan(ts.factory.createIdentifier(item), index + 1 !== values.length ?
22
- ts.factory.createTemplateMiddle('', '') :
23
- ts.factory.createTemplateTail('', ''))));
21
+ return ts.factory.createTemplateExpression(ts.factory.createTemplateHead(value), values.map((item, index) => ts.factory.createTemplateSpan(ts.factory.createIdentifier(item), index + 1 !== values.length
22
+ ? ts.factory.createTemplateMiddle('', '')
23
+ : ts.factory.createTemplateTail('', ''))));
24
24
  }
@@ -1,2 +1,2 @@
1
1
  export { buildGraphqlActor, GraphqlActorConfig } from './actor.js';
2
- export { builtinScalarsMapping, additionalScalarsMapping, type BuiltinScalarName, type ScalarSpec, type ScalarsMapping, buildSymmetricScalarSpec, getScalarSpecFromMapping } from './generators/server/scalars/index.js';
2
+ export { builtinScalarsMapping, additionalScalarsMapping, type BuiltinScalarName, type ScalarSpec, type ScalarsMapping, buildSymmetricScalarSpec, getScalarSpecFromMapping, } from './generators/server/scalars/index.js';
@@ -1,2 +1,2 @@
1
1
  export { buildGraphqlActor } from './actor.js';
2
- export { builtinScalarsMapping, additionalScalarsMapping, buildSymmetricScalarSpec, getScalarSpecFromMapping } from './generators/server/scalars/index.js';
2
+ export { builtinScalarsMapping, additionalScalarsMapping, buildSymmetricScalarSpec, getScalarSpecFromMapping, } from './generators/server/scalars/index.js';
@@ -1,6 +1,6 @@
1
1
  import ts from 'typescript';
2
2
  export function generateImportDeclaration(modulePath, imports) {
3
- return ts.factory.createImportDeclaration(undefined, ts.factory.createImportClause(false, undefined, ts.factory.createNamedImports(imports.map(i => ts.factory.createImportSpecifier(true, typeof i === 'string' ?
4
- undefined :
5
- ts.factory.createIdentifier(i.alias), ts.factory.createIdentifier(typeof i === 'string' ? i : i.name))))), ts.factory.createStringLiteral(modulePath));
3
+ return ts.factory.createImportDeclaration(undefined, ts.factory.createImportClause(false, undefined, ts.factory.createNamedImports(imports.map((i) => ts.factory.createImportSpecifier(true, typeof i === 'string'
4
+ ? undefined
5
+ : ts.factory.createIdentifier(i.alias), ts.factory.createIdentifier(typeof i === 'string' ? i : i.name))))), ts.factory.createStringLiteral(modulePath));
6
6
  }
package/config.d.ts CHANGED
@@ -1,8 +1,6 @@
1
1
  import { RootSchema } from './schema/root.js';
2
- import { Logger } from 'pino';
3
2
  export interface ActorContext {
4
3
  readonly schema: RootSchema;
5
- readonly logger: Logger;
6
4
  }
7
5
  export type Actor<T extends ActorContext> = (c: T) => Promise<void> | void;
8
6
  export interface Config<T extends ActorContext> {
package/index.d.ts CHANGED
@@ -1,4 +1,4 @@
1
1
  export { Actor, ActorContext, Config } from './config.js';
2
2
  export { run } from './main.js';
3
- export { loadClientSchemaFromFile, loadServerSchemaFromFile, loadRootSchemaFromGQLSubprocess } from './schema/utils.js';
3
+ export { loadClientSchemaFromFile, loadServerSchemaFromFile, loadRootSchemaFromGQLSubprocess, } from './schema/utils.js';
4
4
  export * as actors from './actors/index.js';
package/index.js CHANGED
@@ -1,3 +1,3 @@
1
1
  export { run } from './main.js';
2
- export { loadClientSchemaFromFile, loadServerSchemaFromFile, loadRootSchemaFromGQLSubprocess } from './schema/utils.js';
2
+ export { loadClientSchemaFromFile, loadServerSchemaFromFile, loadRootSchemaFromGQLSubprocess, } from './schema/utils.js';
3
3
  export * as actors from './actors/index.js';
package/package.json CHANGED
@@ -1,43 +1,45 @@
1
1
  {
2
2
  "name": "@vladimirdev635/gql-codegen",
3
- "version": "0.0.97",
4
- "type": "module",
5
- "main": "./index.js",
6
- "types": "./index.d.ts",
7
- "files": [
8
- "./"
9
- ],
3
+ "version": "0.0.98",
4
+ "description": "",
5
+ "keywords": [],
10
6
  "homepage": "https://github.com/Voldemat/graphql-plus-plus#readme",
7
+ "license": "ISC",
8
+ "author": "",
11
9
  "repository": {
12
10
  "type": "git",
13
11
  "url": "git+https://github.com/Voldemat/graphql-plus-plus.git"
14
12
  },
13
+ "files": [
14
+ "./"
15
+ ],
16
+ "type": "module",
17
+ "main": "./index.js",
18
+ "types": "./index.d.ts",
15
19
  "scripts": {
16
- "lint": "eslint .",
17
- "lint:fix": "eslint --fix .",
18
- "lint:ci": "npm run lint",
20
+ "fmt": "oxfmt .",
21
+ "fmt:check": "oxfmt --check .",
22
+ "lint": "oxlint .",
23
+ "lint:fix": "oxlint --fix .",
24
+ "lint:ci": "npm run fmt:check && npm run lint",
19
25
  "test": "vitest",
20
26
  "build": "tsc && tsc-alias && cp package.json ./dist/package.json"
21
27
  },
22
- "keywords": [],
23
- "author": "",
24
- "license": "ISC",
25
- "description": "",
26
28
  "devDependencies": {
27
- "@babel/eslint-parser": "^7.27.5",
28
- "@babel/plugin-transform-typescript": "^7.27.1",
29
- "@eslint/compat": "^1.3.0",
30
29
  "@types/node": "^24.0.1",
31
- "@typescript-eslint/eslint-plugin": "^8.34.0",
32
30
  "assert": "^2.1.0",
33
- "eslint": "^9.28.0",
34
31
  "jiti": "^2.4.2",
32
+ "oxfmt": "^0.62.0",
33
+ "oxlint": "^1.77.0",
35
34
  "tsc-alias": "^1.8.16",
36
35
  "vitest": "^3.2.4"
37
36
  },
38
37
  "peerDependencies": {
39
- "pino": ">=9.7.0",
40
- "typescript": ">=5.8.3",
38
+ "typescript": ">=5.8.3 <7.0.0",
41
39
  "zod": ">=3.25.76"
40
+ },
41
+ "allowScripts": {
42
+ "esbuild@0.28.1": true,
43
+ "fsevents@2.3.3": true
42
44
  }
43
45
  }
@@ -5,7 +5,7 @@ export declare const argumentValue: z.ZodDiscriminatedUnion<[z.ZodObject<{
5
5
  }, z.core.$strip>, z.ZodObject<{
6
6
  _type: z.ZodLiteral<"literal">;
7
7
  value: z.ZodUnion<readonly [z.ZodString, z.ZodNumber, z.ZodBoolean]>;
8
- }, z.core.$strip>]>;
8
+ }, z.core.$strip>], "_type">;
9
9
  export declare const argument: z.ZodObject<{
10
10
  name: z.ZodString;
11
11
  value: z.ZodDiscriminatedUnion<[z.ZodObject<{
@@ -14,5 +14,5 @@ export declare const argument: z.ZodObject<{
14
14
  }, z.core.$strip>, z.ZodObject<{
15
15
  _type: z.ZodLiteral<"literal">;
16
16
  value: z.ZodUnion<readonly [z.ZodString, z.ZodNumber, z.ZodBoolean]>;
17
- }, z.core.$strip>]>;
17
+ }, z.core.$strip>], "_type">;
18
18
  }, z.core.$strip>;
@@ -2,12 +2,12 @@ import { z } from 'zod/v4';
2
2
  export const argumentValue = z.discriminatedUnion('_type', [
3
3
  z.object({
4
4
  _type: z.literal('ref'),
5
- name: z.string()
5
+ name: z.string(),
6
6
  }),
7
7
  z.object({
8
8
  _type: z.literal('literal'),
9
- value: z.union([z.string(), z.number(), z.boolean()])
10
- })
9
+ value: z.union([z.string(), z.number(), z.boolean()]),
10
+ }),
11
11
  ]);
12
12
  export const argument = z.object({
13
13
  name: z.string(),
@@ -16,14 +16,14 @@ export declare const directiveSchema: z.ZodObject<{
16
16
  _type: z.ZodLiteral<"Enum">;
17
17
  name: z.ZodString;
18
18
  $ref: z.ZodString;
19
- }, z.core.$strip>]>;
19
+ }, z.core.$strip>], "_type">;
20
20
  defaultValue: z.ZodNullable<z.ZodOptional<z.ZodUnion<readonly [z.ZodString, z.ZodInt, z.ZodFloat32, z.ZodBoolean]>>>;
21
21
  }, z.core.$strip>, z.ZodObject<{
22
22
  _type: z.ZodLiteral<"array">;
23
23
  nullable: z.ZodBoolean;
24
24
  defaultValue: z.ZodNullable<z.ZodOptional<z.ZodUnion<readonly [z.ZodArray<z.ZodString>, z.ZodArray<z.ZodInt>, z.ZodArray<z.ZodFloat32>, z.ZodArray<z.ZodBoolean>]>>>;
25
25
  type: z.ZodDiscriminatedUnion<[typeof import("../shared.js").inputLiteralSpecSchema, typeof import("../shared.js").inputArraySpecSchema]>;
26
- }, z.core.$strip>]>;
26
+ }, z.core.$strip>], "_type">;
27
27
  }, z.core.$strip>>;
28
28
  locations: z.ZodArray<z.ZodEnum<{
29
29
  MUTATION: "MUTATION";
@@ -12,5 +12,5 @@ export const directiveSchema = z.object({
12
12
  'FRAGMENT_SPREAD',
13
13
  'INLINE_FRAGMENT',
14
14
  'VARIABLE_DEFINITION',
15
- ]))
15
+ ])),
16
16
  });
@@ -34,7 +34,7 @@ export declare const fieldSelection: z.ZodObject<{
34
34
  }, z.core.$strip>, z.ZodObject<{
35
35
  _type: z.ZodLiteral<"literal">;
36
36
  value: z.ZodUnion<readonly [z.ZodString, z.ZodNumber, z.ZodBoolean]>;
37
- }, z.core.$strip>]>;
37
+ }, z.core.$strip>], "_type">;
38
38
  }, z.core.$strip>>;
39
39
  selection: z.ZodNullable<FragmentSpecSchemaZodType>;
40
40
  }, z.core.$strip>;
@@ -76,7 +76,7 @@ export declare const objectSelection: z.ZodLazy<z.ZodDiscriminatedUnion<[z.ZodOb
76
76
  }, z.core.$strip>, z.ZodObject<{
77
77
  _type: z.ZodLiteral<"literal">;
78
78
  value: z.ZodUnion<readonly [z.ZodString, z.ZodNumber, z.ZodBoolean]>;
79
- }, z.core.$strip>]>;
79
+ }, z.core.$strip>], "_type">;
80
80
  }, z.core.$strip>>;
81
81
  selection: z.ZodNullable<FragmentSpecSchemaZodType>;
82
82
  }, z.core.$strip>, z.ZodObject<{
@@ -85,7 +85,7 @@ export declare const objectSelection: z.ZodLazy<z.ZodDiscriminatedUnion<[z.ZodOb
85
85
  }, z.core.$strip>, z.ZodObject<{
86
86
  _type: z.ZodLiteral<"SpreadSelection">;
87
87
  fragment: z.ZodString;
88
- }, z.core.$strip>]>>;
88
+ }, z.core.$strip>], "_type">>;
89
89
  export declare const objectFragmentSpec: ObjectFragmentSpec;
90
90
  export declare const unionFragmentSpec: z.ZodObject<{
91
91
  _type: z.ZodLiteral<"UnionFragmentSpec">;
@@ -96,13 +96,13 @@ export declare const fragmentSpecSchema: z.ZodDiscriminatedUnion<[ObjectFragment
96
96
  _type: z.ZodLiteral<"UnionFragmentSpec">;
97
97
  name: z.ZodString;
98
98
  selections: z.ZodArray<UnionSelectionZodType>;
99
- }, z.core.$strip>]>;
99
+ }, z.core.$strip>], "_type">;
100
100
  export declare const fragmentSchema: z.ZodObject<{
101
101
  sourceText: z.ZodString;
102
102
  spec: z.ZodDiscriminatedUnion<[ObjectFragmentSpec, z.ZodObject<{
103
103
  _type: z.ZodLiteral<"UnionFragmentSpec">;
104
104
  name: z.ZodString;
105
105
  selections: z.ZodArray<UnionSelectionZodType>;
106
- }, z.core.$strip>]>;
106
+ }, z.core.$strip>], "_type">;
107
107
  }, z.core.$strip>;
108
108
  export {};
@@ -9,11 +9,11 @@ export const fieldSelection = z.object({
9
9
  get selection() {
10
10
  // eslint-disable-next-line no-use-before-define
11
11
  return z.nullable(fragmentSpecSchema);
12
- }
12
+ },
13
13
  });
14
14
  export const typenameSelection = z.object({
15
15
  _type: z.literal('TypenameField'),
16
- alias: z.nullable(z.string())
16
+ alias: z.nullable(z.string()),
17
17
  });
18
18
  export const objectConditionalSpreadSelection = z.object({
19
19
  _type: z.literal('ObjectConditionalSpreadSelection'),
@@ -21,11 +21,11 @@ export const objectConditionalSpreadSelection = z.object({
21
21
  get spec() {
22
22
  // eslint-disable-next-line no-use-before-define
23
23
  return objectFragmentSpec;
24
- }
24
+ },
25
25
  });
26
26
  export const spreadSelection = z.object({
27
27
  _type: z.literal('SpreadSelection'),
28
- fragment: z.string()
28
+ fragment: z.string(),
29
29
  });
30
30
  export const unionConditionalSpreadSelection = z.object({
31
31
  _type: z.literal('UnionConditionalSpreadSelection'),
@@ -33,7 +33,7 @@ export const unionConditionalSpreadSelection = z.object({
33
33
  get selections() {
34
34
  // eslint-disable-next-line no-use-before-define
35
35
  return z.array(unionSelection);
36
- }
36
+ },
37
37
  });
38
38
  export const unionSelection = z.lazy(() => z.discriminatedUnion('_type', [
39
39
  typenameSelection,
@@ -44,23 +44,23 @@ export const unionSelection = z.lazy(() => z.discriminatedUnion('_type', [
44
44
  export const objectSelection = z.lazy(() => z.discriminatedUnion('_type', [
45
45
  fieldSelection,
46
46
  typenameSelection,
47
- spreadSelection
47
+ spreadSelection,
48
48
  ]));
49
49
  export const objectFragmentSpec = z.object({
50
50
  _type: z.literal('ObjectFragmentSpec'),
51
51
  name: z.string(),
52
- selections: z.array(objectSelection)
52
+ selections: z.array(objectSelection),
53
53
  });
54
54
  export const unionFragmentSpec = z.object({
55
55
  _type: z.literal('UnionFragmentSpec'),
56
56
  name: z.string(),
57
- selections: z.array(unionSelection)
57
+ selections: z.array(unionSelection),
58
58
  });
59
59
  export const fragmentSpecSchema = z.discriminatedUnion('_type', [
60
60
  objectFragmentSpec,
61
- unionFragmentSpec
61
+ unionFragmentSpec,
62
62
  ]);
63
63
  export const fragmentSchema = z.object({
64
64
  sourceText: z.string(),
65
- spec: fragmentSpecSchema
65
+ spec: fragmentSpecSchema,
66
66
  });
@@ -21,14 +21,14 @@ export declare const operationSchema: z.ZodObject<{
21
21
  _type: z.ZodLiteral<"Enum">;
22
22
  name: z.ZodString;
23
23
  $ref: z.ZodString;
24
- }, z.core.$strip>]>;
24
+ }, z.core.$strip>], "_type">;
25
25
  defaultValue: z.ZodNullable<z.ZodOptional<z.ZodUnion<readonly [z.ZodString, z.ZodInt, z.ZodFloat32, z.ZodBoolean]>>>;
26
26
  }, z.core.$strip>, z.ZodObject<{
27
27
  _type: z.ZodLiteral<"array">;
28
28
  nullable: z.ZodBoolean;
29
29
  defaultValue: z.ZodNullable<z.ZodOptional<z.ZodUnion<readonly [z.ZodArray<z.ZodString>, z.ZodArray<z.ZodInt>, z.ZodArray<z.ZodFloat32>, z.ZodArray<z.ZodBoolean>]>>>;
30
30
  type: z.ZodDiscriminatedUnion<[typeof import("../shared.js").inputLiteralSpecSchema, typeof import("../shared.js").inputArraySpecSchema]>;
31
- }, z.core.$strip>]>;
31
+ }, z.core.$strip>], "_type">;
32
32
  }, z.core.$strip>>;
33
33
  fragmentSpec: z.ZodDiscriminatedUnion<[z.ZodObject<{
34
34
  _type: z.ZodLiteral<"ObjectFragmentSpec">;
@@ -38,6 +38,6 @@ export declare const operationSchema: z.ZodObject<{
38
38
  _type: z.ZodLiteral<"UnionFragmentSpec">;
39
39
  name: z.ZodString;
40
40
  selections: z.ZodArray<import("./fragment.js").UnionSelectionZodType>;
41
- }, z.core.$strip>]>;
41
+ }, z.core.$strip>], "_type">;
42
42
  sourceText: z.ZodString;
43
43
  }, z.core.$strip>;