@ldsg/forms 0.2.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.
Files changed (54) hide show
  1. package/LICENSE +22 -0
  2. package/README.md +5 -0
  3. package/dist/constants.d.ts +14 -0
  4. package/dist/constants.d.ts.map +1 -0
  5. package/dist/constants.js +27 -0
  6. package/dist/handler.d.ts +8 -0
  7. package/dist/handler.d.ts.map +1 -0
  8. package/dist/handler.js +5 -0
  9. package/dist/index.d.ts +6 -0
  10. package/dist/index.d.ts.map +1 -0
  11. package/dist/index.js +21 -0
  12. package/dist/instantiate-resource.d.ts +6 -0
  13. package/dist/instantiate-resource.d.ts.map +1 -0
  14. package/dist/instantiate-resource.js +13 -0
  15. package/dist/resource.d.ts +20 -0
  16. package/dist/resource.d.ts.map +1 -0
  17. package/dist/resource.js +87 -0
  18. package/dist/test/__tests__/unit.d.ts +2 -0
  19. package/dist/test/__tests__/unit.d.ts.map +1 -0
  20. package/dist/test/__tests__/unit.js +212 -0
  21. package/dist/types/get-form-info.d.ts +28 -0
  22. package/dist/types/get-form-info.d.ts.map +1 -0
  23. package/dist/types/get-form-info.js +2 -0
  24. package/dist/types/index.d.ts +3 -0
  25. package/dist/types/index.d.ts.map +1 -0
  26. package/dist/types/index.js +18 -0
  27. package/dist/types/specific-resource-settings.d.ts +4 -0
  28. package/dist/types/specific-resource-settings.d.ts.map +1 -0
  29. package/dist/types/specific-resource-settings.js +2 -0
  30. package/dist/utils/get-new-fields/index.d.ts +13 -0
  31. package/dist/utils/get-new-fields/index.d.ts.map +1 -0
  32. package/dist/utils/get-new-fields/index.js +37 -0
  33. package/dist/utils/get-new-fields/utils/get-field-config-map-definition.d.ts +11 -0
  34. package/dist/utils/get-new-fields/utils/get-field-config-map-definition.d.ts.map +1 -0
  35. package/dist/utils/get-new-fields/utils/get-field-config-map-definition.js +28 -0
  36. package/dist/utils/get-new-fields/utils/get-graphql-type-by-common-type.d.ts +10 -0
  37. package/dist/utils/get-new-fields/utils/get-graphql-type-by-common-type.d.ts.map +1 -0
  38. package/dist/utils/get-new-fields/utils/get-graphql-type-by-common-type.js +21 -0
  39. package/dist/utils/get-new-fields/utils/get-graphql-type-by-type-info.d.ts +11 -0
  40. package/dist/utils/get-new-fields/utils/get-graphql-type-by-type-info.d.ts.map +1 -0
  41. package/dist/utils/get-new-fields/utils/get-graphql-type-by-type-info.js +21 -0
  42. package/dist/utils/get-new-fields/utils/get-input-itc.d.ts +13 -0
  43. package/dist/utils/get-new-fields/utils/get-input-itc.d.ts.map +1 -0
  44. package/dist/utils/get-new-fields/utils/get-input-itc.js +27 -0
  45. package/dist/utils/get-new-fields/utils/get-output-otc.d.ts +13 -0
  46. package/dist/utils/get-new-fields/utils/get-output-otc.d.ts.map +1 -0
  47. package/dist/utils/get-new-fields/utils/get-output-otc.js +27 -0
  48. package/dist/utils/get-new-fields/utils/index.d.ts +3 -0
  49. package/dist/utils/get-new-fields/utils/index.d.ts.map +1 -0
  50. package/dist/utils/get-new-fields/utils/index.js +18 -0
  51. package/dist/utils/index.d.ts +2 -0
  52. package/dist/utils/index.d.ts.map +1 -0
  53. package/dist/utils/index.js +17 -0
  54. package/package.json +40 -0
package/LICENSE ADDED
@@ -0,0 +1,22 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2014-present Sebastian McKenzie and other contributors
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining
6
+ a copy of this software and associated documentation files (the
7
+ "Software"), to deal in the Software without restriction, including
8
+ without limitation the rights to use, copy, modify, merge, publish,
9
+ distribute, sublicense, and/or sell copies of the Software, and to
10
+ permit persons to whom the Software is furnished to do so, subject to
11
+ the following conditions:
12
+
13
+ The above copyright notice and this permission notice shall be
14
+ included in all copies or substantial portions of the Software.
15
+
16
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
17
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
18
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
19
+ NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
20
+ LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
21
+ OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
22
+ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
package/README.md ADDED
@@ -0,0 +1,5 @@
1
+ # LDSG Forms Resource
2
+
3
+ TODO
4
+
5
+ - [ ] add e2e, request to express app
@@ -0,0 +1,14 @@
1
+ import { HandlerSpecificResourceSettings } from "@ldsg/handler";
2
+ import { ResourceDefinitionSpecificResourceSettings } from "@ldsg/resource-definition";
3
+ import { GeneralResourceSettings } from "@ldsg/types";
4
+ export declare const HANDLER_GENERAL_RESOURCE_SETTINGS: GeneralResourceSettings;
5
+ /**
6
+ * Handler Resource Settings
7
+ * 此类型资源的子级处理程序资源的配置
8
+ * 如无或为 undefined,则说明无需子级处理程序。
9
+ */
10
+ export declare const HANDLER_SPECIFIC_RESOURCE_SETTINGS: HandlerSpecificResourceSettings;
11
+ export declare const RESOURCE_DEFINITION_GENERAL_RESOURCE_SETTINGS: GeneralResourceSettings;
12
+ export declare const RESOURCE_DEFINITION_SPECIFIC_RESOURCE_SETTINGS: ResourceDefinitionSpecificResourceSettings;
13
+ export declare const FORMS_ROUTE = "/forms";
14
+ //# sourceMappingURL=constants.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"constants.d.ts","sourceRoot":"","sources":["../src/constants.ts"],"names":[],"mappings":"AACA,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,eAAO,MAAM,iCAAiC,EAAE,uBAG/C,CAAC;AAEF;;;;GAIG;AACH,eAAO,MAAM,kCAAkC,EAAE,+BAQ9C,CAAC;AAEJ,eAAO,MAAM,6CAA6C,EAAE,uBACnB,CAAC;AAE1C,eAAO,MAAM,8CAA8C,EAAE,0CAI1D,CAAC;AAEJ,eAAO,MAAM,WAAW,WAAW,CAAC"}
@@ -0,0 +1,27 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.FORMS_ROUTE = exports.RESOURCE_DEFINITION_SPECIFIC_RESOURCE_SETTINGS = exports.RESOURCE_DEFINITION_GENERAL_RESOURCE_SETTINGS = exports.HANDLER_SPECIFIC_RESOURCE_SETTINGS = exports.HANDLER_GENERAL_RESOURCE_SETTINGS = void 0;
4
+ const application_1 = require("@ldsg/application");
5
+ exports.HANDLER_GENERAL_RESOURCE_SETTINGS = {
6
+ title: "表单组类型资源处理程序",
7
+ description: "",
8
+ };
9
+ /**
10
+ * Handler Resource Settings
11
+ * 此类型资源的子级处理程序资源的配置
12
+ * 如无或为 undefined,则说明无需子级处理程序。
13
+ */
14
+ exports.HANDLER_SPECIFIC_RESOURCE_SETTINGS = {
15
+ code: `export * from "@ldsg/forms";`,
16
+ dependencies: [
17
+ {
18
+ name: "@ldsg/forms",
19
+ },
20
+ ],
21
+ };
22
+ exports.RESOURCE_DEFINITION_GENERAL_RESOURCE_SETTINGS = { title: "表单组类型资源定义", description: "" };
23
+ exports.RESOURCE_DEFINITION_SPECIFIC_RESOURCE_SETTINGS = {
24
+ kind: "forms",
25
+ parentKind: application_1.RESOURCE_DEFINITION_SPECIFIC_RESOURCE_SETTINGS.kind,
26
+ };
27
+ exports.FORMS_ROUTE = "/forms";
@@ -0,0 +1,8 @@
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<[
6
+ InstantiateResourceParams<HandlerExtendedResourceSettings<FormsSpecificResourceSettings>>
7
+ ], InstantiateResourceRes<FormsResource>>;
8
+ //# sourceMappingURL=handler.d.ts.map
@@ -0,0 +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,EACL,yBAAyB,EACzB,sBAAsB,EACvB,MAAM,gBAAgB,CAAC;AAExB,OAAO,EAAE,aAAa,EAAE,MAAM,YAAY,CAAC;AAC3C,OAAO,EAAE,6BAA6B,EAAE,MAAM,SAAS,CAAC;AAExD,eAAO,MAAM,OAAO,EAAE,OAAO,CAC3B;IACE,yBAAyB,CACvB,+BAA+B,CAAC,6BAA6B,CAAC,CAC/D;CACF,EACD,sBAAsB,CAAC,aAAa,CAAC,CAChB,CAAC"}
@@ -0,0 +1,5 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.handler = void 0;
4
+ const instantiate_resource_1 = require("./instantiate-resource");
5
+ exports.handler = instantiate_resource_1.instantiateResource;
@@ -0,0 +1,6 @@
1
+ export * from "./constants";
2
+ export * from "./handler";
3
+ export * from "./instantiate-resource";
4
+ export * from "./resource";
5
+ export * from "./types";
6
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,aAAa,CAAC;AAC5B,cAAc,WAAW,CAAC;AAC1B,cAAc,wBAAwB,CAAC;AACvC,cAAc,YAAY,CAAC;AAC3B,cAAc,SAAS,CAAC"}
package/dist/index.js ADDED
@@ -0,0 +1,21 @@
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("./constants"), exports);
18
+ __exportStar(require("./handler"), exports);
19
+ __exportStar(require("./instantiate-resource"), exports);
20
+ __exportStar(require("./resource"), exports);
21
+ __exportStar(require("./types"), exports);
@@ -0,0 +1,6 @@
1
+ import { HandlerExtendedResourceSettings } from "@ldsg/handler";
2
+ import { InstantiateResource } from "@ldsg/resource";
3
+ import { FormsResource } from "./resource";
4
+ import { FormsSpecificResourceSettings } from "./types";
5
+ export declare const instantiateResource: InstantiateResource<HandlerExtendedResourceSettings<FormsSpecificResourceSettings>, FormsResource>;
6
+ //# sourceMappingURL=instantiate-resource.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"instantiate-resource.d.ts","sourceRoot":"","sources":["../src/instantiate-resource.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,+BAA+B,EAAE,MAAM,eAAe,CAAC;AAChE,OAAO,EAAE,mBAAmB,EAAE,MAAM,gBAAgB,CAAC;AACrD,OAAO,EAAE,aAAa,EAAE,MAAM,YAAY,CAAC;AAC3C,OAAO,EAAE,6BAA6B,EAAE,MAAM,SAAS,CAAC;AAExD,eAAO,MAAM,mBAAmB,EAAE,mBAAmB,CACnD,+BAA+B,CAAC,6BAA6B,CAAC,EAC9D,aAAa,CAWd,CAAC"}
@@ -0,0 +1,13 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.instantiateResource = void 0;
4
+ const resource_1 = require("./resource");
5
+ const instantiateResource = (params) => {
6
+ const { resourceConstructorParams } = params;
7
+ const resource = new resource_1.FormsResource(resourceConstructorParams);
8
+ const res = {
9
+ resource,
10
+ };
11
+ return res;
12
+ };
13
+ exports.instantiateResource = instantiateResource;
@@ -0,0 +1,20 @@
1
+ import { ExtendExpressApp } from "@ldsg/application";
2
+ import { PlatformsParams } from "@ldsg/field-type";
3
+ import { ModifyGraphQLSchema } from "@ldsg/graphql";
4
+ import { Resource } from "@ldsg/resource";
5
+ import { FormInfo, FormsSpecificResourceSettings } from "./types";
6
+ interface GetFormInfoListRes {
7
+ /**
8
+ * Form Info List
9
+ */
10
+ formInfoList: FormInfo[];
11
+ }
12
+ type GetFormInfoList = (params?: PlatformsParams) => GetFormInfoListRes;
13
+ export declare class FormsResource extends Resource<FormsSpecificResourceSettings> {
14
+ formInfoList?: FormInfo[];
15
+ getFormInfoList: GetFormInfoList;
16
+ extendExpressApp: ExtendExpressApp;
17
+ modifyGraphQLSchema: ModifyGraphQLSchema;
18
+ }
19
+ export {};
20
+ //# sourceMappingURL=resource.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"resource.d.ts","sourceRoot":"","sources":["../src/resource.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,gBAAgB,EAAE,MAAM,mBAAmB,CAAC;AACrD,OAAO,EAAE,eAAe,EAAE,MAAM,kBAAkB,CAAC;AACnD,OAAO,EAAE,mBAAmB,EAAE,MAAM,eAAe,CAAC;AACpD,OAAO,EAAE,QAAQ,EAAE,MAAM,gBAAgB,CAAC;AAI1C,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,gBAAgB,EAAE,gBAAgB,CAqDhC;IAEF,mBAAmB,EAAE,mBAAmB,CAYtC;CACH"}
@@ -0,0 +1,87 @@
1
+ "use strict";
2
+ var __importDefault = (this && this.__importDefault) || function (mod) {
3
+ return (mod && mod.__esModule) ? mod : { "default": mod };
4
+ };
5
+ Object.defineProperty(exports, "__esModule", { value: true });
6
+ exports.FormsResource = void 0;
7
+ const resource_1 = require("@ldsg/resource");
8
+ const express_1 = __importDefault(require("express"));
9
+ const lodash_1 = __importDefault(require("lodash"));
10
+ const constants_1 = require("./constants");
11
+ const utils_1 = require("./utils");
12
+ class FormsResource extends resource_1.Resource {
13
+ constructor() {
14
+ super(...arguments);
15
+ this.getFormInfoList = (params) => {
16
+ const { id, formInfoList: thisFormInfoList, getFilteredResources } = this;
17
+ let formInfoList = thisFormInfoList;
18
+ if (!formInfoList) {
19
+ const { resources } = getFilteredResources({
20
+ parentId: id,
21
+ });
22
+ const mapRes = resources.map((resource) => {
23
+ var _a;
24
+ return (_a = resource.getFormInfo) === null || _a === void 0 ? void 0 : _a.call(resource, params);
25
+ });
26
+ const filterRes = lodash_1.default.filter(mapRes, (value) => !lodash_1.default.isUndefined(value));
27
+ formInfoList = filterRes;
28
+ this.formInfoList = formInfoList;
29
+ }
30
+ const res = {
31
+ formInfoList,
32
+ };
33
+ return res;
34
+ };
35
+ this.extendExpressApp = async (params) => {
36
+ const { app } = params;
37
+ const { formInfoList } = this.getFormInfoList();
38
+ // 解析 JSON 请求体
39
+ app.use(express_1.default.json());
40
+ // 解析 URL 编码的请求体,extended: true 允许使用复杂对象
41
+ app.use(express_1.default.urlencoded({ extended: true }));
42
+ /**
43
+ * RESTful
44
+ */
45
+ app.get(constants_1.FORMS_ROUTE, (req, res) => {
46
+ res.json({
47
+ list: formInfoList,
48
+ });
49
+ });
50
+ app.get(`${constants_1.FORMS_ROUTE}/:formId`, (req, res) => {
51
+ const { formId } = req.params;
52
+ const formInfo = formInfoList.find((formInfo) => {
53
+ return formInfo.id === formId;
54
+ });
55
+ res.json(formInfo);
56
+ });
57
+ app.post(`${constants_1.FORMS_ROUTE}/:formId`, async (req, res) => {
58
+ const { formId } = req.params;
59
+ const formInfo = formInfoList.find((formInfo) => {
60
+ return formInfo.id === formId;
61
+ });
62
+ const startNodeInputVariables = {
63
+ args: req.body,
64
+ };
65
+ if (!formInfo) {
66
+ throw new Error("invalid form");
67
+ }
68
+ const executeRes = await formInfo.workflowInfo.execute({
69
+ startNodeInputVariables,
70
+ });
71
+ const data = executeRes === null || executeRes === void 0 ? void 0 : executeRes.endNodeOutputVariables;
72
+ res.json(data);
73
+ });
74
+ };
75
+ this.modifyGraphQLSchema = (params) => {
76
+ const { schemaComposer } = params;
77
+ const { formInfoList } = this.getFormInfoList();
78
+ const { newFields } = (0, utils_1.getNewFields)({
79
+ formInfoList,
80
+ schemaComposer,
81
+ });
82
+ schemaComposer.Mutation.addFields(newFields);
83
+ schemaComposer.Query.addFields(newFields);
84
+ };
85
+ }
86
+ }
87
+ exports.FormsResource = FormsResource;
@@ -0,0 +1,2 @@
1
+ export {};
2
+ //# sourceMappingURL=unit.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"unit.d.ts","sourceRoot":"","sources":["../../../src/test/__tests__/unit.ts"],"names":[],"mappings":""}
@@ -0,0 +1,212 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ const field_type_1 = require("@ldsg/field-type");
4
+ const graphql_1 = require("@ldsg/graphql");
5
+ const handler_1 = require("@ldsg/handler");
6
+ const object_1 = require("@ldsg/object");
7
+ const object_field_1 = require("@ldsg/object-field");
8
+ const resource_1 = require("@ldsg/resource");
9
+ const workflow_1 = require("@ldsg/workflow");
10
+ const graphql_2 = require("graphql");
11
+ const resource_2 = require("../../resource");
12
+ class MockFormResource extends resource_1.Resource {
13
+ constructor() {
14
+ super(...arguments);
15
+ this.getFormInfo = (params) => {
16
+ const { id, settings: { title, description, name }, getResourcesFromSettings, } = this;
17
+ const { inputObjectResource, outputObjectResource, workflowResource } = getResourcesFromSettings();
18
+ const { objectInfo: inputObjectInfo } = inputObjectResource.getObjectInfo(params);
19
+ const { objectInfo: outputObjectInfo } = outputObjectResource.getObjectInfo(params);
20
+ const { workflowInfo } = workflowResource.getWorkflowInfo();
21
+ const res = {
22
+ id,
23
+ title,
24
+ description,
25
+ name,
26
+ inputObjectInfo,
27
+ outputObjectInfo,
28
+ workflowInfo,
29
+ };
30
+ return res;
31
+ };
32
+ }
33
+ }
34
+ const handler = (params) => {
35
+ const { fieldProperties, platform } = params;
36
+ const { max } = fieldProperties;
37
+ let res;
38
+ switch (platform) {
39
+ case "graphql": {
40
+ const type = "String";
41
+ res = {
42
+ type,
43
+ };
44
+ break;
45
+ }
46
+ case "mongoose": {
47
+ res = {
48
+ type: "String",
49
+ ...(max
50
+ ? {
51
+ maxLength: max,
52
+ }
53
+ : {}),
54
+ };
55
+ break;
56
+ }
57
+ default: {
58
+ res = {};
59
+ break;
60
+ }
61
+ }
62
+ return res;
63
+ };
64
+ test("forms", () => {
65
+ const graphqlResource = new graphql_1.GraphqlResource({
66
+ id: "test-graphql",
67
+ kind: "graphql",
68
+ parentId: "test-application",
69
+ settings: {
70
+ title: "测试GraphQL",
71
+ description: "",
72
+ code: "",
73
+ dependencies: [],
74
+ },
75
+ });
76
+ new handler_1.HandlerResource(field_type_1.stringFieldTypeHandlerResourceRecord);
77
+ new field_type_1.FieldTypeResource(field_type_1.stringFieldTypeResourceRecord);
78
+ new object_field_1.ObjectFieldResource({
79
+ id: "test-object-1-field-1",
80
+ kind: "object_field",
81
+ parentId: "test-object-1",
82
+ settings: {
83
+ title: "测试对象1测试字段1",
84
+ description: "",
85
+ name: "test-1",
86
+ fieldTypeResourceId: field_type_1.stringFieldTypeResourceRecord.id,
87
+ properties: {
88
+ max: "10",
89
+ },
90
+ },
91
+ });
92
+ new object_field_1.ObjectFieldResource({
93
+ id: "test-object-1-field-2",
94
+ kind: "object_field",
95
+ parentId: "test-object-1",
96
+ settings: {
97
+ title: "测试对象1测试字段2",
98
+ description: "",
99
+ name: "test-2",
100
+ fieldTypeResourceId: field_type_1.stringFieldTypeResourceRecord.id,
101
+ properties: {
102
+ max: "10",
103
+ },
104
+ },
105
+ });
106
+ new object_field_1.ObjectFieldResource({
107
+ id: "test-object-1-field-3",
108
+ kind: "object_field",
109
+ parentId: "test-object-1",
110
+ settings: {
111
+ title: "测试对象1测试字段3",
112
+ description: "",
113
+ name: "test-3",
114
+ fieldTypeResourceId: field_type_1.stringFieldTypeResourceRecord.id,
115
+ properties: {
116
+ max: "10",
117
+ },
118
+ },
119
+ });
120
+ new object_1.ObjectResource({
121
+ id: "test-object-1",
122
+ kind: "object",
123
+ parentId: "root",
124
+ settings: {
125
+ title: "测试对象1",
126
+ description: "",
127
+ name: "test-object-1",
128
+ },
129
+ });
130
+ new object_field_1.ObjectFieldResource({
131
+ id: "test-object-2-field-1",
132
+ kind: "object_field",
133
+ parentId: "test-object-2",
134
+ settings: {
135
+ title: "测试对象2测试字段1",
136
+ description: "",
137
+ name: "test-1",
138
+ fieldTypeResourceId: field_type_1.stringFieldTypeResourceRecord.id,
139
+ properties: {
140
+ max: "10",
141
+ },
142
+ },
143
+ });
144
+ new object_1.ObjectResource({
145
+ id: "test-object-2",
146
+ kind: "object",
147
+ parentId: "root",
148
+ settings: {
149
+ title: "测试对象2",
150
+ description: "",
151
+ name: "test-object-2",
152
+ },
153
+ });
154
+ const formsResource = new resource_2.FormsResource({
155
+ id: "test-forms",
156
+ kind: "form",
157
+ parentId: "test-application",
158
+ settings: {
159
+ title: "测试表单组",
160
+ description: "",
161
+ },
162
+ });
163
+ new workflow_1.WorkflowResource({
164
+ id: "test-workflow-1",
165
+ kind: "workflow",
166
+ parentId: "root",
167
+ settings: {
168
+ title: "测试工作流1",
169
+ description: "",
170
+ },
171
+ });
172
+ new workflow_1.WorkflowResource({
173
+ id: "test-workflow-2",
174
+ kind: "workflow",
175
+ parentId: "root",
176
+ settings: {
177
+ title: "测试工作流2",
178
+ description: "",
179
+ },
180
+ });
181
+ new MockFormResource({
182
+ id: "test-form-1",
183
+ kind: "form",
184
+ parentId: "test-forms",
185
+ settings: {
186
+ title: "测试表单1",
187
+ description: "",
188
+ name: "test-a-1",
189
+ inputObjectResourceId: "test-object-1",
190
+ outputObjectResourceId: "test-object-2",
191
+ workflowResourceId: "test-workflow-1",
192
+ },
193
+ });
194
+ new MockFormResource({
195
+ id: "test-form-2",
196
+ kind: "form",
197
+ parentId: "test-forms",
198
+ settings: {
199
+ title: "测试表单2",
200
+ description: "",
201
+ name: "test-a-2",
202
+ inputObjectResourceId: "test-object-2",
203
+ outputObjectResourceId: "test-object-1",
204
+ workflowResourceId: "test-workflow-2",
205
+ },
206
+ });
207
+ const getFormInfoListRes = formsResource.getFormInfoList();
208
+ expect(getFormInfoListRes).toMatchSnapshot();
209
+ const { schema } = graphqlResource.getGraphQLSchema();
210
+ const schemaDSL = (0, graphql_2.printSchema)(schema);
211
+ expect(schemaDSL).toMatchSnapshot();
212
+ });
@@ -0,0 +1,28 @@
1
+ import { PlatformsParams } from "@ldsg/field-type";
2
+ import { ObjectInfo } from "@ldsg/object";
3
+ import { GeneralResourceSettings } from "@ldsg/types";
4
+ import { WorkflowInfo } from "@ldsg/workflow";
5
+ export interface FormInfo extends GeneralResourceSettings {
6
+ /**
7
+ * Form ID
8
+ */
9
+ id: string;
10
+ /**
11
+ * Form Name
12
+ */
13
+ name: string;
14
+ /**
15
+ * Input Object Info
16
+ */
17
+ inputObjectInfo: ObjectInfo;
18
+ /**
19
+ * Output Object Info
20
+ */
21
+ outputObjectInfo: ObjectInfo;
22
+ /**
23
+ * Workflow Info
24
+ */
25
+ workflowInfo: WorkflowInfo;
26
+ }
27
+ export type GetFormInfo = (params?: PlatformsParams) => FormInfo;
28
+ //# sourceMappingURL=get-form-info.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"get-form-info.d.ts","sourceRoot":"","sources":["../../src/types/get-form-info.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,eAAe,EAAE,MAAM,kBAAkB,CAAC;AACnD,OAAO,EAAE,UAAU,EAAE,MAAM,cAAc,CAAC;AAC1C,OAAO,EAAE,uBAAuB,EAAE,MAAM,aAAa,CAAC;AACtD,OAAO,EAAE,YAAY,EAAE,MAAM,gBAAgB,CAAC;AAE9C,MAAM,WAAW,QAAS,SAAQ,uBAAuB;IACvD;;OAEG;IACH,EAAE,EAAE,MAAM,CAAC;IAEX;;OAEG;IACH,IAAI,EAAE,MAAM,CAAC;IAEb;;OAEG;IACH,eAAe,EAAE,UAAU,CAAC;IAE5B;;OAEG;IACH,gBAAgB,EAAE,UAAU,CAAC;IAE7B;;OAEG;IACH,YAAY,EAAE,YAAY,CAAC;CAC5B;AAED,MAAM,MAAM,WAAW,GAAG,CAAC,MAAM,CAAC,EAAE,eAAe,KAAK,QAAQ,CAAC"}
@@ -0,0 +1,2 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
@@ -0,0 +1,3 @@
1
+ export * from "./get-form-info";
2
+ export * from "./specific-resource-settings";
3
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/types/index.ts"],"names":[],"mappings":"AAAA,cAAc,iBAAiB,CAAC;AAChC,cAAc,8BAA8B,CAAC"}
@@ -0,0 +1,18 @@
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("./get-form-info"), exports);
18
+ __exportStar(require("./specific-resource-settings"), exports);
@@ -0,0 +1,4 @@
1
+ import { SpecificResourceSettings } from "@ldsg/types";
2
+ export interface FormsSpecificResourceSettings extends SpecificResourceSettings {
3
+ }
4
+ //# sourceMappingURL=specific-resource-settings.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"specific-resource-settings.d.ts","sourceRoot":"","sources":["../../src/types/specific-resource-settings.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,wBAAwB,EAAE,MAAM,aAAa,CAAC;AAEvD,MAAM,WAAW,6BACf,SAAQ,wBAAwB;CAAG"}
@@ -0,0 +1,2 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
@@ -0,0 +1,13 @@
1
+ import { SchemaComposerParams } from "@ldsg/graphql";
2
+ import { ObjectTypeComposerFieldConfigMapDefinition } from "graphql-compose";
3
+ import { FormInfo } from "../../types";
4
+ interface GetNewFieldsParams extends SchemaComposerParams {
5
+ formInfoList: FormInfo[];
6
+ }
7
+ interface GetNewFieldsRes {
8
+ newFields: ObjectTypeComposerFieldConfigMapDefinition<any, any>;
9
+ }
10
+ type GetNewFields = (params: GetNewFieldsParams) => GetNewFieldsRes;
11
+ export declare const getNewFields: GetNewFields;
12
+ export {};
13
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/utils/get-new-fields/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,oBAAoB,EAAE,MAAM,eAAe,CAAC;AACrD,OAAO,EACL,0CAA0C,EAE3C,MAAM,iBAAiB,CAAC;AAEzB,OAAO,EAAE,QAAQ,EAAE,MAAM,aAAa,CAAC;AAGvC,UAAU,kBAAmB,SAAQ,oBAAoB;IACvD,YAAY,EAAE,QAAQ,EAAE,CAAC;CAC1B;AAED,UAAU,eAAe;IACvB,SAAS,EAAE,0CAA0C,CAAC,GAAG,EAAE,GAAG,CAAC,CAAC;CACjE;AAED,KAAK,YAAY,GAAG,CAAC,MAAM,EAAE,kBAAkB,KAAK,eAAe,CAAC;AAEpE,eAAO,MAAM,YAAY,EAAE,YA6C1B,CAAC"}
@@ -0,0 +1,37 @@
1
+ "use strict";
2
+ var __importDefault = (this && this.__importDefault) || function (mod) {
3
+ return (mod && mod.__esModule) ? mod : { "default": mod };
4
+ };
5
+ Object.defineProperty(exports, "__esModule", { value: true });
6
+ exports.getNewFields = void 0;
7
+ const lodash_1 = __importDefault(require("lodash"));
8
+ const utils_1 = require("./utils");
9
+ const getNewFields = (params) => {
10
+ const { schemaComposer, formInfoList } = params;
11
+ const newFields = {};
12
+ formInfoList.forEach((formInfo) => {
13
+ const { title, description, name, inputObjectInfo, outputObjectInfo, workflowInfo, } = formInfo;
14
+ const graphqlFieldName = lodash_1.default.camelCase(name);
15
+ const { outputOTC } = (0, utils_1.getOutputOTC)({ schemaComposer, outputObjectInfo });
16
+ const { inputITC } = (0, utils_1.getInputITC)({ schemaComposer, inputObjectInfo });
17
+ const resolverDefinition = {
18
+ name: graphqlFieldName,
19
+ description: `${title}${description ? `:${description}` : ""}`,
20
+ type: outputOTC,
21
+ args: inputITC.getFields(),
22
+ resolve: async (resolveParams) => {
23
+ const { endNodeOutputVariables } = await workflowInfo.execute({
24
+ startNodeInputVariables: resolveParams,
25
+ });
26
+ return endNodeOutputVariables;
27
+ },
28
+ };
29
+ const fieldResolver = schemaComposer.createResolver(resolverDefinition);
30
+ newFields[graphqlFieldName] = fieldResolver;
31
+ });
32
+ const res = {
33
+ newFields,
34
+ };
35
+ return res;
36
+ };
37
+ exports.getNewFields = getNewFields;
@@ -0,0 +1,11 @@
1
+ import { FieldInfo } from "@ldsg/object";
2
+ interface GetFieldConfigMapDefinitionParams {
3
+ fieldInfoList: FieldInfo[];
4
+ }
5
+ interface GetFieldConfigMapDefinitionRes {
6
+ fieldConfigMapDefinition: Record<string, any>;
7
+ }
8
+ type GetFieldConfigMapDefinition = (params: GetFieldConfigMapDefinitionParams) => GetFieldConfigMapDefinitionRes;
9
+ export declare const getFieldConfigMapDefinition: GetFieldConfigMapDefinition;
10
+ export {};
11
+ //# sourceMappingURL=get-field-config-map-definition.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"get-field-config-map-definition.d.ts","sourceRoot":"","sources":["../../../../src/utils/get-new-fields/utils/get-field-config-map-definition.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,cAAc,CAAC;AAIzC,UAAU,iCAAiC;IACzC,aAAa,EAAE,SAAS,EAAE,CAAC;CAC5B;AAED,UAAU,8BAA8B;IACtC,wBAAwB,EAAE,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,CAAC;CAC/C;AAED,KAAK,2BAA2B,GAAG,CACjC,MAAM,EAAE,iCAAiC,KACtC,8BAA8B,CAAC;AAEpC,eAAO,MAAM,2BAA2B,EAAE,2BA2BzC,CAAC"}
@@ -0,0 +1,28 @@
1
+ "use strict";
2
+ var __importDefault = (this && this.__importDefault) || function (mod) {
3
+ return (mod && mod.__esModule) ? mod : { "default": mod };
4
+ };
5
+ Object.defineProperty(exports, "__esModule", { value: true });
6
+ exports.getFieldConfigMapDefinition = void 0;
7
+ const lodash_1 = __importDefault(require("lodash"));
8
+ const get_graphql_type_by_type_info_1 = require("./get-graphql-type-by-type-info");
9
+ const getFieldConfigMapDefinition = (params) => {
10
+ const { fieldInfoList } = params;
11
+ const fieldConfigMapDefinition = {};
12
+ lodash_1.default.each(fieldInfoList, (fieldInfo) => {
13
+ const { title, description, name, typeInfo } = fieldInfo;
14
+ const camelCaseName = lodash_1.default.camelCase(name);
15
+ const { graphqlType } = (0, get_graphql_type_by_type_info_1.getGraphqlTypeByTypeInfo)({
16
+ typeInfo,
17
+ });
18
+ fieldConfigMapDefinition[camelCaseName] = {
19
+ type: graphqlType,
20
+ description: `${title}${description ? `:${description}` : ""}`,
21
+ };
22
+ });
23
+ const res = {
24
+ fieldConfigMapDefinition,
25
+ };
26
+ return res;
27
+ };
28
+ exports.getFieldConfigMapDefinition = getFieldConfigMapDefinition;
@@ -0,0 +1,10 @@
1
+ interface GetGraphqlTypeByCommonTypeParams {
2
+ commonType: any;
3
+ }
4
+ interface GetGraphqlTypeByCommonTypeRes {
5
+ graphqlType: any;
6
+ }
7
+ type GetGraphqlTypeByCommonType = (params: GetGraphqlTypeByCommonTypeParams) => GetGraphqlTypeByCommonTypeRes;
8
+ export declare const getGraphqlTypeByCommonType: GetGraphqlTypeByCommonType;
9
+ export {};
10
+ //# sourceMappingURL=get-graphql-type-by-common-type.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"get-graphql-type-by-common-type.d.ts","sourceRoot":"","sources":["../../../../src/utils/get-new-fields/utils/get-graphql-type-by-common-type.ts"],"names":[],"mappings":"AAAA,UAAU,gCAAgC;IACxC,UAAU,EAAE,GAAG,CAAC;CACjB;AAED,UAAU,6BAA6B;IACrC,WAAW,EAAE,GAAG,CAAC;CAClB;AAED,KAAK,0BAA0B,GAAG,CAChC,MAAM,EAAE,gCAAgC,KACrC,6BAA6B,CAAC;AAEnC,eAAO,MAAM,0BAA0B,EAAE,0BAyBxC,CAAC"}
@@ -0,0 +1,21 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.getGraphqlTypeByCommonType = void 0;
4
+ const getGraphqlTypeByCommonType = (params) => {
5
+ const { commonType } = params;
6
+ const { type } = commonType;
7
+ let graphqlType;
8
+ switch (type) {
9
+ case "string": {
10
+ graphqlType = "String";
11
+ break;
12
+ }
13
+ default:
14
+ break;
15
+ }
16
+ const res = {
17
+ graphqlType,
18
+ };
19
+ return res;
20
+ };
21
+ exports.getGraphqlTypeByCommonType = getGraphqlTypeByCommonType;
@@ -0,0 +1,11 @@
1
+ import { FieldTypeInfo } from "@ldsg/field-type";
2
+ interface GetGraphqlTypeByTypeInfoParams {
3
+ typeInfo: FieldTypeInfo;
4
+ }
5
+ interface GetGraphqlTypeByTypeInfoRes {
6
+ graphqlType: any;
7
+ }
8
+ type GetGraphqlTypeByTypeInfo = (params: GetGraphqlTypeByTypeInfoParams) => GetGraphqlTypeByTypeInfoRes;
9
+ export declare const getGraphqlTypeByTypeInfo: GetGraphqlTypeByTypeInfo;
10
+ export {};
11
+ //# sourceMappingURL=get-graphql-type-by-type-info.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"get-graphql-type-by-type-info.d.ts","sourceRoot":"","sources":["../../../../src/utils/get-new-fields/utils/get-graphql-type-by-type-info.ts"],"names":[],"mappings":"AAAA,OAAO,EAAyB,aAAa,EAAE,MAAM,kBAAkB,CAAC;AAGxE,UAAU,8BAA8B;IACtC,QAAQ,EAAE,aAAa,CAAC;CACzB;AAED,UAAU,2BAA2B;IACnC,WAAW,EAAE,GAAG,CAAC;CAClB;AAED,KAAK,wBAAwB,GAAG,CAC9B,MAAM,EAAE,8BAA8B,KACnC,2BAA2B,CAAC;AAEjC,eAAO,MAAM,wBAAwB,EAAE,wBAoBtC,CAAC"}
@@ -0,0 +1,21 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.getGraphqlTypeByTypeInfo = void 0;
4
+ const field_type_1 = require("@ldsg/field-type");
5
+ const get_graphql_type_by_common_type_1 = require("./get-graphql-type-by-common-type");
6
+ const getGraphqlTypeByTypeInfo = (params) => {
7
+ const { typeInfo } = params;
8
+ const { platformToTypeMap } = typeInfo;
9
+ let graphqlType = platformToTypeMap[field_type_1.FieldTypeBasePlatform.GRAPHQL];
10
+ if (!graphqlType) {
11
+ const commonType = platformToTypeMap[field_type_1.FieldTypeBasePlatform.COMMON];
12
+ graphqlType = (0, get_graphql_type_by_common_type_1.getGraphqlTypeByCommonType)({
13
+ commonType,
14
+ }).graphqlType;
15
+ }
16
+ const res = {
17
+ graphqlType,
18
+ };
19
+ return res;
20
+ };
21
+ exports.getGraphqlTypeByTypeInfo = getGraphqlTypeByTypeInfo;
@@ -0,0 +1,13 @@
1
+ import { SchemaComposerParams } from "@ldsg/graphql";
2
+ import { ObjectInfo } from "@ldsg/object";
3
+ import { InputTypeComposer } from "graphql-compose";
4
+ interface GetInputITCParams extends SchemaComposerParams {
5
+ inputObjectInfo: ObjectInfo;
6
+ }
7
+ interface GetInputITCRes {
8
+ inputITC: InputTypeComposer<any>;
9
+ }
10
+ type GetInputITC = (params: GetInputITCParams) => GetInputITCRes;
11
+ export declare const getInputITC: GetInputITC;
12
+ export {};
13
+ //# sourceMappingURL=get-input-itc.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"get-input-itc.d.ts","sourceRoot":"","sources":["../../../../src/utils/get-new-fields/utils/get-input-itc.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,oBAAoB,EAAE,MAAM,eAAe,CAAC;AACrD,OAAO,EAAE,UAAU,EAAE,MAAM,cAAc,CAAC;AAC1C,OAAO,EACL,iBAAiB,EAElB,MAAM,iBAAiB,CAAC;AAIzB,UAAU,iBAAkB,SAAQ,oBAAoB;IACtD,eAAe,EAAE,UAAU,CAAC;CAC7B;AAED,UAAU,cAAc;IACtB,QAAQ,EAAE,iBAAiB,CAAC,GAAG,CAAC,CAAC;CAClC;AAED,KAAK,WAAW,GAAG,CAAC,MAAM,EAAE,iBAAiB,KAAK,cAAc,CAAC;AAEjE,eAAO,MAAM,WAAW,EAAE,WAyBzB,CAAC"}
@@ -0,0 +1,27 @@
1
+ "use strict";
2
+ var __importDefault = (this && this.__importDefault) || function (mod) {
3
+ return (mod && mod.__esModule) ? mod : { "default": mod };
4
+ };
5
+ Object.defineProperty(exports, "__esModule", { value: true });
6
+ exports.getInputITC = void 0;
7
+ const lodash_1 = __importDefault(require("lodash"));
8
+ const get_field_config_map_definition_1 = require("./get-field-config-map-definition");
9
+ const getInputITC = (params) => {
10
+ const { schemaComposer, inputObjectInfo } = params;
11
+ const { title, description, name, fieldInfoList } = inputObjectInfo;
12
+ const upperFirstCamelCaseName = lodash_1.default.upperFirst(lodash_1.default.camelCase(name));
13
+ const { fieldConfigMapDefinition } = (0, get_field_config_map_definition_1.getFieldConfigMapDefinition)({
14
+ fieldInfoList,
15
+ });
16
+ const definition = {
17
+ name: upperFirstCamelCaseName,
18
+ fields: fieldConfigMapDefinition,
19
+ };
20
+ const inputITC = schemaComposer.createInputTC(definition);
21
+ inputITC.setDescription(`${title}${description ? `:${description}` : ""}`);
22
+ const res = {
23
+ inputITC,
24
+ };
25
+ return res;
26
+ };
27
+ exports.getInputITC = getInputITC;
@@ -0,0 +1,13 @@
1
+ import { SchemaComposerParams } from "@ldsg/graphql";
2
+ import { ObjectInfo } from "@ldsg/object";
3
+ import { ObjectTypeComposer } from "graphql-compose";
4
+ interface GetOutputOTCParams extends SchemaComposerParams {
5
+ outputObjectInfo: ObjectInfo;
6
+ }
7
+ interface GetOutputOTCRes {
8
+ outputOTC: ObjectTypeComposer<any, any>;
9
+ }
10
+ type GetOutputOTC = (params: GetOutputOTCParams) => GetOutputOTCRes;
11
+ export declare const getOutputOTC: GetOutputOTC;
12
+ export {};
13
+ //# sourceMappingURL=get-output-otc.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"get-output-otc.d.ts","sourceRoot":"","sources":["../../../../src/utils/get-new-fields/utils/get-output-otc.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,oBAAoB,EAAE,MAAM,eAAe,CAAC;AACrD,OAAO,EAAE,UAAU,EAAE,MAAM,cAAc,CAAC;AAC1C,OAAO,EACL,kBAAkB,EAEnB,MAAM,iBAAiB,CAAC;AAIzB,UAAU,kBAAmB,SAAQ,oBAAoB;IACvD,gBAAgB,EAAE,UAAU,CAAC;CAC9B;AAED,UAAU,eAAe;IACvB,SAAS,EAAE,kBAAkB,CAAC,GAAG,EAAE,GAAG,CAAC,CAAC;CACzC;AAED,KAAK,YAAY,GAAG,CAAC,MAAM,EAAE,kBAAkB,KAAK,eAAe,CAAC;AAEpE,eAAO,MAAM,YAAY,EAAE,YAyB1B,CAAC"}
@@ -0,0 +1,27 @@
1
+ "use strict";
2
+ var __importDefault = (this && this.__importDefault) || function (mod) {
3
+ return (mod && mod.__esModule) ? mod : { "default": mod };
4
+ };
5
+ Object.defineProperty(exports, "__esModule", { value: true });
6
+ exports.getOutputOTC = void 0;
7
+ const lodash_1 = __importDefault(require("lodash"));
8
+ const get_field_config_map_definition_1 = require("./get-field-config-map-definition");
9
+ const getOutputOTC = (params) => {
10
+ const { schemaComposer, outputObjectInfo } = params;
11
+ const { title, description, name, fieldInfoList } = outputObjectInfo;
12
+ const upperFirstCamelCaseName = lodash_1.default.upperFirst(lodash_1.default.camelCase(name));
13
+ const { fieldConfigMapDefinition } = (0, get_field_config_map_definition_1.getFieldConfigMapDefinition)({
14
+ fieldInfoList,
15
+ });
16
+ const definition = {
17
+ name: upperFirstCamelCaseName,
18
+ fields: fieldConfigMapDefinition,
19
+ };
20
+ const outputOTC = schemaComposer.createObjectTC(definition);
21
+ outputOTC.setDescription(`${title}${description ? `:${description}` : ""}`);
22
+ const res = {
23
+ outputOTC,
24
+ };
25
+ return res;
26
+ };
27
+ exports.getOutputOTC = getOutputOTC;
@@ -0,0 +1,3 @@
1
+ export * from "./get-input-itc";
2
+ export * from "./get-output-otc";
3
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/utils/get-new-fields/utils/index.ts"],"names":[],"mappings":"AAAA,cAAc,iBAAiB,CAAC;AAChC,cAAc,kBAAkB,CAAC"}
@@ -0,0 +1,18 @@
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("./get-input-itc"), exports);
18
+ __exportStar(require("./get-output-otc"), exports);
@@ -0,0 +1,2 @@
1
+ export * from "./get-new-fields";
2
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/utils/index.ts"],"names":[],"mappings":"AAAA,cAAc,kBAAkB,CAAC"}
@@ -0,0 +1,17 @@
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("./get-new-fields"), exports);
package/package.json ADDED
@@ -0,0 +1,40 @@
1
+ {
2
+ "name": "@ldsg/forms",
3
+ "version": "0.2.0",
4
+ "description": "",
5
+ "main": "dist/index.js",
6
+ "files": [
7
+ "dist/"
8
+ ],
9
+ "types": "dist",
10
+ "keywords": [],
11
+ "author": "wanxger",
12
+ "license": "MIT",
13
+ "publishConfig": {
14
+ "access": "public"
15
+ },
16
+ "dependencies": {
17
+ "lodash": "^4.17.21",
18
+ "@ldsg/handler": "0.2.0",
19
+ "@ldsg/resource-definition": "0.2.0",
20
+ "@ldsg/resource": "0.2.0"
21
+ },
22
+ "devDependencies": {
23
+ "@types/lodash": "^4.14.202",
24
+ "@types/supertest": "^6.0.0",
25
+ "graphql": "16.11.0",
26
+ "graphql-compose": "^9.1.0",
27
+ "supertest": "^6.3.4",
28
+ "@ldsg/application": "0.2.0",
29
+ "@ldsg/graphql": "0.2.0",
30
+ "@ldsg/object": "0.2.0",
31
+ "@ldsg/field-type": "0.2.0",
32
+ "@ldsg/object-field": "0.2.0",
33
+ "@ldsg/types": "0.2.0",
34
+ "@ldsg/workflow": "0.2.0"
35
+ },
36
+ "scripts": {
37
+ "build": "pnpm clean && tsc --project tsconfig.build.json",
38
+ "clean": "rm -rf dist"
39
+ }
40
+ }