@graphql-codegen/c-sharp-common 0.0.0

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.
@@ -0,0 +1,95 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.CSharpDeclarationBlock = void 0;
4
+ const visitor_plugin_common_1 = require("@graphql-codegen/visitor-plugin-common");
5
+ const utils_js_1 = require("./utils.js");
6
+ class CSharpDeclarationBlock {
7
+ constructor() {
8
+ this._name = null;
9
+ this._extendStr = [];
10
+ this._implementsStr = [];
11
+ this._kind = null;
12
+ this._access = 'public';
13
+ this._final = false;
14
+ this._static = false;
15
+ this._block = null;
16
+ this._comment = null;
17
+ this._nestedClasses = [];
18
+ }
19
+ nestedClass(nstCls) {
20
+ this._nestedClasses.push(nstCls);
21
+ return this;
22
+ }
23
+ access(access) {
24
+ this._access = access;
25
+ return this;
26
+ }
27
+ asKind(kind) {
28
+ this._kind = kind;
29
+ return this;
30
+ }
31
+ final() {
32
+ this._final = true;
33
+ return this;
34
+ }
35
+ static() {
36
+ this._static = true;
37
+ return this;
38
+ }
39
+ withComment(comment) {
40
+ if (comment) {
41
+ this._comment = (0, utils_js_1.transformComment)(comment, 1);
42
+ }
43
+ return this;
44
+ }
45
+ withBlock(block) {
46
+ this._block = block;
47
+ return this;
48
+ }
49
+ extends(extendStr) {
50
+ this._extendStr = extendStr;
51
+ return this;
52
+ }
53
+ implements(implementsStr) {
54
+ this._implementsStr = implementsStr;
55
+ return this;
56
+ }
57
+ withName(name) {
58
+ this._name = typeof name === 'object' ? name.value : name;
59
+ return this;
60
+ }
61
+ get string() {
62
+ let result = '';
63
+ if (this._kind) {
64
+ let name = '';
65
+ if (this._name) {
66
+ name = this._name;
67
+ }
68
+ if (this._kind === 'namespace') {
69
+ result += `${this._kind} ${name} `;
70
+ }
71
+ else {
72
+ let extendStr = '';
73
+ let implementsStr = '';
74
+ const final = this._final ? ' final' : '';
75
+ const isStatic = this._static ? ' static' : '';
76
+ if (this._extendStr.length > 0) {
77
+ extendStr = ` : ${this._extendStr.join(', ')}`;
78
+ }
79
+ if (this._implementsStr.length > 0) {
80
+ implementsStr = ` : ${this._implementsStr.join(', ')}`;
81
+ }
82
+ result += `${this._access}${isStatic}${final} ${this._kind} ${name}${extendStr}${implementsStr} `;
83
+ }
84
+ }
85
+ const nestedClasses = this._nestedClasses.length
86
+ ? this._nestedClasses.map(c => (0, visitor_plugin_common_1.indentMultiline)(c.string)).join('\n\n')
87
+ : null;
88
+ const before = '{';
89
+ const after = '}';
90
+ const block = [before, nestedClasses, this._block, after].filter(f => f).join('\n');
91
+ result += block;
92
+ return (this._comment ? this._comment : '') + result + '\n';
93
+ }
94
+ }
95
+ exports.CSharpDeclarationBlock = CSharpDeclarationBlock;
@@ -0,0 +1,16 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.CSharpFieldType = void 0;
4
+ class CSharpFieldType {
5
+ constructor(fieldType) {
6
+ Object.assign(this, fieldType);
7
+ }
8
+ get innerTypeName() {
9
+ const nullable = this.baseType.valueType && !this.baseType.required ? '?' : '';
10
+ return `${this.baseType.type}${nullable}`;
11
+ }
12
+ get isOuterTypeRequired() {
13
+ return this.listType ? this.listType.required : this.baseType.required;
14
+ }
15
+ }
16
+ exports.CSharpFieldType = CSharpFieldType;
package/cjs/index.js ADDED
@@ -0,0 +1,8 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ const tslib_1 = require("tslib");
4
+ tslib_1.__exportStar(require("./c-sharp-declaration-block.js"), exports);
5
+ tslib_1.__exportStar(require("./scalars.js"), exports);
6
+ tslib_1.__exportStar(require("./utils.js"), exports);
7
+ tslib_1.__exportStar(require("./c-sharp-field-types.js"), exports);
8
+ tslib_1.__exportStar(require("./keywords.js"), exports);
@@ -0,0 +1,102 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.convertSafeName = void 0;
4
+ /**
5
+ * C# keywords
6
+ * https://docs.microsoft.com/en-us/dotnet/csharp/language-reference/keywords/
7
+ */
8
+ const csharpKeywords = new Set([
9
+ 'abstract',
10
+ 'as',
11
+ 'base',
12
+ 'bool',
13
+ 'break',
14
+ 'byte',
15
+ 'case',
16
+ 'catch',
17
+ 'char',
18
+ 'checked',
19
+ 'class',
20
+ 'const',
21
+ 'continue',
22
+ 'decimal',
23
+ 'default',
24
+ 'delegate',
25
+ 'do',
26
+ 'double',
27
+ 'else',
28
+ 'enum',
29
+ 'event',
30
+ 'explicit',
31
+ 'extern',
32
+ 'false',
33
+ 'finally',
34
+ 'fixed',
35
+ 'float',
36
+ 'for',
37
+ 'foreach',
38
+ 'goto',
39
+ 'if',
40
+ 'implicit',
41
+ 'in',
42
+ 'int',
43
+ 'interface',
44
+ 'internal',
45
+ 'is',
46
+ 'lock',
47
+ 'long',
48
+ 'namespace',
49
+ 'new',
50
+ 'null',
51
+ 'object',
52
+ 'operator',
53
+ 'out',
54
+ 'override',
55
+ 'params',
56
+ 'private',
57
+ 'protected',
58
+ 'public',
59
+ 'readonly',
60
+ 'record',
61
+ 'ref',
62
+ 'return',
63
+ 'sbyte',
64
+ 'sealed',
65
+ 'short',
66
+ 'sizeof',
67
+ 'stackalloc',
68
+ 'static',
69
+ 'string',
70
+ 'struct',
71
+ 'switch',
72
+ 'this',
73
+ 'throw',
74
+ 'true',
75
+ 'try',
76
+ 'typeof',
77
+ 'uint',
78
+ 'ulong',
79
+ 'unchecked',
80
+ 'unsafe',
81
+ 'ushort',
82
+ 'using',
83
+ 'virtual',
84
+ 'void',
85
+ 'volatile',
86
+ 'while',
87
+ ]);
88
+ /**
89
+ * Checks name against list of keywords. If it is, will prefix value with @
90
+ *
91
+ * Note:
92
+ * This class should first invoke the convertName from base-visitor to convert the string or node
93
+ * value according the naming configuration, eg upper or lower case. Then resulting string checked
94
+ * against the list or keywords.
95
+ * However the generated C# code is not yet able to handle fields that are in a different case so
96
+ * the invocation of convertName is omitted purposely.
97
+ */
98
+ function convertSafeName(node) {
99
+ const name = typeof node === 'string' ? node : node.value;
100
+ return csharpKeywords.has(name) ? `@${name}` : name;
101
+ }
102
+ exports.convertSafeName = convertSafeName;
@@ -0,0 +1 @@
1
+ {"type":"commonjs"}
package/cjs/scalars.js ADDED
@@ -0,0 +1,27 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.csharpValueTypes = exports.C_SHARP_SCALARS = void 0;
4
+ exports.C_SHARP_SCALARS = {
5
+ ID: 'string',
6
+ String: 'string',
7
+ Boolean: 'bool',
8
+ Int: 'int',
9
+ Float: 'double',
10
+ Date: 'DateTime',
11
+ };
12
+ exports.csharpValueTypes = [
13
+ 'bool',
14
+ 'byte',
15
+ 'sbyte',
16
+ 'char',
17
+ 'decimal',
18
+ 'double',
19
+ 'float',
20
+ 'int',
21
+ 'uint',
22
+ 'long',
23
+ 'ulong',
24
+ 'short',
25
+ 'ushort',
26
+ 'DateTime',
27
+ ];
package/cjs/utils.js ADDED
@@ -0,0 +1,78 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.wrapFieldType = exports.getListInnerTypeNode = exports.getListTypeDepth = exports.getListTypeField = exports.isValueType = exports.transformComment = void 0;
4
+ // This file is bundled and inlined.
5
+ // We should probably make this a shared package though.
6
+ // eslint-disable-next-line import/no-extraneous-dependencies
7
+ const graphql_1 = require("graphql");
8
+ // eslint-disable-next-line import/no-extraneous-dependencies
9
+ const visitor_plugin_common_1 = require("@graphql-codegen/visitor-plugin-common");
10
+ const scalars_js_1 = require("./scalars.js");
11
+ function transformComment(comment, indentLevel = 0) {
12
+ if (!comment) {
13
+ return '';
14
+ }
15
+ if (isStringValueNode(comment)) {
16
+ comment = comment.value;
17
+ }
18
+ comment = comment.trimStart().split('*/').join('*\\/');
19
+ let lines = comment.split('\n');
20
+ lines = ['/// <summary>', ...lines.map(line => `/// ${line}`), '/// </summary>'];
21
+ return lines
22
+ .map(line => (0, visitor_plugin_common_1.indent)(line, indentLevel))
23
+ .concat('')
24
+ .join('\n');
25
+ }
26
+ exports.transformComment = transformComment;
27
+ function isStringValueNode(node) {
28
+ return node && typeof node === 'object' && node.kind === graphql_1.Kind.STRING;
29
+ }
30
+ function isValueType(type) {
31
+ // Limitation: only checks the list of known built in value types
32
+ // Eg .NET types and struct types won't be detected correctly
33
+ return scalars_js_1.csharpValueTypes.includes(type);
34
+ }
35
+ exports.isValueType = isValueType;
36
+ function getListTypeField(typeNode) {
37
+ if (typeNode.kind === graphql_1.Kind.LIST_TYPE) {
38
+ return {
39
+ required: false,
40
+ type: getListTypeField(typeNode.type),
41
+ };
42
+ }
43
+ if (typeNode.kind === graphql_1.Kind.NON_NULL_TYPE && typeNode.type.kind === graphql_1.Kind.LIST_TYPE) {
44
+ return Object.assign(getListTypeField(typeNode.type), {
45
+ required: true,
46
+ });
47
+ }
48
+ if (typeNode.kind === graphql_1.Kind.NON_NULL_TYPE) {
49
+ return getListTypeField(typeNode.type);
50
+ }
51
+ return undefined;
52
+ }
53
+ exports.getListTypeField = getListTypeField;
54
+ function getListTypeDepth(listType) {
55
+ if (listType) {
56
+ return getListTypeDepth(listType.type) + 1;
57
+ }
58
+ return 0;
59
+ }
60
+ exports.getListTypeDepth = getListTypeDepth;
61
+ function getListInnerTypeNode(typeNode) {
62
+ if (typeNode.kind === graphql_1.Kind.LIST_TYPE) {
63
+ return getListInnerTypeNode(typeNode.type);
64
+ }
65
+ if (typeNode.kind === graphql_1.Kind.NON_NULL_TYPE && typeNode.type.kind === graphql_1.Kind.LIST_TYPE) {
66
+ return getListInnerTypeNode(typeNode.type);
67
+ }
68
+ return typeNode;
69
+ }
70
+ exports.getListInnerTypeNode = getListInnerTypeNode;
71
+ function wrapFieldType(fieldType, listTypeField, listType = 'IEnumerable') {
72
+ if (listTypeField) {
73
+ const innerType = wrapFieldType(fieldType, listTypeField.type, listType);
74
+ return `${listType}<${innerType}>`;
75
+ }
76
+ return fieldType.innerTypeName;
77
+ }
78
+ exports.wrapFieldType = wrapFieldType;
@@ -0,0 +1,91 @@
1
+ import { indentMultiline } from '@graphql-codegen/visitor-plugin-common';
2
+ import { transformComment } from './utils.js';
3
+ export class CSharpDeclarationBlock {
4
+ constructor() {
5
+ this._name = null;
6
+ this._extendStr = [];
7
+ this._implementsStr = [];
8
+ this._kind = null;
9
+ this._access = 'public';
10
+ this._final = false;
11
+ this._static = false;
12
+ this._block = null;
13
+ this._comment = null;
14
+ this._nestedClasses = [];
15
+ }
16
+ nestedClass(nstCls) {
17
+ this._nestedClasses.push(nstCls);
18
+ return this;
19
+ }
20
+ access(access) {
21
+ this._access = access;
22
+ return this;
23
+ }
24
+ asKind(kind) {
25
+ this._kind = kind;
26
+ return this;
27
+ }
28
+ final() {
29
+ this._final = true;
30
+ return this;
31
+ }
32
+ static() {
33
+ this._static = true;
34
+ return this;
35
+ }
36
+ withComment(comment) {
37
+ if (comment) {
38
+ this._comment = transformComment(comment, 1);
39
+ }
40
+ return this;
41
+ }
42
+ withBlock(block) {
43
+ this._block = block;
44
+ return this;
45
+ }
46
+ extends(extendStr) {
47
+ this._extendStr = extendStr;
48
+ return this;
49
+ }
50
+ implements(implementsStr) {
51
+ this._implementsStr = implementsStr;
52
+ return this;
53
+ }
54
+ withName(name) {
55
+ this._name = typeof name === 'object' ? name.value : name;
56
+ return this;
57
+ }
58
+ get string() {
59
+ let result = '';
60
+ if (this._kind) {
61
+ let name = '';
62
+ if (this._name) {
63
+ name = this._name;
64
+ }
65
+ if (this._kind === 'namespace') {
66
+ result += `${this._kind} ${name} `;
67
+ }
68
+ else {
69
+ let extendStr = '';
70
+ let implementsStr = '';
71
+ const final = this._final ? ' final' : '';
72
+ const isStatic = this._static ? ' static' : '';
73
+ if (this._extendStr.length > 0) {
74
+ extendStr = ` : ${this._extendStr.join(', ')}`;
75
+ }
76
+ if (this._implementsStr.length > 0) {
77
+ implementsStr = ` : ${this._implementsStr.join(', ')}`;
78
+ }
79
+ result += `${this._access}${isStatic}${final} ${this._kind} ${name}${extendStr}${implementsStr} `;
80
+ }
81
+ }
82
+ const nestedClasses = this._nestedClasses.length
83
+ ? this._nestedClasses.map(c => indentMultiline(c.string)).join('\n\n')
84
+ : null;
85
+ const before = '{';
86
+ const after = '}';
87
+ const block = [before, nestedClasses, this._block, after].filter(f => f).join('\n');
88
+ result += block;
89
+ return (this._comment ? this._comment : '') + result + '\n';
90
+ }
91
+ }
@@ -0,0 +1,12 @@
1
+ export class CSharpFieldType {
2
+ constructor(fieldType) {
3
+ Object.assign(this, fieldType);
4
+ }
5
+ get innerTypeName() {
6
+ const nullable = this.baseType.valueType && !this.baseType.required ? '?' : '';
7
+ return `${this.baseType.type}${nullable}`;
8
+ }
9
+ get isOuterTypeRequired() {
10
+ return this.listType ? this.listType.required : this.baseType.required;
11
+ }
12
+ }
package/esm/index.js ADDED
@@ -0,0 +1,5 @@
1
+ export * from './c-sharp-declaration-block.js';
2
+ export * from './scalars.js';
3
+ export * from './utils.js';
4
+ export * from './c-sharp-field-types.js';
5
+ export * from './keywords.js';
@@ -0,0 +1,98 @@
1
+ /**
2
+ * C# keywords
3
+ * https://docs.microsoft.com/en-us/dotnet/csharp/language-reference/keywords/
4
+ */
5
+ const csharpKeywords = new Set([
6
+ 'abstract',
7
+ 'as',
8
+ 'base',
9
+ 'bool',
10
+ 'break',
11
+ 'byte',
12
+ 'case',
13
+ 'catch',
14
+ 'char',
15
+ 'checked',
16
+ 'class',
17
+ 'const',
18
+ 'continue',
19
+ 'decimal',
20
+ 'default',
21
+ 'delegate',
22
+ 'do',
23
+ 'double',
24
+ 'else',
25
+ 'enum',
26
+ 'event',
27
+ 'explicit',
28
+ 'extern',
29
+ 'false',
30
+ 'finally',
31
+ 'fixed',
32
+ 'float',
33
+ 'for',
34
+ 'foreach',
35
+ 'goto',
36
+ 'if',
37
+ 'implicit',
38
+ 'in',
39
+ 'int',
40
+ 'interface',
41
+ 'internal',
42
+ 'is',
43
+ 'lock',
44
+ 'long',
45
+ 'namespace',
46
+ 'new',
47
+ 'null',
48
+ 'object',
49
+ 'operator',
50
+ 'out',
51
+ 'override',
52
+ 'params',
53
+ 'private',
54
+ 'protected',
55
+ 'public',
56
+ 'readonly',
57
+ 'record',
58
+ 'ref',
59
+ 'return',
60
+ 'sbyte',
61
+ 'sealed',
62
+ 'short',
63
+ 'sizeof',
64
+ 'stackalloc',
65
+ 'static',
66
+ 'string',
67
+ 'struct',
68
+ 'switch',
69
+ 'this',
70
+ 'throw',
71
+ 'true',
72
+ 'try',
73
+ 'typeof',
74
+ 'uint',
75
+ 'ulong',
76
+ 'unchecked',
77
+ 'unsafe',
78
+ 'ushort',
79
+ 'using',
80
+ 'virtual',
81
+ 'void',
82
+ 'volatile',
83
+ 'while',
84
+ ]);
85
+ /**
86
+ * Checks name against list of keywords. If it is, will prefix value with @
87
+ *
88
+ * Note:
89
+ * This class should first invoke the convertName from base-visitor to convert the string or node
90
+ * value according the naming configuration, eg upper or lower case. Then resulting string checked
91
+ * against the list or keywords.
92
+ * However the generated C# code is not yet able to handle fields that are in a different case so
93
+ * the invocation of convertName is omitted purposely.
94
+ */
95
+ export function convertSafeName(node) {
96
+ const name = typeof node === 'string' ? node : node.value;
97
+ return csharpKeywords.has(name) ? `@${name}` : name;
98
+ }
package/esm/scalars.js ADDED
@@ -0,0 +1,24 @@
1
+ export const C_SHARP_SCALARS = {
2
+ ID: 'string',
3
+ String: 'string',
4
+ Boolean: 'bool',
5
+ Int: 'int',
6
+ Float: 'double',
7
+ Date: 'DateTime',
8
+ };
9
+ export const csharpValueTypes = [
10
+ 'bool',
11
+ 'byte',
12
+ 'sbyte',
13
+ 'char',
14
+ 'decimal',
15
+ 'double',
16
+ 'float',
17
+ 'int',
18
+ 'uint',
19
+ 'long',
20
+ 'ulong',
21
+ 'short',
22
+ 'ushort',
23
+ 'DateTime',
24
+ ];
package/esm/utils.js ADDED
@@ -0,0 +1,69 @@
1
+ // This file is bundled and inlined.
2
+ // We should probably make this a shared package though.
3
+ // eslint-disable-next-line import/no-extraneous-dependencies
4
+ import { Kind } from 'graphql';
5
+ // eslint-disable-next-line import/no-extraneous-dependencies
6
+ import { indent } from '@graphql-codegen/visitor-plugin-common';
7
+ import { csharpValueTypes } from './scalars.js';
8
+ export function transformComment(comment, indentLevel = 0) {
9
+ if (!comment) {
10
+ return '';
11
+ }
12
+ if (isStringValueNode(comment)) {
13
+ comment = comment.value;
14
+ }
15
+ comment = comment.trimStart().split('*/').join('*\\/');
16
+ let lines = comment.split('\n');
17
+ lines = ['/// <summary>', ...lines.map(line => `/// ${line}`), '/// </summary>'];
18
+ return lines
19
+ .map(line => indent(line, indentLevel))
20
+ .concat('')
21
+ .join('\n');
22
+ }
23
+ function isStringValueNode(node) {
24
+ return node && typeof node === 'object' && node.kind === Kind.STRING;
25
+ }
26
+ export function isValueType(type) {
27
+ // Limitation: only checks the list of known built in value types
28
+ // Eg .NET types and struct types won't be detected correctly
29
+ return csharpValueTypes.includes(type);
30
+ }
31
+ export function getListTypeField(typeNode) {
32
+ if (typeNode.kind === Kind.LIST_TYPE) {
33
+ return {
34
+ required: false,
35
+ type: getListTypeField(typeNode.type),
36
+ };
37
+ }
38
+ if (typeNode.kind === Kind.NON_NULL_TYPE && typeNode.type.kind === Kind.LIST_TYPE) {
39
+ return Object.assign(getListTypeField(typeNode.type), {
40
+ required: true,
41
+ });
42
+ }
43
+ if (typeNode.kind === Kind.NON_NULL_TYPE) {
44
+ return getListTypeField(typeNode.type);
45
+ }
46
+ return undefined;
47
+ }
48
+ export function getListTypeDepth(listType) {
49
+ if (listType) {
50
+ return getListTypeDepth(listType.type) + 1;
51
+ }
52
+ return 0;
53
+ }
54
+ export function getListInnerTypeNode(typeNode) {
55
+ if (typeNode.kind === Kind.LIST_TYPE) {
56
+ return getListInnerTypeNode(typeNode.type);
57
+ }
58
+ if (typeNode.kind === Kind.NON_NULL_TYPE && typeNode.type.kind === Kind.LIST_TYPE) {
59
+ return getListInnerTypeNode(typeNode.type);
60
+ }
61
+ return typeNode;
62
+ }
63
+ export function wrapFieldType(fieldType, listTypeField, listType = 'IEnumerable') {
64
+ if (listTypeField) {
65
+ const innerType = wrapFieldType(fieldType, listTypeField.type, listType);
66
+ return `${listType}<${innerType}>`;
67
+ }
68
+ return fieldType.innerTypeName;
69
+ }
package/package.json ADDED
@@ -0,0 +1,42 @@
1
+ {
2
+ "name": "@graphql-codegen/c-sharp-common",
3
+ "version": "0.0.0",
4
+ "sideEffects": false,
5
+ "peerDependencies": {
6
+ "graphql": "^0.8.0 || ^0.9.0 || ^0.10.0 || ^0.11.0 || ^0.12.0 || ^0.13.0 || ^14.0.0 || ^15.0.0 || ^16.0.0",
7
+ "graphql-tag": "2.12.6"
8
+ },
9
+ "dependencies": {
10
+ "@graphql-codegen/plugin-helpers": "^2.4.0",
11
+ "@graphql-codegen/visitor-plugin-common": "^2.9.1",
12
+ "auto-bind": "~4.0.0",
13
+ "change-case-all": "1.0.14",
14
+ "tslib": "~2.4.0"
15
+ },
16
+ "repository": "git@github.com:dotansimha/graphql-code-generator.git",
17
+ "license": "MIT",
18
+ "main": "cjs/index.js",
19
+ "module": "esm/index.js",
20
+ "typings": "typings/index.d.ts",
21
+ "typescript": {
22
+ "definition": "typings/index.d.ts"
23
+ },
24
+ "type": "module",
25
+ "exports": {
26
+ ".": {
27
+ "require": {
28
+ "types": "./typings/index.d.ts",
29
+ "default": "./cjs/index.js"
30
+ },
31
+ "import": {
32
+ "types": "./typings/index.d.ts",
33
+ "default": "./esm/index.js"
34
+ },
35
+ "default": {
36
+ "types": "./typings/index.d.ts",
37
+ "default": "./esm/index.js"
38
+ }
39
+ },
40
+ "./package.json": "./package.json"
41
+ }
42
+ }
@@ -0,0 +1,26 @@
1
+ import { StringValueNode, NameNode } from 'graphql';
2
+ export declare type Access = 'private' | 'public' | 'protected';
3
+ export declare type Kind = 'namespace' | 'class' | 'record' | 'interface' | 'enum';
4
+ export declare class CSharpDeclarationBlock {
5
+ _name: string;
6
+ _extendStr: string[];
7
+ _implementsStr: string[];
8
+ _kind: Kind;
9
+ _access: Access;
10
+ _final: boolean;
11
+ _static: boolean;
12
+ _block: any;
13
+ _comment: any;
14
+ _nestedClasses: CSharpDeclarationBlock[];
15
+ nestedClass(nstCls: CSharpDeclarationBlock): CSharpDeclarationBlock;
16
+ access(access: Access): CSharpDeclarationBlock;
17
+ asKind(kind: Kind): CSharpDeclarationBlock;
18
+ final(): CSharpDeclarationBlock;
19
+ static(): CSharpDeclarationBlock;
20
+ withComment(comment: string | StringValueNode | null): CSharpDeclarationBlock;
21
+ withBlock(block: string): CSharpDeclarationBlock;
22
+ extends(extendStr: string[]): CSharpDeclarationBlock;
23
+ implements(implementsStr: string[]): CSharpDeclarationBlock;
24
+ withName(name: string | NameNode): CSharpDeclarationBlock;
25
+ get string(): string;
26
+ }
@@ -0,0 +1,20 @@
1
+ export interface BaseTypeField {
2
+ type: string;
3
+ valueType: boolean;
4
+ required: boolean;
5
+ }
6
+ export interface ListTypeField {
7
+ required: boolean;
8
+ type: ListTypeField;
9
+ }
10
+ export interface CSharpField {
11
+ baseType: BaseTypeField;
12
+ listType?: ListTypeField;
13
+ }
14
+ export declare class CSharpFieldType implements CSharpField {
15
+ baseType: BaseTypeField;
16
+ listType?: ListTypeField;
17
+ constructor(fieldType: CSharpField);
18
+ get innerTypeName(): string;
19
+ get isOuterTypeRequired(): boolean;
20
+ }
@@ -0,0 +1,5 @@
1
+ export * from './c-sharp-declaration-block.js';
2
+ export * from './scalars.js';
3
+ export * from './utils.js';
4
+ export * from './c-sharp-field-types.js';
5
+ export * from './keywords.js';
@@ -0,0 +1,12 @@
1
+ import { NameNode } from 'graphql';
2
+ /**
3
+ * Checks name against list of keywords. If it is, will prefix value with @
4
+ *
5
+ * Note:
6
+ * This class should first invoke the convertName from base-visitor to convert the string or node
7
+ * value according the naming configuration, eg upper or lower case. Then resulting string checked
8
+ * against the list or keywords.
9
+ * However the generated C# code is not yet able to handle fields that are in a different case so
10
+ * the invocation of convertName is omitted purposely.
11
+ */
12
+ export declare function convertSafeName(node: NameNode | string): string;
@@ -0,0 +1,9 @@
1
+ export declare const C_SHARP_SCALARS: {
2
+ ID: string;
3
+ String: string;
4
+ Boolean: string;
5
+ Int: string;
6
+ Float: string;
7
+ Date: string;
8
+ };
9
+ export declare const csharpValueTypes: string[];
@@ -0,0 +1,8 @@
1
+ import { TypeNode, StringValueNode } from 'graphql';
2
+ import { ListTypeField, CSharpFieldType } from './c-sharp-field-types.js';
3
+ export declare function transformComment(comment: string | StringValueNode, indentLevel?: number): string;
4
+ export declare function isValueType(type: string): boolean;
5
+ export declare function getListTypeField(typeNode: TypeNode): ListTypeField | undefined;
6
+ export declare function getListTypeDepth(listType: ListTypeField): number;
7
+ export declare function getListInnerTypeNode(typeNode: TypeNode): TypeNode;
8
+ export declare function wrapFieldType(fieldType: CSharpFieldType, listTypeField?: ListTypeField, listType?: string): string;