@graphql-codegen/java-common 2.1.20 → 2.2.0-alpha-2fbcdb6d3.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.
- package/cjs/index.js +6 -0
- package/{index.js → cjs/java-declaration-block.js} +10 -53
- package/cjs/package.json +1 -0
- package/cjs/scalars.js +10 -0
- package/cjs/utils.js +33 -0
- package/esm/index.js +3 -0
- package/{index.mjs → esm/java-declaration-block.js} +2 -39
- package/esm/scalars.js +7 -0
- package/esm/utils.js +26 -0
- package/package.json +22 -15
- package/typings/index.d.ts +3 -0
- package/{java-declaration-block.d.ts → typings/java-declaration-block.d.ts} +0 -0
- package/{scalars.d.ts → typings/scalars.d.ts} +0 -0
- package/{utils.d.ts → typings/utils.d.ts} +0 -0
- package/index.d.ts +0 -3
package/cjs/index.js
ADDED
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
const tslib_1 = require("tslib");
|
|
4
|
+
tslib_1.__exportStar(require("./java-declaration-block.js"), exports);
|
|
5
|
+
tslib_1.__exportStar(require("./scalars.js"), exports);
|
|
6
|
+
tslib_1.__exportStar(require("./utils.js"), exports);
|
|
@@ -1,38 +1,8 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
const visitorPluginCommon = require('@graphql-codegen/visitor-plugin-common');
|
|
8
|
-
const graphql = require('graphql');
|
|
9
|
-
const minIndent = _interopDefault(require('min-indent'));
|
|
10
|
-
const unixify = _interopDefault(require('unixify'));
|
|
11
|
-
|
|
12
|
-
function buildPackageNameFromPath(path) {
|
|
13
|
-
return unixify(path || '')
|
|
14
|
-
.replace(/src\/main\/.*?\//, '')
|
|
15
|
-
.replace(/\//g, '.');
|
|
16
|
-
}
|
|
17
|
-
function wrapTypeWithModifiers(baseType, typeNode, listType = 'Iterable') {
|
|
18
|
-
if (typeNode.kind === graphql.Kind.NON_NULL_TYPE) {
|
|
19
|
-
return wrapTypeWithModifiers(baseType, typeNode.type, listType);
|
|
20
|
-
}
|
|
21
|
-
if (typeNode.kind === graphql.Kind.LIST_TYPE) {
|
|
22
|
-
const innerType = wrapTypeWithModifiers(baseType, typeNode.type, listType);
|
|
23
|
-
return `${listType}<${innerType}>`;
|
|
24
|
-
}
|
|
25
|
-
return baseType;
|
|
26
|
-
}
|
|
27
|
-
function stripIndent(string) {
|
|
28
|
-
const indent = minIndent(string);
|
|
29
|
-
if (indent === 0) {
|
|
30
|
-
return string;
|
|
31
|
-
}
|
|
32
|
-
const regex = new RegExp(`^[ \\t]{${indent}}`, 'gm');
|
|
33
|
-
return string.replace(regex, '');
|
|
34
|
-
}
|
|
35
|
-
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.JavaDeclarationBlock = void 0;
|
|
4
|
+
const visitor_plugin_common_1 = require("@graphql-codegen/visitor-plugin-common");
|
|
5
|
+
const utils_js_1 = require("./utils.js");
|
|
36
6
|
class JavaDeclarationBlock {
|
|
37
7
|
constructor() {
|
|
38
8
|
this._name = null;
|
|
@@ -75,7 +45,7 @@ class JavaDeclarationBlock {
|
|
|
75
45
|
}
|
|
76
46
|
withComment(comment) {
|
|
77
47
|
if (comment) {
|
|
78
|
-
this._comment =
|
|
48
|
+
this._comment = (0, visitor_plugin_common_1.transformComment)(comment, 0);
|
|
79
49
|
}
|
|
80
50
|
return this;
|
|
81
51
|
}
|
|
@@ -123,7 +93,7 @@ class JavaDeclarationBlock {
|
|
|
123
93
|
].filter(f => f);
|
|
124
94
|
const args = method.args.map(arg => this.printMember(arg)).join(', ');
|
|
125
95
|
return `${pieces.join(' ')}(${args}) {
|
|
126
|
-
${
|
|
96
|
+
${(0, visitor_plugin_common_1.indentMultiline)(method.implementation)}
|
|
127
97
|
}`;
|
|
128
98
|
}
|
|
129
99
|
addClassMember(name, type, value, typeAnnotations = [], access = null, flags = {}) {
|
|
@@ -186,13 +156,13 @@ ${visitorPluginCommon.indentMultiline(method.implementation)}
|
|
|
186
156
|
result += `${annotatesStr}${this._access}${isStatic}${final} ${this._kind} ${name}${extendStr}${implementsStr} `;
|
|
187
157
|
}
|
|
188
158
|
const members = this._members.length
|
|
189
|
-
?
|
|
159
|
+
? (0, visitor_plugin_common_1.indentMultiline)((0, utils_js_1.stripIndent)(this._members.map(member => this.printMember(member) + ';').join('\n')))
|
|
190
160
|
: null;
|
|
191
161
|
const methods = this._methods.length
|
|
192
|
-
?
|
|
162
|
+
? (0, visitor_plugin_common_1.indentMultiline)((0, utils_js_1.stripIndent)(this._methods.map(method => this.printMethod(method)).join('\n\n')))
|
|
193
163
|
: null;
|
|
194
164
|
const nestedClasses = this._nestedClasses.length
|
|
195
|
-
? this._nestedClasses.map(c =>
|
|
165
|
+
? this._nestedClasses.map(c => (0, visitor_plugin_common_1.indentMultiline)(c.string)).join('\n\n')
|
|
196
166
|
: null;
|
|
197
167
|
const before = '{';
|
|
198
168
|
const after = '}';
|
|
@@ -201,17 +171,4 @@ ${visitorPluginCommon.indentMultiline(method.implementation)}
|
|
|
201
171
|
return (this._comment ? this._comment : '') + result + '\n';
|
|
202
172
|
}
|
|
203
173
|
}
|
|
204
|
-
|
|
205
|
-
const JAVA_SCALARS = {
|
|
206
|
-
ID: 'Object',
|
|
207
|
-
String: 'String',
|
|
208
|
-
Boolean: 'Boolean',
|
|
209
|
-
Int: 'Integer',
|
|
210
|
-
Float: 'Double',
|
|
211
|
-
};
|
|
212
|
-
|
|
213
|
-
exports.JAVA_SCALARS = JAVA_SCALARS;
|
|
214
174
|
exports.JavaDeclarationBlock = JavaDeclarationBlock;
|
|
215
|
-
exports.buildPackageNameFromPath = buildPackageNameFromPath;
|
|
216
|
-
exports.stripIndent = stripIndent;
|
|
217
|
-
exports.wrapTypeWithModifiers = wrapTypeWithModifiers;
|
package/cjs/package.json
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"type":"commonjs"}
|
package/cjs/scalars.js
ADDED
package/cjs/utils.js
ADDED
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.stripIndent = exports.wrapTypeWithModifiers = exports.buildPackageNameFromPath = void 0;
|
|
4
|
+
const tslib_1 = require("tslib");
|
|
5
|
+
const graphql_1 = require("graphql");
|
|
6
|
+
const min_indent_1 = tslib_1.__importDefault(require("min-indent"));
|
|
7
|
+
const unixify_1 = tslib_1.__importDefault(require("unixify"));
|
|
8
|
+
function buildPackageNameFromPath(path) {
|
|
9
|
+
return (0, unixify_1.default)(path || '')
|
|
10
|
+
.replace(/src\/main\/.*?\//, '')
|
|
11
|
+
.replace(/\//g, '.');
|
|
12
|
+
}
|
|
13
|
+
exports.buildPackageNameFromPath = buildPackageNameFromPath;
|
|
14
|
+
function wrapTypeWithModifiers(baseType, typeNode, listType = 'Iterable') {
|
|
15
|
+
if (typeNode.kind === graphql_1.Kind.NON_NULL_TYPE) {
|
|
16
|
+
return wrapTypeWithModifiers(baseType, typeNode.type, listType);
|
|
17
|
+
}
|
|
18
|
+
if (typeNode.kind === graphql_1.Kind.LIST_TYPE) {
|
|
19
|
+
const innerType = wrapTypeWithModifiers(baseType, typeNode.type, listType);
|
|
20
|
+
return `${listType}<${innerType}>`;
|
|
21
|
+
}
|
|
22
|
+
return baseType;
|
|
23
|
+
}
|
|
24
|
+
exports.wrapTypeWithModifiers = wrapTypeWithModifiers;
|
|
25
|
+
function stripIndent(string) {
|
|
26
|
+
const indent = (0, min_indent_1.default)(string);
|
|
27
|
+
if (indent === 0) {
|
|
28
|
+
return string;
|
|
29
|
+
}
|
|
30
|
+
const regex = new RegExp(`^[ \\t]{${indent}}`, 'gm');
|
|
31
|
+
return string.replace(regex, '');
|
|
32
|
+
}
|
|
33
|
+
exports.stripIndent = stripIndent;
|
package/esm/index.js
ADDED
|
@@ -1,33 +1,6 @@
|
|
|
1
1
|
import { transformComment, indentMultiline } from '@graphql-codegen/visitor-plugin-common';
|
|
2
|
-
import {
|
|
3
|
-
|
|
4
|
-
import unixify from 'unixify';
|
|
5
|
-
|
|
6
|
-
function buildPackageNameFromPath(path) {
|
|
7
|
-
return unixify(path || '')
|
|
8
|
-
.replace(/src\/main\/.*?\//, '')
|
|
9
|
-
.replace(/\//g, '.');
|
|
10
|
-
}
|
|
11
|
-
function wrapTypeWithModifiers(baseType, typeNode, listType = 'Iterable') {
|
|
12
|
-
if (typeNode.kind === Kind.NON_NULL_TYPE) {
|
|
13
|
-
return wrapTypeWithModifiers(baseType, typeNode.type, listType);
|
|
14
|
-
}
|
|
15
|
-
if (typeNode.kind === Kind.LIST_TYPE) {
|
|
16
|
-
const innerType = wrapTypeWithModifiers(baseType, typeNode.type, listType);
|
|
17
|
-
return `${listType}<${innerType}>`;
|
|
18
|
-
}
|
|
19
|
-
return baseType;
|
|
20
|
-
}
|
|
21
|
-
function stripIndent(string) {
|
|
22
|
-
const indent = minIndent(string);
|
|
23
|
-
if (indent === 0) {
|
|
24
|
-
return string;
|
|
25
|
-
}
|
|
26
|
-
const regex = new RegExp(`^[ \\t]{${indent}}`, 'gm');
|
|
27
|
-
return string.replace(regex, '');
|
|
28
|
-
}
|
|
29
|
-
|
|
30
|
-
class JavaDeclarationBlock {
|
|
2
|
+
import { stripIndent } from './utils.js';
|
|
3
|
+
export class JavaDeclarationBlock {
|
|
31
4
|
constructor() {
|
|
32
5
|
this._name = null;
|
|
33
6
|
this._extendStr = [];
|
|
@@ -195,13 +168,3 @@ ${indentMultiline(method.implementation)}
|
|
|
195
168
|
return (this._comment ? this._comment : '') + result + '\n';
|
|
196
169
|
}
|
|
197
170
|
}
|
|
198
|
-
|
|
199
|
-
const JAVA_SCALARS = {
|
|
200
|
-
ID: 'Object',
|
|
201
|
-
String: 'String',
|
|
202
|
-
Boolean: 'Boolean',
|
|
203
|
-
Int: 'Integer',
|
|
204
|
-
Float: 'Double',
|
|
205
|
-
};
|
|
206
|
-
|
|
207
|
-
export { JAVA_SCALARS, JavaDeclarationBlock, buildPackageNameFromPath, stripIndent, wrapTypeWithModifiers };
|
package/esm/scalars.js
ADDED
package/esm/utils.js
ADDED
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import { Kind } from 'graphql';
|
|
2
|
+
import minIndent from 'min-indent';
|
|
3
|
+
import unixify from 'unixify';
|
|
4
|
+
export function buildPackageNameFromPath(path) {
|
|
5
|
+
return unixify(path || '')
|
|
6
|
+
.replace(/src\/main\/.*?\//, '')
|
|
7
|
+
.replace(/\//g, '.');
|
|
8
|
+
}
|
|
9
|
+
export function wrapTypeWithModifiers(baseType, typeNode, listType = 'Iterable') {
|
|
10
|
+
if (typeNode.kind === Kind.NON_NULL_TYPE) {
|
|
11
|
+
return wrapTypeWithModifiers(baseType, typeNode.type, listType);
|
|
12
|
+
}
|
|
13
|
+
if (typeNode.kind === Kind.LIST_TYPE) {
|
|
14
|
+
const innerType = wrapTypeWithModifiers(baseType, typeNode.type, listType);
|
|
15
|
+
return `${listType}<${innerType}>`;
|
|
16
|
+
}
|
|
17
|
+
return baseType;
|
|
18
|
+
}
|
|
19
|
+
export function stripIndent(string) {
|
|
20
|
+
const indent = minIndent(string);
|
|
21
|
+
if (indent === 0) {
|
|
22
|
+
return string;
|
|
23
|
+
}
|
|
24
|
+
const regex = new RegExp(`^[ \\t]{${indent}}`, 'gm');
|
|
25
|
+
return string.replace(regex, '');
|
|
26
|
+
}
|
package/package.json
CHANGED
|
@@ -1,13 +1,13 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@graphql-codegen/java-common",
|
|
3
|
-
"version": "2.
|
|
3
|
+
"version": "2.2.0-alpha-2fbcdb6d3.0",
|
|
4
4
|
"description": "GraphQL Code Generator utils library for developing Java plugins",
|
|
5
5
|
"peerDependencies": {
|
|
6
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
7
|
},
|
|
8
8
|
"dependencies": {
|
|
9
|
-
"@graphql-codegen/plugin-helpers": "^2.
|
|
10
|
-
"@graphql-codegen/visitor-plugin-common": "2.
|
|
9
|
+
"@graphql-codegen/plugin-helpers": "^2.5.0-alpha-2fbcdb6d3.0",
|
|
10
|
+
"@graphql-codegen/visitor-plugin-common": "2.11.0-alpha-2fbcdb6d3.0",
|
|
11
11
|
"auto-bind": "~4.0.0",
|
|
12
12
|
"min-indent": "1.0.1",
|
|
13
13
|
"tslib": "~2.4.0",
|
|
@@ -19,21 +19,28 @@
|
|
|
19
19
|
"directory": "packages/plugins/java/common"
|
|
20
20
|
},
|
|
21
21
|
"license": "MIT",
|
|
22
|
-
"main": "index.js",
|
|
23
|
-
"module": "index.
|
|
24
|
-
"typings": "index.d.ts",
|
|
22
|
+
"main": "cjs/index.js",
|
|
23
|
+
"module": "esm/index.js",
|
|
24
|
+
"typings": "typings/index.d.ts",
|
|
25
25
|
"typescript": {
|
|
26
|
-
"definition": "index.d.ts"
|
|
26
|
+
"definition": "typings/index.d.ts"
|
|
27
27
|
},
|
|
28
|
+
"type": "module",
|
|
28
29
|
"exports": {
|
|
29
|
-
"./package.json": "./package.json",
|
|
30
30
|
".": {
|
|
31
|
-
"require":
|
|
32
|
-
|
|
31
|
+
"require": {
|
|
32
|
+
"types": "./typings/index.d.ts",
|
|
33
|
+
"default": "./cjs/index.js"
|
|
34
|
+
},
|
|
35
|
+
"import": {
|
|
36
|
+
"types": "./typings/index.d.ts",
|
|
37
|
+
"default": "./esm/index.js"
|
|
38
|
+
},
|
|
39
|
+
"default": {
|
|
40
|
+
"types": "./typings/index.d.ts",
|
|
41
|
+
"default": "./esm/index.js"
|
|
42
|
+
}
|
|
33
43
|
},
|
|
34
|
-
"
|
|
35
|
-
"require": "./*.js",
|
|
36
|
-
"import": "./*.mjs"
|
|
37
|
-
}
|
|
44
|
+
"./package.json": "./package.json"
|
|
38
45
|
}
|
|
39
|
-
}
|
|
46
|
+
}
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
package/index.d.ts
DELETED