@ldsg/forms 0.3.9 → 0.3.11
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/README.md +51 -1
- package/dist/constants.d.ts +3 -3
- package/dist/constants.d.ts.map +1 -1
- package/dist/constants.js +11 -10
- package/dist/handler.d.ts +5 -7
- package/dist/handler.d.ts.map +1 -1
- package/dist/index.d.ts +5 -5
- package/dist/instantiate-resource.d.ts +4 -4
- package/dist/instantiate-resource.js +1 -1
- package/dist/resource.d.ts +4 -4
- package/dist/resource.d.ts.map +1 -1
- package/dist/resource.js +4 -8
- package/dist/test/__tests__/unit.js +199 -131
- package/dist/types/get-form-info.d.ts +3 -3
- package/dist/types/index.d.ts +3 -2
- package/dist/types/index.d.ts.map +1 -1
- package/dist/types/index.js +1 -0
- package/dist/types/query-types.d.ts +50 -0
- package/dist/types/query-types.d.ts.map +1 -0
- package/dist/types/query-types.js +2 -0
- package/dist/types/specific-resource-settings.d.ts +1 -1
- package/dist/types/specific-resource-settings.d.ts.map +1 -1
- package/dist/utils/add-query-fields/index.d.ts +10 -0
- package/dist/utils/add-query-fields/index.d.ts.map +1 -0
- package/dist/utils/add-query-fields/index.js +26 -0
- package/dist/utils/add-query-fields/utils/create-resolvers.d.ts +21 -0
- package/dist/utils/add-query-fields/utils/create-resolvers.d.ts.map +1 -0
- package/dist/utils/add-query-fields/utils/create-resolvers.js +37 -0
- package/dist/utils/add-query-fields/utils/create-types.d.ts +10 -0
- package/dist/utils/add-query-fields/utils/create-types.d.ts.map +1 -0
- package/dist/utils/add-query-fields/utils/create-types.js +100 -0
- package/dist/utils/add-query-fields/utils/get-json-schema.d.ts +11 -0
- package/dist/utils/add-query-fields/utils/get-json-schema.d.ts.map +1 -0
- package/dist/utils/add-query-fields/utils/get-json-schema.js +90 -0
- package/dist/utils/add-query-fields/utils/get-schema-for-formily/constants.d.ts +3 -0
- package/dist/utils/add-query-fields/utils/get-schema-for-formily/constants.d.ts.map +1 -0
- package/dist/utils/add-query-fields/utils/get-schema-for-formily/constants.js +29 -0
- package/dist/utils/add-query-fields/utils/get-schema-for-formily/index.d.ts +11 -0
- package/dist/utils/add-query-fields/utils/get-schema-for-formily/index.d.ts.map +1 -0
- package/dist/utils/add-query-fields/utils/get-schema-for-formily/index.js +15 -0
- package/dist/utils/add-query-fields/utils/get-schema-for-formily/utils/process-object-schema.d.ts +8 -0
- package/dist/utils/add-query-fields/utils/get-schema-for-formily/utils/process-object-schema.d.ts.map +1 -0
- package/dist/utils/add-query-fields/utils/get-schema-for-formily/utils/process-object-schema.js +44 -0
- package/dist/utils/add-query-fields/utils/map-form-info.d.ts +11 -0
- package/dist/utils/add-query-fields/utils/map-form-info.d.ts.map +1 -0
- package/dist/utils/add-query-fields/utils/map-form-info.js +42 -0
- package/dist/utils/get-new-fields/index.d.ts +3 -3
- package/dist/utils/get-new-fields/index.d.ts.map +1 -1
- package/dist/utils/get-new-fields/index.js +3 -3
- package/dist/utils/get-new-fields/utils/get-field-config-map-definition.d.ts +1 -1
- package/dist/utils/get-new-fields/utils/get-field-config-map-definition.d.ts.map +1 -1
- package/dist/utils/get-new-fields/utils/get-field-config-map-definition.js +3 -3
- package/dist/utils/get-new-fields/utils/get-graphql-type-by-common-type.d.ts.map +1 -1
- package/dist/utils/get-new-fields/utils/get-graphql-type-by-common-type.js +3 -3
- package/dist/utils/get-new-fields/utils/get-graphql-type-by-type-info.d.ts +1 -1
- package/dist/utils/get-new-fields/utils/get-graphql-type-by-type-info.d.ts.map +1 -1
- package/dist/utils/get-new-fields/utils/get-graphql-type-by-type-info.js +2 -2
- package/dist/utils/get-new-fields/utils/get-input-itc.d.ts +3 -3
- package/dist/utils/get-new-fields/utils/get-input-itc.d.ts.map +1 -1
- package/dist/utils/get-new-fields/utils/get-input-itc.js +4 -4
- package/dist/utils/get-new-fields/utils/get-output-otc.d.ts +3 -3
- package/dist/utils/get-new-fields/utils/get-output-otc.d.ts.map +1 -1
- package/dist/utils/get-new-fields/utils/get-output-otc.js +10 -4
- package/dist/utils/get-new-fields/utils/index.d.ts +2 -2
- package/dist/utils/index.d.ts +2 -1
- package/dist/utils/index.d.ts.map +1 -1
- package/dist/utils/index.js +1 -0
- package/package.json +27 -19
package/README.md
CHANGED
|
@@ -1,5 +1,55 @@
|
|
|
1
1
|
# LDSG Forms Resource
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
The FormsResource provides GraphQL query fields for discovering and retrieving form definitions.
|
|
4
|
+
|
|
5
|
+
## Features
|
|
6
|
+
|
|
7
|
+
- **`form(name: "...")`** - Query a single form by name
|
|
8
|
+
- Returns form metadata (name, title, description) with input and output objects
|
|
9
|
+
- Example: `form(name: "ContactForm") { name, title, description, inputObject, outputObject }`
|
|
10
|
+
|
|
11
|
+
- **`forms`** - Query all forms
|
|
12
|
+
- Returns a list of all forms with metadata (name, title, description)
|
|
13
|
+
- Example: `forms { name, title, description }`
|
|
14
|
+
|
|
15
|
+
## Usage
|
|
16
|
+
|
|
17
|
+
```graphql
|
|
18
|
+
# Query a single form by name
|
|
19
|
+
query {
|
|
20
|
+
form(name: "ContactForm") {
|
|
21
|
+
name
|
|
22
|
+
title
|
|
23
|
+
description
|
|
24
|
+
inputObject {
|
|
25
|
+
name
|
|
26
|
+
title
|
|
27
|
+
description
|
|
28
|
+
fieldInfoList
|
|
29
|
+
jsonSchema
|
|
30
|
+
formilyJsonSchema
|
|
31
|
+
}
|
|
32
|
+
outputObject {
|
|
33
|
+
name
|
|
34
|
+
title
|
|
35
|
+
description
|
|
36
|
+
fieldInfoList
|
|
37
|
+
jsonSchema
|
|
38
|
+
formilyJsonSchema
|
|
39
|
+
}
|
|
40
|
+
}
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
# Query all forms
|
|
44
|
+
query {
|
|
45
|
+
forms {
|
|
46
|
+
name
|
|
47
|
+
title
|
|
48
|
+
description
|
|
49
|
+
}
|
|
50
|
+
}
|
|
51
|
+
```
|
|
52
|
+
|
|
53
|
+
## TODO
|
|
4
54
|
|
|
5
55
|
- [ ] add e2e, request to express app
|
package/dist/constants.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { HandlerSpecificResourceSettings } from
|
|
2
|
-
import { ResourceDefinitionSpecificResourceSettings } from
|
|
3
|
-
import { GeneralResourceSettings } from
|
|
1
|
+
import { HandlerSpecificResourceSettings } from '@ldsg/handler';
|
|
2
|
+
import { ResourceDefinitionSpecificResourceSettings } from '@ldsg/resource-definition';
|
|
3
|
+
import { GeneralResourceSettings } from '@ldsg/types';
|
|
4
4
|
/**
|
|
5
5
|
* Instantiate Resource Handler General Resource Settings
|
|
6
6
|
* 实例化资源处理程序普通资源配置
|
package/dist/constants.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"constants.d.ts","sourceRoot":"","sources":["../src/constants.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"constants.d.ts","sourceRoot":"","sources":["../src/constants.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,+BAA+B,EAAE,MAAM,eAAe,CAAC;AAChE,OAAO,EAAE,0CAA0C,EAAE,MAAM,2BAA2B,CAAC;AACvF,OAAO,EAAE,uBAAuB,EAAE,MAAM,aAAa,CAAC;AAEtD;;;GAGG;AACH,eAAO,MAAM,sDAAsD,EAAE,uBAGpE,CAAC;AAEF;;;;GAIG;AACH,eAAO,MAAM,uDAAuD,EAAE,+BAOrE,CAAC;AAEF,eAAO,MAAM,6CAA6C,EAAE,uBAG3D,CAAC;AAEF,eAAO,MAAM,8CAA8C,EAAE,0CAE5D,CAAC;AAEF,eAAO,MAAM,WAAW,WAAW,CAAC"}
|
package/dist/constants.js
CHANGED
|
@@ -1,14 +1,13 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.FORMS_ROUTE = exports.RESOURCE_DEFINITION_SPECIFIC_RESOURCE_SETTINGS = exports.RESOURCE_DEFINITION_GENERAL_RESOURCE_SETTINGS = exports.INSTANTIATE_RESOURCE_HANDLER_SPECIFIC_RESOURCE_SETTINGS = exports.INSTANTIATE_RESOURCE_HANDLER_GENERAL_RESOURCE_SETTINGS = void 0;
|
|
4
|
-
const application_1 = require("@ldsg/application");
|
|
5
4
|
/**
|
|
6
5
|
* Instantiate Resource Handler General Resource Settings
|
|
7
6
|
* 实例化资源处理程序普通资源配置
|
|
8
7
|
*/
|
|
9
8
|
exports.INSTANTIATE_RESOURCE_HANDLER_GENERAL_RESOURCE_SETTINGS = {
|
|
10
|
-
title:
|
|
11
|
-
description:
|
|
9
|
+
title: '表单组实例化资源处理程序',
|
|
10
|
+
description: ''
|
|
12
11
|
};
|
|
13
12
|
/**
|
|
14
13
|
* Instantiate Resource Handler Specific Resource Settings
|
|
@@ -19,13 +18,15 @@ exports.INSTANTIATE_RESOURCE_HANDLER_SPECIFIC_RESOURCE_SETTINGS = {
|
|
|
19
18
|
code: `export * from "@ldsg/forms";`,
|
|
20
19
|
dependencies: [
|
|
21
20
|
{
|
|
22
|
-
name:
|
|
23
|
-
}
|
|
24
|
-
]
|
|
21
|
+
name: '@ldsg/forms'
|
|
22
|
+
}
|
|
23
|
+
]
|
|
24
|
+
};
|
|
25
|
+
exports.RESOURCE_DEFINITION_GENERAL_RESOURCE_SETTINGS = {
|
|
26
|
+
title: '表单组资源定义',
|
|
27
|
+
description: ''
|
|
25
28
|
};
|
|
26
|
-
exports.RESOURCE_DEFINITION_GENERAL_RESOURCE_SETTINGS = { title: "表单组资源定义", description: "" };
|
|
27
29
|
exports.RESOURCE_DEFINITION_SPECIFIC_RESOURCE_SETTINGS = {
|
|
28
|
-
kind:
|
|
29
|
-
parentKind: application_1.RESOURCE_DEFINITION_SPECIFIC_RESOURCE_SETTINGS.kind,
|
|
30
|
+
kind: 'forms'
|
|
30
31
|
};
|
|
31
|
-
exports.FORMS_ROUTE =
|
|
32
|
+
exports.FORMS_ROUTE = '/forms';
|
package/dist/handler.d.ts
CHANGED
|
@@ -1,8 +1,6 @@
|
|
|
1
|
-
import { Handler, HandlerExtendedResourceSettings } from
|
|
2
|
-
import { InstantiateResourceParams, InstantiateResourceRes } from
|
|
3
|
-
import { FormsResource } from
|
|
4
|
-
import { FormsSpecificResourceSettings } from
|
|
5
|
-
export declare const handler: Handler<
|
|
6
|
-
InstantiateResourceParams<HandlerExtendedResourceSettings<FormsSpecificResourceSettings>>
|
|
7
|
-
], InstantiateResourceRes<FormsResource>>;
|
|
1
|
+
import { Handler, HandlerExtendedResourceSettings } from '@ldsg/handler';
|
|
2
|
+
import { InstantiateResourceParams, InstantiateResourceRes } from '@ldsg/resource';
|
|
3
|
+
import { FormsResource } from './resource';
|
|
4
|
+
import { FormsSpecificResourceSettings } from './types';
|
|
5
|
+
export declare const handler: Handler<InstantiateResourceParams<HandlerExtendedResourceSettings<FormsSpecificResourceSettings>>, InstantiateResourceRes<FormsResource>>;
|
|
8
6
|
//# sourceMappingURL=handler.d.ts.map
|
package/dist/handler.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"handler.d.ts","sourceRoot":"","sources":["../src/handler.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,+BAA+B,EAAE,MAAM,eAAe,CAAC;AACzE,OAAO,
|
|
1
|
+
{"version":3,"file":"handler.d.ts","sourceRoot":"","sources":["../src/handler.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,+BAA+B,EAAE,MAAM,eAAe,CAAC;AACzE,OAAO,EAAE,yBAAyB,EAAE,sBAAsB,EAAE,MAAM,gBAAgB,CAAC;AAEnF,OAAO,EAAE,aAAa,EAAE,MAAM,YAAY,CAAC;AAC3C,OAAO,EAAE,6BAA6B,EAAE,MAAM,SAAS,CAAC;AAExD,eAAO,MAAM,OAAO,EAAE,OAAO,CAC3B,yBAAyB,CAAC,+BAA+B,CAAC,6BAA6B,CAAC,CAAC,EACzF,sBAAsB,CAAC,aAAa,CAAC,CAChB,CAAC"}
|
package/dist/index.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
export * from
|
|
2
|
-
export * from
|
|
3
|
-
export * from
|
|
4
|
-
export * from
|
|
5
|
-
export * from
|
|
1
|
+
export * from './constants';
|
|
2
|
+
export * from './handler';
|
|
3
|
+
export * from './instantiate-resource';
|
|
4
|
+
export * from './resource';
|
|
5
|
+
export * from './types';
|
|
6
6
|
//# sourceMappingURL=index.d.ts.map
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { HandlerExtendedResourceSettings } from
|
|
2
|
-
import { InstantiateResource } from
|
|
3
|
-
import { FormsResource } from
|
|
4
|
-
import { FormsSpecificResourceSettings } from
|
|
1
|
+
import { HandlerExtendedResourceSettings } from '@ldsg/handler';
|
|
2
|
+
import { InstantiateResource } from '@ldsg/resource';
|
|
3
|
+
import { FormsResource } from './resource';
|
|
4
|
+
import { FormsSpecificResourceSettings } from './types';
|
|
5
5
|
export declare const instantiateResource: InstantiateResource<HandlerExtendedResourceSettings<FormsSpecificResourceSettings>, FormsResource>;
|
|
6
6
|
//# sourceMappingURL=instantiate-resource.d.ts.map
|
package/dist/resource.d.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import { PlatformsParams } from
|
|
2
|
-
import { ModifyGraphQLSchema } from
|
|
3
|
-
import { Resource } from
|
|
4
|
-
import { FormInfo, FormsSpecificResourceSettings } from
|
|
1
|
+
import { PlatformsParams } from '@ldsg/field-type';
|
|
2
|
+
import { ModifyGraphQLSchema } from '@ldsg/graphql';
|
|
3
|
+
import { Resource } from '@ldsg/resource';
|
|
4
|
+
import { FormInfo, FormsSpecificResourceSettings } from './types';
|
|
5
5
|
interface GetFormInfoListRes {
|
|
6
6
|
/**
|
|
7
7
|
* Form Info List
|
package/dist/resource.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"resource.d.ts","sourceRoot":"","sources":["../src/resource.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,eAAe,EAAE,MAAM,kBAAkB,CAAC;AACnD,OAAO,EAAE,mBAAmB,EAAE,MAAM,eAAe,CAAC;AACpD,OAAO,EAAE,QAAQ,EAAE,MAAM,gBAAgB,CAAC;AAE1C,OAAO,EAAE,QAAQ,EAAE,6BAA6B,EAAe,MAAM,SAAS,CAAC;AAG/E,UAAU,kBAAkB;IAC1B;;OAEG;IACH,YAAY,EAAE,QAAQ,EAAE,CAAC;CAC1B;AAED,KAAK,eAAe,GAAG,CAAC,MAAM,CAAC,EAAE,eAAe,KAAK,kBAAkB,CAAC;AAExE,qBAAa,aAAc,SAAQ,QAAQ,CAAC,6BAA6B,CAAC;IACxE,YAAY,CAAC,EAAE,QAAQ,EAAE,CAAC;IAE1B,eAAe,EAAE,eAAe,CA4B9B;IAEF,mBAAmB,EAAE,mBAAmB,
|
|
1
|
+
{"version":3,"file":"resource.d.ts","sourceRoot":"","sources":["../src/resource.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,eAAe,EAAE,MAAM,kBAAkB,CAAC;AACnD,OAAO,EAAE,mBAAmB,EAAE,MAAM,eAAe,CAAC;AACpD,OAAO,EAAE,QAAQ,EAAE,MAAM,gBAAgB,CAAC;AAE1C,OAAO,EAAE,QAAQ,EAAE,6BAA6B,EAAe,MAAM,SAAS,CAAC;AAG/E,UAAU,kBAAkB;IAC1B;;OAEG;IACH,YAAY,EAAE,QAAQ,EAAE,CAAC;CAC1B;AAED,KAAK,eAAe,GAAG,CAAC,MAAM,CAAC,EAAE,eAAe,KAAK,kBAAkB,CAAC;AAExE,qBAAa,aAAc,SAAQ,QAAQ,CAAC,6BAA6B,CAAC;IACxE,YAAY,CAAC,EAAE,QAAQ,EAAE,CAAC;IAE1B,eAAe,EAAE,eAAe,CA4B9B;IAEF,mBAAmB,EAAE,mBAAmB,CAStC;CACH"}
|
package/dist/resource.js
CHANGED
|
@@ -15,7 +15,7 @@ class FormsResource extends resource_1.Resource {
|
|
|
15
15
|
let formInfoList = thisFormInfoList;
|
|
16
16
|
if (!formInfoList) {
|
|
17
17
|
const { resources } = getFilteredResources({
|
|
18
|
-
parentId: id
|
|
18
|
+
parentId: id
|
|
19
19
|
});
|
|
20
20
|
const mapRes = resources.map((resource) => {
|
|
21
21
|
var _a;
|
|
@@ -26,20 +26,16 @@ class FormsResource extends resource_1.Resource {
|
|
|
26
26
|
this.formInfoList = formInfoList;
|
|
27
27
|
}
|
|
28
28
|
const res = {
|
|
29
|
-
formInfoList
|
|
29
|
+
formInfoList
|
|
30
30
|
};
|
|
31
31
|
return res;
|
|
32
32
|
};
|
|
33
33
|
this.modifyGraphQLSchema = (params) => {
|
|
34
34
|
const { schemaComposer } = params;
|
|
35
|
-
const { Mutation, Query } = schemaComposer;
|
|
36
35
|
const { formInfoList } = this.getFormInfoList();
|
|
37
|
-
|
|
36
|
+
(0, utils_1.getNewFields)({
|
|
38
37
|
formInfoList,
|
|
39
|
-
schemaComposer
|
|
40
|
-
});
|
|
41
|
-
[Mutation, Query].forEach((value) => {
|
|
42
|
-
value.addFields(newFields);
|
|
38
|
+
schemaComposer
|
|
43
39
|
});
|
|
44
40
|
};
|
|
45
41
|
}
|
|
@@ -13,7 +13,7 @@ class MockFormResource extends resource_1.Resource {
|
|
|
13
13
|
constructor() {
|
|
14
14
|
super(...arguments);
|
|
15
15
|
this.getFormInfo = (params) => {
|
|
16
|
-
const { id, settings: { title, description, name }, getResourcesFromSettings
|
|
16
|
+
const { id, settings: { title, description, name }, getResourcesFromSettings } = this;
|
|
17
17
|
const { inputObjectResource, outputObjectResource } = getResourcesFromSettings();
|
|
18
18
|
const { objectInfo: inputObjectInfo } = inputObjectResource.getObjectInfo(params);
|
|
19
19
|
const { objectInfo: outputObjectInfo } = outputObjectResource.getObjectInfo(params);
|
|
@@ -23,186 +23,156 @@ class MockFormResource extends resource_1.Resource {
|
|
|
23
23
|
description,
|
|
24
24
|
name,
|
|
25
25
|
inputObjectInfo,
|
|
26
|
-
outputObjectInfo
|
|
26
|
+
outputObjectInfo
|
|
27
27
|
};
|
|
28
28
|
return res;
|
|
29
29
|
};
|
|
30
30
|
}
|
|
31
31
|
}
|
|
32
|
-
|
|
33
|
-
const { fieldProperties, platform } = params;
|
|
34
|
-
const { max } = fieldProperties;
|
|
35
|
-
let res;
|
|
36
|
-
switch (platform) {
|
|
37
|
-
case "graphql": {
|
|
38
|
-
const type = "String";
|
|
39
|
-
res = {
|
|
40
|
-
type,
|
|
41
|
-
};
|
|
42
|
-
break;
|
|
43
|
-
}
|
|
44
|
-
case "mongoose": {
|
|
45
|
-
res = {
|
|
46
|
-
type: "String",
|
|
47
|
-
...(max
|
|
48
|
-
? {
|
|
49
|
-
maxLength: max,
|
|
50
|
-
}
|
|
51
|
-
: {}),
|
|
52
|
-
};
|
|
53
|
-
break;
|
|
54
|
-
}
|
|
55
|
-
default: {
|
|
56
|
-
res = {};
|
|
57
|
-
break;
|
|
58
|
-
}
|
|
59
|
-
}
|
|
60
|
-
return res;
|
|
61
|
-
};
|
|
62
|
-
test("forms", () => {
|
|
32
|
+
test('forms', () => {
|
|
63
33
|
const graphqlResource = new graphql_1.GraphqlResource({
|
|
64
|
-
id:
|
|
65
|
-
kind:
|
|
66
|
-
parentId:
|
|
34
|
+
id: 'test-graphql',
|
|
35
|
+
kind: 'graphql',
|
|
36
|
+
parentId: 'test-application',
|
|
67
37
|
settings: {
|
|
68
|
-
title:
|
|
69
|
-
description:
|
|
70
|
-
code:
|
|
71
|
-
dependencies: []
|
|
72
|
-
}
|
|
38
|
+
title: '测试GraphQL',
|
|
39
|
+
description: '',
|
|
40
|
+
code: '',
|
|
41
|
+
dependencies: []
|
|
42
|
+
}
|
|
73
43
|
});
|
|
74
44
|
new handler_1.HandlerResource(field_type_1.stringFieldTypeHandlerResourceRecord);
|
|
75
45
|
new field_type_1.FieldTypeResource(field_type_1.stringFieldTypeResourceRecord);
|
|
76
46
|
new object_field_1.ObjectFieldResource({
|
|
77
|
-
id:
|
|
78
|
-
kind:
|
|
79
|
-
parentId:
|
|
47
|
+
id: 'test-object-1-field-1',
|
|
48
|
+
kind: 'object_field',
|
|
49
|
+
parentId: 'test-object-1',
|
|
80
50
|
settings: {
|
|
81
|
-
title:
|
|
82
|
-
description:
|
|
83
|
-
name:
|
|
51
|
+
title: '测试对象1测试字段1',
|
|
52
|
+
description: '',
|
|
53
|
+
name: 'test-1',
|
|
84
54
|
fieldTypeResourceId: field_type_1.stringFieldTypeResourceRecord.id,
|
|
85
55
|
properties: {
|
|
86
|
-
max:
|
|
87
|
-
}
|
|
88
|
-
}
|
|
56
|
+
max: '10'
|
|
57
|
+
}
|
|
58
|
+
}
|
|
89
59
|
});
|
|
90
60
|
new object_field_1.ObjectFieldResource({
|
|
91
|
-
id:
|
|
92
|
-
kind:
|
|
93
|
-
parentId:
|
|
61
|
+
id: 'test-object-1-field-2',
|
|
62
|
+
kind: 'object_field',
|
|
63
|
+
parentId: 'test-object-1',
|
|
94
64
|
settings: {
|
|
95
|
-
title:
|
|
96
|
-
description:
|
|
97
|
-
name:
|
|
65
|
+
title: '测试对象1测试字段2',
|
|
66
|
+
description: '',
|
|
67
|
+
name: 'test-2',
|
|
98
68
|
fieldTypeResourceId: field_type_1.stringFieldTypeResourceRecord.id,
|
|
99
69
|
properties: {
|
|
100
|
-
max:
|
|
101
|
-
}
|
|
102
|
-
}
|
|
70
|
+
max: '10'
|
|
71
|
+
}
|
|
72
|
+
}
|
|
103
73
|
});
|
|
104
74
|
new object_field_1.ObjectFieldResource({
|
|
105
|
-
id:
|
|
106
|
-
kind:
|
|
107
|
-
parentId:
|
|
75
|
+
id: 'test-object-1-field-3',
|
|
76
|
+
kind: 'object_field',
|
|
77
|
+
parentId: 'test-object-1',
|
|
108
78
|
settings: {
|
|
109
|
-
title:
|
|
110
|
-
description:
|
|
111
|
-
name:
|
|
79
|
+
title: '测试对象1测试字段3',
|
|
80
|
+
description: '',
|
|
81
|
+
name: 'test-3',
|
|
112
82
|
fieldTypeResourceId: field_type_1.stringFieldTypeResourceRecord.id,
|
|
113
83
|
properties: {
|
|
114
|
-
max:
|
|
115
|
-
}
|
|
116
|
-
}
|
|
84
|
+
max: '10'
|
|
85
|
+
}
|
|
86
|
+
}
|
|
117
87
|
});
|
|
118
88
|
new object_1.ObjectResource({
|
|
119
|
-
id:
|
|
120
|
-
kind:
|
|
121
|
-
parentId:
|
|
89
|
+
id: 'test-object-1',
|
|
90
|
+
kind: 'object',
|
|
91
|
+
parentId: 'root',
|
|
122
92
|
settings: {
|
|
123
|
-
title:
|
|
124
|
-
description:
|
|
125
|
-
name:
|
|
126
|
-
}
|
|
93
|
+
title: '测试对象1',
|
|
94
|
+
description: '',
|
|
95
|
+
name: 'test-object-1'
|
|
96
|
+
}
|
|
127
97
|
});
|
|
128
98
|
new object_field_1.ObjectFieldResource({
|
|
129
|
-
id:
|
|
130
|
-
kind:
|
|
131
|
-
parentId:
|
|
99
|
+
id: 'test-object-2-field-1',
|
|
100
|
+
kind: 'object_field',
|
|
101
|
+
parentId: 'test-object-2',
|
|
132
102
|
settings: {
|
|
133
|
-
title:
|
|
134
|
-
description:
|
|
135
|
-
name:
|
|
103
|
+
title: '测试对象2测试字段1',
|
|
104
|
+
description: '',
|
|
105
|
+
name: 'test-1',
|
|
136
106
|
fieldTypeResourceId: field_type_1.stringFieldTypeResourceRecord.id,
|
|
137
107
|
properties: {
|
|
138
|
-
max:
|
|
139
|
-
}
|
|
140
|
-
}
|
|
108
|
+
max: '10'
|
|
109
|
+
}
|
|
110
|
+
}
|
|
141
111
|
});
|
|
142
112
|
new object_1.ObjectResource({
|
|
143
|
-
id:
|
|
144
|
-
kind:
|
|
145
|
-
parentId:
|
|
113
|
+
id: 'test-object-2',
|
|
114
|
+
kind: 'object',
|
|
115
|
+
parentId: 'root',
|
|
146
116
|
settings: {
|
|
147
|
-
title:
|
|
148
|
-
description:
|
|
149
|
-
name:
|
|
150
|
-
}
|
|
117
|
+
title: '测试对象2',
|
|
118
|
+
description: '',
|
|
119
|
+
name: 'test-object-2'
|
|
120
|
+
}
|
|
151
121
|
});
|
|
152
122
|
const formsResource = new resource_2.FormsResource({
|
|
153
|
-
id:
|
|
154
|
-
kind:
|
|
155
|
-
parentId:
|
|
123
|
+
id: 'test-forms',
|
|
124
|
+
kind: 'form',
|
|
125
|
+
parentId: 'test-application',
|
|
156
126
|
settings: {
|
|
157
|
-
title:
|
|
158
|
-
description:
|
|
159
|
-
}
|
|
127
|
+
title: '测试表单组',
|
|
128
|
+
description: ''
|
|
129
|
+
}
|
|
160
130
|
});
|
|
161
131
|
new workflow_1.WorkflowResource({
|
|
162
|
-
id:
|
|
163
|
-
kind:
|
|
164
|
-
parentId:
|
|
132
|
+
id: 'test-workflow-1',
|
|
133
|
+
kind: 'workflow',
|
|
134
|
+
parentId: 'root',
|
|
165
135
|
settings: {
|
|
166
|
-
title:
|
|
167
|
-
description:
|
|
168
|
-
startWorkflowNodeResourceId:
|
|
169
|
-
endWorkflowNodeResourceId:
|
|
170
|
-
}
|
|
136
|
+
title: '测试工作流1',
|
|
137
|
+
description: '',
|
|
138
|
+
startWorkflowNodeResourceId: '',
|
|
139
|
+
endWorkflowNodeResourceId: ''
|
|
140
|
+
}
|
|
171
141
|
});
|
|
172
142
|
new workflow_1.WorkflowResource({
|
|
173
|
-
id:
|
|
174
|
-
kind:
|
|
175
|
-
parentId:
|
|
143
|
+
id: 'test-workflow-2',
|
|
144
|
+
kind: 'workflow',
|
|
145
|
+
parentId: 'root',
|
|
176
146
|
settings: {
|
|
177
|
-
title:
|
|
178
|
-
description:
|
|
179
|
-
startWorkflowNodeResourceId:
|
|
180
|
-
endWorkflowNodeResourceId:
|
|
181
|
-
}
|
|
147
|
+
title: '测试工作流2',
|
|
148
|
+
description: '',
|
|
149
|
+
startWorkflowNodeResourceId: '',
|
|
150
|
+
endWorkflowNodeResourceId: ''
|
|
151
|
+
}
|
|
182
152
|
});
|
|
183
153
|
new MockFormResource({
|
|
184
|
-
id:
|
|
185
|
-
kind:
|
|
186
|
-
parentId:
|
|
154
|
+
id: 'test-form-1',
|
|
155
|
+
kind: 'form',
|
|
156
|
+
parentId: 'test-forms',
|
|
187
157
|
settings: {
|
|
188
|
-
title:
|
|
189
|
-
description:
|
|
190
|
-
name:
|
|
191
|
-
inputObjectResourceId:
|
|
192
|
-
outputObjectResourceId:
|
|
193
|
-
}
|
|
158
|
+
title: '测试表单1',
|
|
159
|
+
description: '',
|
|
160
|
+
name: 'test-a-1',
|
|
161
|
+
inputObjectResourceId: 'test-object-1',
|
|
162
|
+
outputObjectResourceId: 'test-object-2'
|
|
163
|
+
}
|
|
194
164
|
});
|
|
195
165
|
new MockFormResource({
|
|
196
|
-
id:
|
|
197
|
-
kind:
|
|
198
|
-
parentId:
|
|
166
|
+
id: 'test-form-2',
|
|
167
|
+
kind: 'form',
|
|
168
|
+
parentId: 'test-forms',
|
|
199
169
|
settings: {
|
|
200
|
-
title:
|
|
201
|
-
description:
|
|
202
|
-
name:
|
|
203
|
-
inputObjectResourceId:
|
|
204
|
-
outputObjectResourceId:
|
|
205
|
-
}
|
|
170
|
+
title: '测试表单2',
|
|
171
|
+
description: '',
|
|
172
|
+
name: 'test-a-2',
|
|
173
|
+
inputObjectResourceId: 'test-object-2',
|
|
174
|
+
outputObjectResourceId: 'test-object-1'
|
|
175
|
+
}
|
|
206
176
|
});
|
|
207
177
|
const getFormInfoListRes = formsResource.getFormInfoList();
|
|
208
178
|
expect(getFormInfoListRes).toMatchSnapshot();
|
|
@@ -210,3 +180,101 @@ test("forms", () => {
|
|
|
210
180
|
const schemaDSL = (0, graphql_2.printSchema)(schema);
|
|
211
181
|
expect(schemaDSL).toMatchSnapshot();
|
|
212
182
|
});
|
|
183
|
+
test('form and forms query fields', () => {
|
|
184
|
+
const graphqlResource = new graphql_1.GraphqlResource({
|
|
185
|
+
id: 'test-graphql',
|
|
186
|
+
kind: 'graphql',
|
|
187
|
+
parentId: 'test-application',
|
|
188
|
+
settings: {
|
|
189
|
+
title: '测试GraphQL',
|
|
190
|
+
description: '',
|
|
191
|
+
code: '',
|
|
192
|
+
dependencies: []
|
|
193
|
+
}
|
|
194
|
+
});
|
|
195
|
+
new handler_1.HandlerResource(field_type_1.stringFieldTypeHandlerResourceRecord);
|
|
196
|
+
new field_type_1.FieldTypeResource(field_type_1.stringFieldTypeResourceRecord);
|
|
197
|
+
new object_field_1.ObjectFieldResource({
|
|
198
|
+
id: 'test-object-1-field-1',
|
|
199
|
+
kind: 'object_field',
|
|
200
|
+
parentId: 'test-object-1',
|
|
201
|
+
settings: {
|
|
202
|
+
title: '测试对象字段',
|
|
203
|
+
description: '',
|
|
204
|
+
name: 'test_field_1',
|
|
205
|
+
fieldTypeResourceId: field_type_1.stringFieldTypeResourceRecord.id,
|
|
206
|
+
properties: {
|
|
207
|
+
max: '10'
|
|
208
|
+
}
|
|
209
|
+
}
|
|
210
|
+
});
|
|
211
|
+
new object_1.ObjectResource({
|
|
212
|
+
id: 'test-object-1',
|
|
213
|
+
kind: 'object',
|
|
214
|
+
parentId: 'test-application',
|
|
215
|
+
settings: {
|
|
216
|
+
title: '测试对象1',
|
|
217
|
+
description: '',
|
|
218
|
+
name: 'test_object_1',
|
|
219
|
+
fields: ['test-object-1-field-1']
|
|
220
|
+
}
|
|
221
|
+
});
|
|
222
|
+
new object_1.ObjectResource({
|
|
223
|
+
id: 'test-object-2',
|
|
224
|
+
kind: 'object',
|
|
225
|
+
parentId: 'test-application',
|
|
226
|
+
settings: {
|
|
227
|
+
title: '测试对象2',
|
|
228
|
+
description: '',
|
|
229
|
+
name: 'test_object_2',
|
|
230
|
+
fields: []
|
|
231
|
+
}
|
|
232
|
+
});
|
|
233
|
+
const formsResource = new resource_2.FormsResource({
|
|
234
|
+
id: 'test-forms',
|
|
235
|
+
kind: 'forms',
|
|
236
|
+
parentId: 'test-application',
|
|
237
|
+
settings: {
|
|
238
|
+
title: '测试表单',
|
|
239
|
+
description: ''
|
|
240
|
+
}
|
|
241
|
+
});
|
|
242
|
+
new MockFormResource({
|
|
243
|
+
id: 'test-form-1',
|
|
244
|
+
kind: 'form',
|
|
245
|
+
parentId: 'test-forms',
|
|
246
|
+
settings: {
|
|
247
|
+
title: '测试表单1',
|
|
248
|
+
description: 'Test Form 1',
|
|
249
|
+
name: 'test-a-1',
|
|
250
|
+
inputObjectResourceId: 'test-object-1',
|
|
251
|
+
outputObjectResourceId: 'test-object-2'
|
|
252
|
+
}
|
|
253
|
+
});
|
|
254
|
+
new MockFormResource({
|
|
255
|
+
id: 'test-form-2',
|
|
256
|
+
kind: 'form',
|
|
257
|
+
parentId: 'test-forms',
|
|
258
|
+
settings: {
|
|
259
|
+
title: '测试表单2',
|
|
260
|
+
description: 'Test Form 2',
|
|
261
|
+
name: 'test-a-2',
|
|
262
|
+
inputObjectResourceId: 'test-object-2',
|
|
263
|
+
outputObjectResourceId: 'test-object-1'
|
|
264
|
+
}
|
|
265
|
+
});
|
|
266
|
+
const { schema } = graphqlResource.getGraphQLSchema();
|
|
267
|
+
const queryType = schema.getQueryType();
|
|
268
|
+
expect(queryType).toBeDefined();
|
|
269
|
+
const formField = queryType === null || queryType === void 0 ? void 0 : queryType.getFields()['form'];
|
|
270
|
+
expect(formField).toBeDefined();
|
|
271
|
+
const formsField = queryType === null || queryType === void 0 ? void 0 : queryType.getFields()['forms'];
|
|
272
|
+
expect(formsField).toBeDefined();
|
|
273
|
+
const mutationType = schema.getMutationType();
|
|
274
|
+
expect(mutationType).toBeDefined();
|
|
275
|
+
// Individual form mutations should still exist
|
|
276
|
+
const testA1Field = mutationType === null || mutationType === void 0 ? void 0 : mutationType.getFields()['testA1'];
|
|
277
|
+
expect(testA1Field).toBeDefined();
|
|
278
|
+
const testA2Field = mutationType === null || mutationType === void 0 ? void 0 : mutationType.getFields()['testA2'];
|
|
279
|
+
expect(testA2Field).toBeDefined();
|
|
280
|
+
});
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { PlatformsParams } from
|
|
2
|
-
import { ObjectInfo } from
|
|
3
|
-
import { GeneralResourceSettings } from
|
|
1
|
+
import { PlatformsParams } from '@ldsg/field-type';
|
|
2
|
+
import { ObjectInfo } from '@ldsg/object';
|
|
3
|
+
import { GeneralResourceSettings } from '@ldsg/types';
|
|
4
4
|
export interface FormInfo extends GeneralResourceSettings {
|
|
5
5
|
/**
|
|
6
6
|
* Form ID
|
package/dist/types/index.d.ts
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/types/index.ts"],"names":[],"mappings":"AAAA,cAAc,iBAAiB,CAAC;AAChC,cAAc,8BAA8B,CAAC"}
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/types/index.ts"],"names":[],"mappings":"AAAA,cAAc,iBAAiB,CAAC;AAChC,cAAc,eAAe,CAAC;AAC9B,cAAc,8BAA8B,CAAC"}
|
package/dist/types/index.js
CHANGED
|
@@ -15,4 +15,5 @@ var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
|
15
15
|
};
|
|
16
16
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
17
|
__exportStar(require("./get-form-info"), exports);
|
|
18
|
+
__exportStar(require("./query-types"), exports);
|
|
18
19
|
__exportStar(require("./specific-resource-settings"), exports);
|