graphql-form 0.0.24 → 0.0.25
Sign up to get free protection for your applications and to get access to all the features.
- package/jest.config.ts +14 -0
- package/lib/FormToCode/gql/formToGql.spec.d.ts +1 -0
- package/lib/FormToCode/gql/formToGql.spec.js +50 -0
- package/lib/FormToCode/gql/formToGql.spec.js.map +1 -0
- package/lib/FormToCode/gql/index.js.map +1 -1
- package/lib/FormToCode/gql/reducers.js +4 -1
- package/lib/FormToCode/gql/reducers.js.map +1 -1
- package/lib/FormToCode/zeus/formToZeus.spec.d.ts +1 -0
- package/lib/FormToCode/zeus/formToZeus.spec.js +59 -0
- package/lib/FormToCode/zeus/formToZeus.spec.js.map +1 -0
- package/lib/FormToCode/zeus/index.js.map +1 -1
- package/lib/FormToCode/zeus/resolvers.d.ts +1 -1
- package/lib/FormToCode/zeus/resolvers.js +4 -1
- package/lib/FormToCode/zeus/resolvers.js.map +1 -1
- package/lib/__tests__/consts.d.ts +11 -0
- package/lib/__tests__/consts.js +38 -0
- package/lib/__tests__/consts.js.map +1 -0
- package/lib/__tests__/index.d.ts +2 -0
- package/lib/__tests__/index.js +19 -0
- package/lib/__tests__/index.js.map +1 -0
- package/lib/__tests__/testUtils.d.ts +1 -0
- package/lib/__tests__/testUtils.js +8 -0
- package/lib/__tests__/testUtils.js.map +1 -0
- package/package.json +3 -3
- package/src/FormToCode/gql/formToGql.spec.ts +75 -0
- package/src/FormToCode/gql/index.ts +1 -1
- package/src/FormToCode/gql/reducers.ts +5 -2
- package/src/FormToCode/zeus/formToZeus.spec.ts +84 -0
- package/src/FormToCode/zeus/index.ts +1 -1
- package/src/FormToCode/zeus/resolvers.tsx +6 -3
- package/src/__tests__/consts.ts +40 -0
- package/src/__tests__/index.ts +2 -0
- package/src/__tests__/testUtils.ts +2 -0
- package/tsconfig.build.json +2 -2
package/jest.config.ts
ADDED
@@ -0,0 +1,14 @@
|
|
1
|
+
import type { Config } from '@jest/types';
|
2
|
+
|
3
|
+
const config: Config.InitialOptions = {
|
4
|
+
verbose: true,
|
5
|
+
preset: 'ts-jest',
|
6
|
+
moduleFileExtensions: ['ts', 'tsx', 'js'],
|
7
|
+
moduleNameMapper: {
|
8
|
+
'@/(.*)': ['<rootDir>/src/'],
|
9
|
+
},
|
10
|
+
testMatch: ['**/*.spec.(ts|tsx)'],
|
11
|
+
watchPathIgnorePatterns: ['node_modules'],
|
12
|
+
watchman: false,
|
13
|
+
};
|
14
|
+
export default config;
|
@@ -0,0 +1 @@
|
|
1
|
+
export {};
|
@@ -0,0 +1,50 @@
|
|
1
|
+
"use strict";
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
3
|
+
var index_1 = require("./index");
|
4
|
+
var __tests__1 = require("../../__tests__");
|
5
|
+
it('tranform form to Gql, typeNode, No args', function () {
|
6
|
+
// Arrange
|
7
|
+
var expectedValue = 'test';
|
8
|
+
// Act
|
9
|
+
var result = (0, index_1.formToGql)({ nodes: __tests__1.singleNode, fields: __tests__1.fields });
|
10
|
+
// Assert
|
11
|
+
var matchExact = (0, __tests__1.replSpace)(result);
|
12
|
+
matchExact(expectedValue);
|
13
|
+
});
|
14
|
+
it('tranform form to Gql, typeNode, With args', function () {
|
15
|
+
// Arrange
|
16
|
+
var expectedValue = "testInput(\n test: 5\n )";
|
17
|
+
// Act
|
18
|
+
var result = (0, index_1.formToGql)({ nodes: __tests__1.nodes, fields: __tests__1.extenedFields });
|
19
|
+
// Assert
|
20
|
+
var matchExact = (0, __tests__1.replSpace)(result);
|
21
|
+
matchExact(expectedValue);
|
22
|
+
});
|
23
|
+
it('tranform form to Gql, typeNode, fieldsNodeWithArgs', function () {
|
24
|
+
// Arrange
|
25
|
+
var expectedValue = "testInput(\n test: 5\n )";
|
26
|
+
// Act
|
27
|
+
var result = (0, index_1.formToGql)({ nodes: __tests__1.nodes, fields: __tests__1.fieldsNodeWithArgs });
|
28
|
+
// Assert
|
29
|
+
var matchExact = (0, __tests__1.replSpace)(result);
|
30
|
+
matchExact(expectedValue);
|
31
|
+
});
|
32
|
+
it('tranform form to Gql, typeNode, fieldsNodeWithArgsWithInput', function () {
|
33
|
+
// Arrange
|
34
|
+
var expectedValue = 'testInput(testInput:[objectObject])';
|
35
|
+
// Act
|
36
|
+
var result = (0, index_1.formToGql)({ nodes: __tests__1.nodes, fields: __tests__1.fieldsNodeWithArgsWithInput });
|
37
|
+
// Assert
|
38
|
+
var matchExact = (0, __tests__1.replSpace)(result);
|
39
|
+
matchExact(expectedValue);
|
40
|
+
});
|
41
|
+
it('tranform form to Gql, nodeWithArgs, fieldsNodeWithArgsWithInput', function () {
|
42
|
+
// Arrange
|
43
|
+
var expectedValue = 'testInput(testInput:[objectObject])';
|
44
|
+
// Act
|
45
|
+
var result = (0, index_1.formToGql)({ nodes: [__tests__1.nodeWithArgs], fields: __tests__1.fieldsNodeWithArgsWithInput });
|
46
|
+
// Assert
|
47
|
+
var matchExact = (0, __tests__1.replSpace)(result);
|
48
|
+
matchExact(expectedValue);
|
49
|
+
});
|
50
|
+
//# sourceMappingURL=formToGql.spec.js.map
|
@@ -0,0 +1 @@
|
|
1
|
+
{"version":3,"file":"formToGql.spec.js","sourceRoot":"","sources":["../../../src/FormToCode/gql/formToGql.spec.ts"],"names":[],"mappings":";;AAAA,iCAAoC;AACpC,4CASyB;AAEzB,EAAE,CAAC,yCAAyC,EAAE;IAC1C,UAAU;IACV,IAAM,aAAa,GAAG,MAAM,CAAC;IAC7B,MAAM;IACN,IAAM,MAAM,GAAG,IAAA,iBAAS,EAAC,EAAE,KAAK,EAAE,qBAAU,EAAE,MAAM,mBAAA,EAAE,CAAC,CAAC;IACxD,SAAS;IACT,IAAM,UAAU,GAAG,IAAA,oBAAS,EAAC,MAAM,CAAC,CAAC;IACrC,UAAU,CAAC,aAAa,CAAC,CAAC;AAC9B,CAAC,CAAC,CAAC;AAEH,EAAE,CAAC,2CAA2C,EAAE;IAC5C,UAAU;IACV,IAAM,aAAa,GAAG,oCAEpB,CAAC;IAEH,MAAM;IACN,IAAM,MAAM,GAAG,IAAA,iBAAS,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
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/FormToCode/gql/index.ts"],"names":[],"mappings":";;;AAAA,
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/FormToCode/gql/index.ts"],"names":[],"mappings":";;;AAAA,uCAAwD;AAIjD,IAAM,SAAS,GAAG,UAAC,EAA+E;QAA7E,MAAM,YAAA,EAAE,KAAK,WAAA;IACrC,IAAM,SAAS,GAAG,IAAA,2BAAgB,EAAC,MAAM,CAAC,CAAC;IAC3C,IAAM,CAAC,GAAG,IAAA,mBAAQ,EAAC,SAAS,EAAE,KAAK,CAAC,CAAC;IACrC,OAAO,CAAC,CAAC;AACb,CAAC,CAAC;AAJW,QAAA,SAAS,aAIpB"}
|
@@ -5,7 +5,10 @@ var resolvers_1 = require("./resolvers");
|
|
5
5
|
var fieldsToReductor = function (toggledFields) {
|
6
6
|
return Object.entries(toggledFields).reduce(function (a, _a) {
|
7
7
|
var key = _a[0], value = _a[1];
|
8
|
-
var pathElements = key
|
8
|
+
var pathElements = key
|
9
|
+
.replace('... on', '___on')
|
10
|
+
.split('.')
|
11
|
+
.map(function (e) { return e.replace('___on', '... on'); });
|
9
12
|
var start = a;
|
10
13
|
pathElements.forEach(function (el, index) {
|
11
14
|
var _a;
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"reducers.js","sourceRoot":"","sources":["../../../src/FormToCode/gql/reducers.ts"],"names":[],"mappings":";;;AAAA,
|
1
|
+
{"version":3,"file":"reducers.js","sourceRoot":"","sources":["../../../src/FormToCode/gql/reducers.ts"],"names":[],"mappings":";;;AAAA,yCAA6C;AAKtC,IAAM,gBAAgB,GAAG,UAAC,aAAyC;IACtE,OAAA,MAAM,CAAC,OAAO,CAAC,aAAa,CAAC,CAAC,MAAM,CAAC,UAAC,CAAC,EAAE,EAAY;YAAX,GAAG,QAAA,EAAE,KAAK,QAAA;QAChD,IAAM,YAAY,GAAG,GAAG;aACnB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./index");
|
4
|
+
var __tests__1 = require("../../__tests__");
|
5
|
+
it('tranform form to zeus, typeNode, No args', function () {
|
6
|
+
// Arrange
|
7
|
+
var expectedValue = 'api("undefined")({})';
|
8
|
+
// Act
|
9
|
+
var result = (0, index_1.formToZeus)({ nodes: __tests__1.singleNode, fields: __tests__1.fields });
|
10
|
+
// Assert
|
11
|
+
var matchExact = (0, __tests__1.replSpace)(result);
|
12
|
+
matchExact(expectedValue);
|
13
|
+
});
|
14
|
+
it('tranform form to zeus, typeNode, With args', function () {
|
15
|
+
// Arrange
|
16
|
+
var expectedValue = 'api("undefined")({})';
|
17
|
+
// Act
|
18
|
+
var result = (0, index_1.formToZeus)({ nodes: __tests__1.nodes, fields: __tests__1.fields });
|
19
|
+
// Assert
|
20
|
+
var matchExact = (0, __tests__1.replSpace)(result);
|
21
|
+
matchExact(expectedValue);
|
22
|
+
});
|
23
|
+
it('tranform form to zeus, inputNode, With args', function () {
|
24
|
+
// Arrange
|
25
|
+
var expectedValue = 'testInput:[{test:5},true]';
|
26
|
+
// Act
|
27
|
+
var result = (0, index_1.formToZeus)({ nodes: __tests__1.nodes, fields: __tests__1.extenedFields });
|
28
|
+
// Assert
|
29
|
+
var matchExact = (0, __tests__1.replSpace)(result);
|
30
|
+
matchExact(expectedValue);
|
31
|
+
});
|
32
|
+
it('tranform form to zeus, singleTypeNode, No args', function () {
|
33
|
+
// Arrange
|
34
|
+
var expectedValue = 'testInput:[{test:5},true]';
|
35
|
+
// Act
|
36
|
+
var result = (0, index_1.formToZeus)({ nodes: __tests__1.singleNode, fields: __tests__1.extenedFields });
|
37
|
+
// Assert
|
38
|
+
var matchExact = (0, __tests__1.replSpace)(result);
|
39
|
+
matchExact(expectedValue);
|
40
|
+
});
|
41
|
+
it('tranform form to zeus, singleTypeNode, fieldsNodeWithArgs', function () {
|
42
|
+
// Arrange
|
43
|
+
var expectedValue = 'testInput:[{test:5},true]';
|
44
|
+
// Act
|
45
|
+
var result = (0, index_1.formToZeus)({ nodes: __tests__1.singleNode, fields: __tests__1.fieldsNodeWithArgs });
|
46
|
+
// Assert
|
47
|
+
var matchExact = (0, __tests__1.replSpace)(result);
|
48
|
+
matchExact(expectedValue);
|
49
|
+
});
|
50
|
+
it('tranform form to zeus, singleTypeNode, fieldsNodeWithArgsWithInput', function () {
|
51
|
+
// Arrange
|
52
|
+
var expectedValue = 'testInput:[{testInput:[objectObject]},true]';
|
53
|
+
// Act
|
54
|
+
var result = (0, index_1.formToZeus)({ nodes: __tests__1.singleNode, fields: __tests__1.fieldsNodeWithArgsWithInput });
|
55
|
+
// Assert
|
56
|
+
var matchExact = (0, __tests__1.replSpace)(result);
|
57
|
+
matchExact(expectedValue);
|
58
|
+
});
|
59
|
+
//# sourceMappingURL=formToZeus.spec.js.map
|
@@ -0,0 +1 @@
|
|
1
|
+
{"version":3,"file":"formToZeus.spec.js","sourceRoot":"","sources":["../../../src/FormToCode/zeus/formToZeus.spec.ts"],"names":[],"mappings":";;AAAA,iCAAqC;AACrC,4CAQyB;AAEzB,EAAE,CAAC,0CAA0C,EAAE;IAC3C,UAAU;IACV,IAAM,aAAa,GAAG,sBAAsB,CAAC;IAE7C,MAAM;IACN,IAAM,MAAM,GAAG,IAAA,kBAAU,EAAC,EAAE,KAAK,EAAE,qBAAU,EAAE,MAAM,mBAAA,EAAE,CAAC,CAAC;IAEzD,SAAS;IACT,IAAM,UAAU,GAAG,IAAA,oBAAS,EAAC,MAAM,CAAC,CAAC;IACrC,UAAU,CAAC,aAAa,CAAC,CAAC;AAC9B,CAAC,CAAC,CAAC;AAEH,EAAE,CAAC,4CAA4C,EAAE;IAC7C,UAAU;IACV,IAAM,aAAa,GAAG,sBAAsB,CAAC;IAE7C,MAAM;IACN,IAAM,MAAM,GAAG,IAAA,kBAAU,EAAC,EAAE,KAAK,EAAE,gBAAK,EAAE,MAAM,mBAAA,EAAE,CAAC,CAAC;IAEpD,SAAS;IACT,IAAM,UAAU,GAAG,IAAA,oBAAS,EAAC,MAAM,CA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E,KAAK,EAAE,qBAAU,EAAE,MAAM,EAAE,sCAA2B,EAAE,CAAC,CAAC;IAEtF,SAAS;IACT,IAAM,UAAU,GAAG,IAAA,oBAAS,EAAC,MAAM,CAAC,CAAC;IACrC,UAAU,CAAC,aAAa,CAAC,CAAC;AAC9B,CAAC,CAAC,CAAC"}
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/FormToCode/zeus/index.ts"],"names":[],"mappings":";;;AAAA,
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/FormToCode/zeus/index.ts"],"names":[],"mappings":";;;AAAA,yCAAiE;AAI1D,IAAM,UAAU,GAAG,UAAC,EAA+E;QAA7E,MAAM,YAAA,EAAE,KAAK,WAAA;IACtC,IAAM,SAAS,GAAG,IAAA,gCAAoB,EAAC,MAAM,CAAC,CAAC;IAC/C,IAAM,CAAC,GAAG,IAAA,wBAAY,EAAC,SAAS,EAAE,KAAK,CAAC,CAAC;IACzC,OAAO,CAAC,CAAC;AACb,CAAC,CAAC;AAJW,QAAA,UAAU,cAIrB"}
|
@@ -1,4 +1,4 @@
|
|
1
|
-
import { Reductor } from
|
1
|
+
import { Reductor } from '../models';
|
2
2
|
import { FormObject } from "../../models";
|
3
3
|
import { ParserField } from 'graphql-js-tree';
|
4
4
|
export declare const zeusFieldsToReductor: (toggledFields: Record<string, FormObject>) => Reductor;
|
@@ -5,7 +5,10 @@ var resolvers_1 = require("../gql/resolvers");
|
|
5
5
|
var zeusFieldsToReductor = function (toggledFields) {
|
6
6
|
var r = Object.entries(toggledFields).reduce(function (a, _a) {
|
7
7
|
var key = _a[0], value = _a[1];
|
8
|
-
var pathElements = key
|
8
|
+
var pathElements = key
|
9
|
+
.replace('... on', '___on')
|
10
|
+
.split('.')
|
11
|
+
.map(function (e) { return e.replace('___on', '... on'); });
|
9
12
|
var start = a;
|
10
13
|
pathElements.forEach(function (el, index) {
|
11
14
|
var _a;
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"resolvers.js","sourceRoot":"","sources":["../../../src/FormToCode/zeus/resolvers.tsx"],"names":[],"mappings":";;;AAAA,
|
1
|
+
{"version":3,"file":"resolvers.js","sourceRoot":"","sources":["../../../src/FormToCode/zeus/resolvers.tsx"],"names":[],"mappings":";;;AAAA,8CAAkD;AAK3C,IAAM,oBAAoB,GAAG,UAAC,aAAyC;IAC1E,IAAM,CAAC,GAAG,MAAM,CAAC,OAAO,CAAC,aAAa,CAAC,CAAC,MAAM,CAAC,UAAC,CAAC,EAAE,EAAY;YAAX,GAAG,QAAA,EAAE,KAAK,QAAA;QAC1D,IAAM,YAAY,GAAG,GAAG;aACnB,OAAO,CAAC,QAAQ,EAAE,OAAO,CAAC;aAC1B,KAAK,CAAC,GAAG,CAAC;aACV,GAAG,CAAC,UAAC,CAAC,IAAK,OAAA,CAAC,CAAC,OAAO,CAAC,OAAO,EAAE,QAAQ,CAAC,EAA5B,CAA4B,CAAC,CAAC;QAC9C,IAAI,KAAK,GAAG,CAAC,CAAC;QACd,YAAY,CAAC,OAAO,CAAC,UAAC,EAAE,EAAE,KAAK;;YAC3B,IAAI,KAAK,KAAK,CAAC,IAAI,CAAC,CAAC,CAAA,MAAA,KAAK,CAAC,IAAI,CAAC,IAAI,CAAC,UAAU,0CAAE,MAAM,CAAA,EAAE;gBACrD,EAAE,GAAG,KAAK,CAAC,IAAI,CAAC,IAAI,CAAC,UAAU,CAAC,CAAC,CAAC,CAAC;gBACnC,OAAO;aACV;YACD,KAAK,CAAC,EAAE,CAAC,GAAG,KAAK,CAAC,EAAE,CAAC,IAAI,EAAE,CAAC;YAC5B,KAAK,CAAC,EAAE,CAAC,CAAC,QAAQ,GAAG,KAAK,CAAC,EAAE,CAAC,CAAC,QAAQ,IAAI,EAAE,CAAC;YAC9C,IAAI,KAAK,KAAK,YAAY,CAAC,MAAM,GAAG,CAAC,EAAE;gBACnC,IAAI,KAAK,CAAC,KAAK,IAAI,MAAM,CAAC,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AU,CAAC;SAClF;QACD,IAAI,KAAK,KAAK,CAAC,EAAE;YACb,OAAO,qCACH,MAAA,MAAA,KAAK,CAAC,IAAI,CAAC,UAAC,CAAC,IAAK,OAAA,CAAC,CAAC,IAAI,KAAK,CAAC,EAAZ,CAAY,CAAC,0CAAE,IAAI,CAAC,UAAU,0CAAG,CAAC,CAAC,oBAChD,IAAA,oBAAY,EAAC,CAAC,CAAC,QAAQ,EAAE,KAAK,EAAE,IAAI,GAAG,IAAI,EAAE,GAAG,CAAC,OAAI,CAAC;SAClE;QACD,IAAM,OAAO,GACT,MAAM,CAAC,IAAI,CAAC,CAAC,CAAC,QAAQ,CAAC,CAAC,MAAM,GAAG,CAAC;YAC9B,CAAC,CAAC,UAAG,IAAI,SAAG,CAAC,iBAAO,IAAA,oBAAY,EAAC,CAAC,CAAC,QAAQ,EAAE,KAAK,EAAE,IAAI,GAAG,IAAI,EAAE,GAAG,CAAC,SAAG,IAAI,QAAK;YACjF,CAAC,CAAC,UAAG,IAAI,SAAG,CAAC,aAAU,CAAC;QAChC,OAAO,OAAO,CAAC;IACnB,CAAC,CAAC;SACD,IAAI,CAAC,EAAE,CAAC,CAAC;AAClB,CAAC,CAAC;AA1BW,QAAA,YAAY,gBA0BvB"}
|
@@ -0,0 +1,11 @@
|
|
1
|
+
import { FormObject } from "../models";
|
2
|
+
import { ParserField } from 'graphql-js-tree';
|
3
|
+
export declare const typeNode: ParserField;
|
4
|
+
export declare const inputNode: ParserField;
|
5
|
+
export declare const nodeWithArgs: ParserField;
|
6
|
+
export declare const singleNode: ParserField[];
|
7
|
+
export declare const nodes: ParserField[];
|
8
|
+
export declare const fields: Record<string, FormObject>;
|
9
|
+
export declare const extenedFields: Record<string, FormObject>;
|
10
|
+
export declare const fieldsNodeWithArgs: Record<string, FormObject>;
|
11
|
+
export declare const fieldsNodeWithArgsWithInput: Record<string, FormObject>;
|
@@ -0,0 +1,38 @@
|
|
1
|
+
"use strict";
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
3
|
+
exports.fieldsNodeWithArgsWithInput = exports.fieldsNodeWithArgs = exports.extenedFields = exports.fields = exports.nodes = exports.singleNode = exports.nodeWithArgs = exports.inputNode = exports.typeNode = void 0;
|
4
|
+
var graphql_js_tree_1 = require("graphql-js-tree");
|
5
|
+
// Global Arrange
|
6
|
+
exports.typeNode = {
|
7
|
+
name: 'Type',
|
8
|
+
args: [],
|
9
|
+
data: { type: graphql_js_tree_1.TypeDefinition.ObjectTypeDefinition },
|
10
|
+
directives: [],
|
11
|
+
interfaces: [],
|
12
|
+
type: { fieldType: { name: 'type', type: graphql_js_tree_1.Options.name } },
|
13
|
+
};
|
14
|
+
exports.inputNode = {
|
15
|
+
name: 'Input',
|
16
|
+
args: [],
|
17
|
+
data: { type: graphql_js_tree_1.TypeDefinition.InputObjectTypeDefinition },
|
18
|
+
directives: [],
|
19
|
+
interfaces: [],
|
20
|
+
type: { fieldType: { name: 'type', type: graphql_js_tree_1.Options.name } },
|
21
|
+
};
|
22
|
+
exports.nodeWithArgs = {
|
23
|
+
name: 'Root',
|
24
|
+
args: [exports.typeNode, exports.inputNode],
|
25
|
+
data: { type: graphql_js_tree_1.TypeDefinition.ObjectTypeDefinition },
|
26
|
+
directives: [],
|
27
|
+
interfaces: [],
|
28
|
+
type: { fieldType: { name: 'type', type: graphql_js_tree_1.Options.name } },
|
29
|
+
};
|
30
|
+
exports.singleNode = [exports.typeNode];
|
31
|
+
exports.nodes = [exports.typeNode, exports.inputNode, exports.nodeWithArgs];
|
32
|
+
exports.fields = { test: { node: exports.typeNode, value: 5 } };
|
33
|
+
exports.extenedFields = { testInput: { node: exports.inputNode, value: exports.fields } };
|
34
|
+
exports.fieldsNodeWithArgs = { testInput: { node: exports.nodeWithArgs, value: exports.fields } };
|
35
|
+
exports.fieldsNodeWithArgsWithInput = {
|
36
|
+
testInput: { node: exports.nodeWithArgs, value: exports.extenedFields },
|
37
|
+
};
|
38
|
+
//# sourceMappingURL=consts.js.map
|
@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AAI,EAAE,EAAE,IAAI,EAAE,gBAAQ,EAAE,KAAK,EAAE,CAAC,EAAE,EAAE,CAAC;AAC5E,QAAA,aAAa,GAA+B,EAAE,SAAS,EAAE,EAAE,IAAI,EAAE,iBAAS,EAAE,KAAK,EAAE,cAAM,EAAE,EAAE,CAAC;AAC9F,QAAA,kBAAkB,GAA+B,EAAE,SAAS,EAAE,EAAE,IAAI,EAAE,oBAAY,EAAE,KAAK,EAAE,cAAM,EAAE,EAAE,CAAC;AACtG,QAAA,2BAA2B,GAA+B;IACnE,SAAS,EAAE,EAAE,IAAI,EAAE,oBAAY,EAAE,KAAK,EAAE,qBAAa,EAAE;CAC1D,CAAC"}
|
@@ -0,0 +1,19 @@
|
|
1
|
+
"use strict";
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
3
|
+
if (k2 === undefined) k2 = k;
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
7
|
+
}
|
8
|
+
Object.defineProperty(o, k2, desc);
|
9
|
+
}) : (function(o, m, k, k2) {
|
10
|
+
if (k2 === undefined) k2 = k;
|
11
|
+
o[k2] = m[k];
|
12
|
+
}));
|
13
|
+
var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
14
|
+
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
15
|
+
};
|
16
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
17
|
+
__exportStar(require("./consts"), exports);
|
18
|
+
__exportStar(require("./testUtils"), exports);
|
19
|
+
//# sourceMappingURL=index.js.map
|
@@ -0,0 +1 @@
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/__tests__/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAAA,2CAAyB;AACzB,8CAA4B"}
|
@@ -0,0 +1 @@
|
|
1
|
+
export declare const replSpace: (baseString: string) => (s: string) => void;
|
@@ -0,0 +1,8 @@
|
|
1
|
+
"use strict";
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
3
|
+
exports.replSpace = void 0;
|
4
|
+
var replSpace = function (baseString) { return function (s) {
|
5
|
+
return expect(baseString.replace(/\s+/g, '')).toContain(s.replace(/\s+/g, ''));
|
6
|
+
}; };
|
7
|
+
exports.replSpace = replSpace;
|
8
|
+
//# sourceMappingURL=testUtils.js.map
|
@@ -0,0 +1 @@
|
|
1
|
+
{"version":3,"file":"testUtils.js","sourceRoot":"","sources":["../../src/__tests__/testUtils.ts"],"names":[],"mappings":";;;AAAO,IAAM,SAAS,GAAG,UAAC,UAAkB,IAAK,OAAA,UAAC,CAAS;IACvD,OAAA,MAAM,CAAC,UAAU,CAAC,OAAO,CAAC,MAAM,EAAE,EAAE,CAAC,CAAC,CAAC,SAAS,CAAC,CAAC,CAAC,OAAO,CAAC,MAAM,EAAE,EAAE,CAAC,CAAC;AAAvE,CAAuE,EAD1B,CAC0B,CAAC;AAD/D,QAAA,SAAS,aACsD"}
|
package/package.json
CHANGED
@@ -1,13 +1,13 @@
|
|
1
1
|
{
|
2
2
|
"name": "graphql-form",
|
3
|
-
"version": "0.0.
|
3
|
+
"version": "0.0.25",
|
4
4
|
"description": "Easy form creation with GraphQL Editor and React",
|
5
5
|
"main": "lib/index.js",
|
6
6
|
"scripts": {
|
7
7
|
"test": "jest",
|
8
8
|
"test:watch": "jest --watch",
|
9
|
-
"build": "
|
10
|
-
"start": "
|
9
|
+
"build": "ttsc -p tsconfig.build.json",
|
10
|
+
"start": "ttsc -p tsconfig.build.json --watch",
|
11
11
|
"lint": "eslint '*/**/*.{js,ts,tsx}' --quiet --fix"
|
12
12
|
},
|
13
13
|
"types": "lib/index.d.ts",
|
@@ -0,0 +1,75 @@
|
|
1
|
+
import { formToGql } from './index';
|
2
|
+
import {
|
3
|
+
extenedFields,
|
4
|
+
fields,
|
5
|
+
nodes,
|
6
|
+
replSpace,
|
7
|
+
singleNode,
|
8
|
+
fieldsNodeWithArgs,
|
9
|
+
fieldsNodeWithArgsWithInput,
|
10
|
+
nodeWithArgs,
|
11
|
+
} from '../../__tests__';
|
12
|
+
|
13
|
+
it('tranform form to Gql, typeNode, No args', () => {
|
14
|
+
// Arrange
|
15
|
+
const expectedValue = 'test';
|
16
|
+
// Act
|
17
|
+
const result = formToGql({ nodes: singleNode, fields });
|
18
|
+
// Assert
|
19
|
+
const matchExact = replSpace(result);
|
20
|
+
matchExact(expectedValue);
|
21
|
+
});
|
22
|
+
|
23
|
+
it('tranform form to Gql, typeNode, With args', () => {
|
24
|
+
// Arrange
|
25
|
+
const expectedValue = `testInput(
|
26
|
+
test: 5
|
27
|
+
)`;
|
28
|
+
|
29
|
+
// Act
|
30
|
+
const result = formToGql({ nodes, fields: extenedFields });
|
31
|
+
|
32
|
+
// Assert
|
33
|
+
const matchExact = replSpace(result);
|
34
|
+
matchExact(expectedValue);
|
35
|
+
});
|
36
|
+
|
37
|
+
it('tranform form to Gql, typeNode, fieldsNodeWithArgs', () => {
|
38
|
+
// Arrange
|
39
|
+
const expectedValue = `testInput(
|
40
|
+
test: 5
|
41
|
+
)`;
|
42
|
+
|
43
|
+
// Act
|
44
|
+
const result = formToGql({ nodes, fields: fieldsNodeWithArgs });
|
45
|
+
|
46
|
+
// Assert
|
47
|
+
const matchExact = replSpace(result);
|
48
|
+
matchExact(expectedValue);
|
49
|
+
});
|
50
|
+
|
51
|
+
it('tranform form to Gql, typeNode, fieldsNodeWithArgsWithInput', () => {
|
52
|
+
// Arrange
|
53
|
+
const expectedValue = 'testInput(testInput:[objectObject])';
|
54
|
+
|
55
|
+
// Act
|
56
|
+
const result = formToGql({ nodes, fields: fieldsNodeWithArgsWithInput });
|
57
|
+
|
58
|
+
// Assert
|
59
|
+
const matchExact = replSpace(result);
|
60
|
+
matchExact(expectedValue);
|
61
|
+
});
|
62
|
+
|
63
|
+
it('tranform form to Gql, nodeWithArgs, fieldsNodeWithArgsWithInput', () => {
|
64
|
+
// Arrange
|
65
|
+
const expectedValue = 'testInput(testInput:[objectObject])';
|
66
|
+
|
67
|
+
// Act
|
68
|
+
const result = formToGql({ nodes: [nodeWithArgs], fields: fieldsNodeWithArgsWithInput });
|
69
|
+
|
70
|
+
// Assert
|
71
|
+
const matchExact = replSpace(result);
|
72
|
+
matchExact(expectedValue);
|
73
|
+
});
|
74
|
+
|
75
|
+
export {};
|
@@ -1,11 +1,14 @@
|
|
1
|
-
import { resolveQlValue } from '
|
1
|
+
import { resolveQlValue } from './resolvers';
|
2
2
|
import { Reductor, ReductorValue } from '@/FormToCode/models';
|
3
3
|
import { FormObject } from '@/models';
|
4
4
|
import { ParserField } from 'graphql-js-tree';
|
5
5
|
|
6
6
|
export const fieldsToReductor = (toggledFields: Record<string, FormObject>): Reductor =>
|
7
7
|
Object.entries(toggledFields).reduce((a, [key, value]) => {
|
8
|
-
const pathElements = key
|
8
|
+
const pathElements = key
|
9
|
+
.replace('... on', '___on')
|
10
|
+
.split('.')
|
11
|
+
.map((e) => e.replace('___on', '... on'));
|
9
12
|
let start = a;
|
10
13
|
pathElements.forEach((el, index) => {
|
11
14
|
if (index === 0 && !!value.node.type.operations?.length) {
|
@@ -0,0 +1,84 @@
|
|
1
|
+
import { formToZeus } from './index';
|
2
|
+
import {
|
3
|
+
extenedFields,
|
4
|
+
nodes,
|
5
|
+
replSpace,
|
6
|
+
singleNode,
|
7
|
+
fields,
|
8
|
+
fieldsNodeWithArgs,
|
9
|
+
fieldsNodeWithArgsWithInput,
|
10
|
+
} from '../../__tests__';
|
11
|
+
|
12
|
+
it('tranform form to zeus, typeNode, No args', () => {
|
13
|
+
// Arrange
|
14
|
+
const expectedValue = 'api("undefined")({})';
|
15
|
+
|
16
|
+
// Act
|
17
|
+
const result = formToZeus({ nodes: singleNode, fields });
|
18
|
+
|
19
|
+
// Assert
|
20
|
+
const matchExact = replSpace(result);
|
21
|
+
matchExact(expectedValue);
|
22
|
+
});
|
23
|
+
|
24
|
+
it('tranform form to zeus, typeNode, With args', () => {
|
25
|
+
// Arrange
|
26
|
+
const expectedValue = 'api("undefined")({})';
|
27
|
+
|
28
|
+
// Act
|
29
|
+
const result = formToZeus({ nodes: nodes, fields });
|
30
|
+
|
31
|
+
// Assert
|
32
|
+
const matchExact = replSpace(result);
|
33
|
+
matchExact(expectedValue);
|
34
|
+
});
|
35
|
+
|
36
|
+
it('tranform form to zeus, inputNode, With args', () => {
|
37
|
+
// Arrange
|
38
|
+
const expectedValue = 'testInput:[{test:5},true]';
|
39
|
+
|
40
|
+
// Act
|
41
|
+
const result = formToZeus({ nodes: nodes, fields: extenedFields });
|
42
|
+
|
43
|
+
// Assert
|
44
|
+
const matchExact = replSpace(result);
|
45
|
+
matchExact(expectedValue);
|
46
|
+
});
|
47
|
+
|
48
|
+
it('tranform form to zeus, singleTypeNode, No args', () => {
|
49
|
+
// Arrange
|
50
|
+
const expectedValue = 'testInput:[{test:5},true]';
|
51
|
+
|
52
|
+
// Act
|
53
|
+
const result = formToZeus({ nodes: singleNode, fields: extenedFields });
|
54
|
+
|
55
|
+
// Assert
|
56
|
+
const matchExact = replSpace(result);
|
57
|
+
matchExact(expectedValue);
|
58
|
+
});
|
59
|
+
|
60
|
+
it('tranform form to zeus, singleTypeNode, fieldsNodeWithArgs', () => {
|
61
|
+
// Arrange
|
62
|
+
const expectedValue = 'testInput:[{test:5},true]';
|
63
|
+
|
64
|
+
// Act
|
65
|
+
const result = formToZeus({ nodes: singleNode, fields: fieldsNodeWithArgs });
|
66
|
+
|
67
|
+
// Assert
|
68
|
+
const matchExact = replSpace(result);
|
69
|
+
matchExact(expectedValue);
|
70
|
+
});
|
71
|
+
|
72
|
+
it('tranform form to zeus, singleTypeNode, fieldsNodeWithArgsWithInput', () => {
|
73
|
+
// Arrange
|
74
|
+
const expectedValue = 'testInput:[{testInput:[objectObject]},true]';
|
75
|
+
|
76
|
+
// Act
|
77
|
+
const result = formToZeus({ nodes: singleNode, fields: fieldsNodeWithArgsWithInput });
|
78
|
+
|
79
|
+
// Assert
|
80
|
+
const matchExact = replSpace(result);
|
81
|
+
matchExact(expectedValue);
|
82
|
+
});
|
83
|
+
|
84
|
+
export {};
|
@@ -1,11 +1,14 @@
|
|
1
|
-
import { resolveQlValue } from '
|
2
|
-
import { Reductor } from '
|
1
|
+
import { resolveQlValue } from '../gql/resolvers';
|
2
|
+
import { Reductor } from '../models';
|
3
3
|
import { FormObject } from '@/models';
|
4
4
|
import { ParserField } from 'graphql-js-tree';
|
5
5
|
|
6
6
|
export const zeusFieldsToReductor = (toggledFields: Record<string, FormObject>): Reductor => {
|
7
7
|
const r = Object.entries(toggledFields).reduce((a, [key, value]) => {
|
8
|
-
const pathElements = key
|
8
|
+
const pathElements = key
|
9
|
+
.replace('... on', '___on')
|
10
|
+
.split('.')
|
11
|
+
.map((e) => e.replace('___on', '... on'));
|
9
12
|
let start = a;
|
10
13
|
pathElements.forEach((el, index) => {
|
11
14
|
if (index === 0 && !!value.node.type.operations?.length) {
|
@@ -0,0 +1,40 @@
|
|
1
|
+
import { FormObject } from '@/models';
|
2
|
+
import { Options, ParserField, TypeDefinition } from 'graphql-js-tree';
|
3
|
+
|
4
|
+
// Global Arrange
|
5
|
+
export const typeNode: ParserField = {
|
6
|
+
name: 'Type',
|
7
|
+
args: [],
|
8
|
+
data: { type: TypeDefinition.ObjectTypeDefinition },
|
9
|
+
directives: [],
|
10
|
+
interfaces: [],
|
11
|
+
type: { fieldType: { name: 'type', type: Options.name } },
|
12
|
+
};
|
13
|
+
|
14
|
+
export const inputNode: ParserField = {
|
15
|
+
name: 'Input',
|
16
|
+
args: [],
|
17
|
+
data: { type: TypeDefinition.InputObjectTypeDefinition },
|
18
|
+
directives: [],
|
19
|
+
interfaces: [],
|
20
|
+
type: { fieldType: { name: 'type', type: Options.name } },
|
21
|
+
};
|
22
|
+
|
23
|
+
export const nodeWithArgs: ParserField = {
|
24
|
+
name: 'Root',
|
25
|
+
args: [typeNode, inputNode],
|
26
|
+
data: { type: TypeDefinition.ObjectTypeDefinition },
|
27
|
+
directives: [],
|
28
|
+
interfaces: [],
|
29
|
+
type: { fieldType: { name: 'type', type: Options.name } },
|
30
|
+
};
|
31
|
+
|
32
|
+
export const singleNode: ParserField[] = [typeNode];
|
33
|
+
export const nodes: ParserField[] = [typeNode, inputNode, nodeWithArgs];
|
34
|
+
|
35
|
+
export const fields: Record<string, FormObject> = { test: { node: typeNode, value: 5 } };
|
36
|
+
export const extenedFields: Record<string, FormObject> = { testInput: { node: inputNode, value: fields } };
|
37
|
+
export const fieldsNodeWithArgs: Record<string, FormObject> = { testInput: { node: nodeWithArgs, value: fields } };
|
38
|
+
export const fieldsNodeWithArgsWithInput: Record<string, FormObject> = {
|
39
|
+
testInput: { node: nodeWithArgs, value: extenedFields },
|
40
|
+
};
|
package/tsconfig.build.json
CHANGED