graphql-form 0.0.24 → 0.0.26
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/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/lib/outsideUse.js +9 -11
- package/lib/outsideUse.js.map +1 -1
- 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/src/outsideUse.tsx +11 -12
- 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;AAE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S;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/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,CAA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0,0 +1 @@
|
|
1
|
+
export {};
|
@@ -0,0 +1,59 @@
|
|
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 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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AAC,oEAAoE,EAAE;IACrE,UAAU;IACV,IAAM,aAAa,GAAG,6CAA6C,CAAC;IAEpE,MAAM;IACN,IAAM,MAAM,GAAG,IAAA,kBAAU,EAAC,EAAE,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,I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B,CAAC,CAAC,UAAG,IAAI,SAAG,CAAC,gBAAM,IAAA,0BAAc,EAAC,CAAC,CAAC,KAAK,EAAE,KAAK,EAAE,IAAI,CAAC,eAAK,IAAI,aAAU,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
|
@@ -0,0 +1 @@
|
|
1
|
+
{"version":3,"file":"consts.js","sourceRoot":"","sources":["../../src/__tests__/consts.ts"],"names":[],"mappings":";;;AACA,mDAAuE;AAEvE,iBAAiB;AACJ,QAAA,QAAQ,GAAgB;IACjC,IAAI,EAAE,MAAM;IACZ,IAAI,EAAE,EAAE;IACR,IAAI,EAAE,EAAE,IAAI,EAAE,gCAAc,CAAC,oBAAoB,EAAE;IACnD,UAAU,EAAE,EAAE;IACd,UAAU,EAAE,EAAE;IACd,IAAI,EAAE,EAAE,SAAS,EAAE,EAAE,IAAI,EAAE,MAAM,EAAE,IAAI,EAAE,yBAAO,CAAC,IAAI,EAAE,EAAE;CAC5D,CAAC;AAEW,QAAA,SAAS,GAAgB;IAClC,IAAI,EAAE,OAAO;IACb,IAAI,EAAE,EAAE;IACR,IAAI,EAAE,EAAE,IAAI,EAAE,gCAAc,CAAC,yBAAyB,EAAE;IACxD,UAAU,EAAE,EAAE;IACd,UAAU,EAAE,EAAE;IACd,IAAI,EAAE,EAAE,SAAS,EAAE,EAAE,IAAI,EAAE,MAAM,EAAE,IAAI,EAAE,yBAAO,CAAC,IAAI,EAAE,EAAE;CAC5D,CAAC;AAEW,QAAA,YAAY,GAAgB;IACrC,IAAI,EAAE,MAAM;IACZ,IAAI,EAAE,CAAC,gBAAQ,EAAE,iBAAS,CAAC;IAC3B,IAAI,EAAE,EAAE,IAAI,EAAE,gCAAc,CAAC,oBAAoB,EAAE;IACnD,UAAU,EAAE,EAAE;IACd,UAAU,EAAE,EAAE;IACd,IAAI,EAAE,EAAE,SAAS,EAAE,EAAE,IAAI,EAAE,MAAM,EAAE,IAAI,EAAE,yBAAO,CAAC,IAAI,EAAE,EAAE;CAC5D,CAAC;AAEW,QAAA,UAAU,GAAkB,CAAC,gBAAQ,CAAC,CAAC;AACvC,QAAA,KAAK,GAAkB,CAAC,gBAAQ,EAAE,iBAAS,EAAE,oBAAY,CAAC,CAAC;AAE3D,QAAA,MAAM,GAA+B,EAAE,IAAI,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/lib/outsideUse.js
CHANGED
@@ -61,20 +61,18 @@ var validateValue = function (f, nodes, path, pushErrors) {
|
|
61
61
|
'type' in f.node.data &&
|
62
62
|
'directives' in f.node) {
|
63
63
|
var _a = f, node = _a.node, value = _a.value;
|
64
|
+
console.log("Validating ".concat(node.name), node);
|
64
65
|
if (node.data.type === graphql_js_tree_1.ValueDefinition.InputValueDefinition) {
|
65
|
-
if (node.type.fieldType.type === graphql_js_tree_1.Options.required
|
66
|
-
|
66
|
+
if (node.type.fieldType.type === graphql_js_tree_1.Options.required &&
|
67
|
+
(0, graphql_js_tree_1.getTypeName)(node.type.fieldType) !== graphql_js_tree_1.ScalarTypes.Boolean) {
|
68
|
+
if (typeof value === 'undefined' || value === '') {
|
67
69
|
pushErrors(path, models_1.Errs.REQUIRED);
|
68
70
|
}
|
69
|
-
if (
|
70
|
-
|
71
|
-
|
72
|
-
|
73
|
-
|
74
|
-
if (!v) {
|
75
|
-
pushErrors(path, models_1.Errs.VALUE_IN_ARRAY_REQUIRED);
|
76
|
-
}
|
77
|
-
}
|
71
|
+
if (Array.isArray(value)) {
|
72
|
+
for (var _i = 0, value_1 = value; _i < value_1.length; _i++) {
|
73
|
+
var v = value_1[_i];
|
74
|
+
console.log(v);
|
75
|
+
(0, exports.validateValue)(v, nodes, path, pushErrors);
|
78
76
|
}
|
79
77
|
}
|
80
78
|
}
|
package/lib/outsideUse.js.map
CHANGED
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"outsideUse.js","sourceRoot":"","sources":["../src/outsideUse.tsx"],"names":[],"mappings":";;;;;;;;;;;;;;AAAA,mCAAkF;AAClF,
|
1
|
+
{"version":3,"file":"outsideUse.js","sourceRoot":"","sources":["../src/outsideUse.tsx"],"names":[],"mappings":";;;;;;;;;;;;;;AAAA,mCAAkF;AAClF,mDAQyB;AAElB,IAAM,kBAAkB,GAAG,UAAC,KAAsB;;IACrD,IAAM,CAAC,GAAG,MAAA,KAAK,CAAC,OAAO,0CAAG,KAAK,CAAC,WAAW,CAAC,CAAC;IAC7C,IAAM,gBAAgB,GAAG,KAAK,CAAC,gBAAgB,CAAC,IAAI,CAAC,UAAC,EAAE,IAAK,OAAA,EAAE,CAAC,IAAI,MAAK,CAAC,aAAD,CAAC,uBAAD,CAAC,CAAE,MAAM,CAAA,EAArB,CAAqB,CAAC,CAAC;IACpF,IAAI,CAAC,gBAAgB,EAAE;QACnB,IAAM,eAAa,GAAG,MAAA,KAAK,CAAC,cAAc,0CAAE,IAAI,CAAC,UAAC,EAAE,IAAK,OAAA,EAAE,CAAC,IAAI,MAAK,CAAC,aAAD,CAAC,uBAAD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AA,EAAE,GAAG,QAAA;QAAM,OAAA,uBACV,CAAC,gBACH,CAAC,IAAG,GAAG,OACV;IAHe,CAGf,EACF,EAAuB,CAC1B,CAAC;IACN,6BACO,CAAC,KACJ,KAAK,OAAA,IACP;AACN,CAAC,CAAC;AAjBW,QAAA,SAAS,aAiBpB"}
|
package/package.json
CHANGED
@@ -1,13 +1,13 @@
|
|
1
1
|
{
|
2
2
|
"name": "graphql-form",
|
3
|
-
"version": "0.0.
|
3
|
+
"version": "0.0.26",
|
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/src/outsideUse.tsx
CHANGED
@@ -3,6 +3,7 @@ import {
|
|
3
3
|
getTypeName,
|
4
4
|
Options,
|
5
5
|
ParserField,
|
6
|
+
ScalarTypes,
|
6
7
|
TypeDefinition,
|
7
8
|
TypeSystemDefinition,
|
8
9
|
ValueDefinition,
|
@@ -64,21 +65,19 @@ export const validateValue = (
|
|
64
65
|
'directives' in f.node
|
65
66
|
) {
|
66
67
|
const { node, value } = f as FormObject;
|
68
|
+
console.log(`Validating ${node.name}`, node);
|
67
69
|
if (node.data.type === ValueDefinition.InputValueDefinition) {
|
68
|
-
if (
|
69
|
-
|
70
|
+
if (
|
71
|
+
node.type.fieldType.type === Options.required &&
|
72
|
+
getTypeName(node.type.fieldType) !== ScalarTypes.Boolean
|
73
|
+
) {
|
74
|
+
if (typeof value === 'undefined' || value === '') {
|
70
75
|
pushErrors(path, Errs.REQUIRED);
|
71
76
|
}
|
72
|
-
if (
|
73
|
-
|
74
|
-
|
75
|
-
|
76
|
-
if (Array.isArray(value)) {
|
77
|
-
for (const v of value) {
|
78
|
-
if (!v) {
|
79
|
-
pushErrors(path, Errs.VALUE_IN_ARRAY_REQUIRED);
|
80
|
-
}
|
81
|
-
}
|
77
|
+
if (Array.isArray(value)) {
|
78
|
+
for (const v of value) {
|
79
|
+
console.log(v);
|
80
|
+
validateValue(v, nodes, path, pushErrors);
|
82
81
|
}
|
83
82
|
}
|
84
83
|
}
|
package/tsconfig.build.json
CHANGED