@ldsg/forms 0.3.23 → 0.3.25

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 (23) hide show
  1. package/dist/resource.d.ts +3 -0
  2. package/dist/resource.d.ts.map +1 -1
  3. package/dist/resource.js +2 -2
  4. package/dist/test/__tests__/unit.js +32 -130
  5. package/dist/utils/handle-form-info-list/index.d.ts +9 -0
  6. package/dist/utils/handle-form-info-list/index.d.ts.map +1 -0
  7. package/dist/utils/handle-form-info-list/index.js +21 -0
  8. package/dist/utils/handle-form-info-list/utils/get-field-config-map-definition.d.ts +11 -0
  9. package/dist/utils/handle-form-info-list/utils/get-field-config-map-definition.d.ts.map +1 -0
  10. package/dist/utils/handle-form-info-list/utils/get-field-config-map-definition.js +28 -0
  11. package/dist/utils/handle-form-info-list/utils/get-graphql-type-by-common-type.d.ts +10 -0
  12. package/dist/utils/handle-form-info-list/utils/get-graphql-type-by-common-type.d.ts.map +1 -0
  13. package/dist/utils/handle-form-info-list/utils/get-graphql-type-by-common-type.js +21 -0
  14. package/dist/utils/handle-form-info-list/utils/get-graphql-type-by-type-info.d.ts +11 -0
  15. package/dist/utils/handle-form-info-list/utils/get-graphql-type-by-type-info.d.ts.map +1 -0
  16. package/dist/utils/handle-form-info-list/utils/get-graphql-type-by-type-info.js +21 -0
  17. package/dist/utils/handle-form-info-list/utils/get-input-itc.d.ts +13 -0
  18. package/dist/utils/handle-form-info-list/utils/get-input-itc.d.ts.map +1 -0
  19. package/dist/utils/handle-form-info-list/utils/get-input-itc.js +22 -0
  20. package/dist/utils/handle-form-info-list/utils/get-output-otc.d.ts +13 -0
  21. package/dist/utils/handle-form-info-list/utils/get-output-otc.d.ts.map +1 -0
  22. package/dist/utils/handle-form-info-list/utils/get-output-otc.js +22 -0
  23. package/package.json +11 -11
@@ -10,6 +10,9 @@ interface GetFormInfoListRes {
10
10
  }
11
11
  type GetFormInfoList = (params?: PlatformsParams) => GetFormInfoListRes;
12
12
  export declare class FormsResource extends Resource<FormsSpecificResourceSettings> {
13
+ /**
14
+ * 用于缓存表单信息列表,避免重复计算
15
+ */
13
16
  formInfoList?: FormInfo[];
14
17
  getFormInfoList: GetFormInfoList;
15
18
  modifyGraphQLSchema: ModifyGraphQLSchema;
@@ -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,CAStC;CACH"}
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;;OAEG;IACH,YAAY,CAAC,EAAE,QAAQ,EAAE,CAAC;IAE1B,eAAe,EAAE,eAAe,CA4B9B;IAEF,mBAAmB,EAAE,mBAAmB,CAStC;CACH"}
package/dist/resource.js CHANGED
@@ -6,7 +6,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
6
6
  exports.FormsResource = void 0;
7
7
  const resource_1 = require("@ldsg/resource");
8
8
  const lodash_1 = __importDefault(require("lodash"));
9
- const utils_1 = require("./utils");
9
+ const handle_form_info_list_1 = require("./utils/handle-form-info-list");
10
10
  class FormsResource extends resource_1.Resource {
11
11
  constructor() {
12
12
  super(...arguments);
@@ -33,7 +33,7 @@ class FormsResource extends resource_1.Resource {
33
33
  this.modifyGraphQLSchema = (params) => {
34
34
  const { schemaComposer } = params;
35
35
  const { formInfoList } = this.getFormInfoList();
36
- (0, utils_1.getNewFields)({
36
+ (0, handle_form_info_list_1.handleFormInfoList)({
37
37
  formInfoList,
38
38
  schemaComposer
39
39
  });
@@ -31,9 +31,9 @@ class MockFormResource extends resource_1.Resource {
31
31
  }
32
32
  test('forms', () => {
33
33
  const graphqlResource = new graphql_1.GraphqlResource({
34
- id: 'test-graphql',
34
+ id: 'test_graphql',
35
35
  kind: 'graphql',
36
- parentId: 'test-application',
36
+ parentId: 'test_application',
37
37
  settings: {
38
38
  title: '测试GraphQL',
39
39
  description: '',
@@ -44,13 +44,13 @@ test('forms', () => {
44
44
  new handler_1.HandlerResource(field_type_1.stringFieldTypeHandlerResourceRecord);
45
45
  new field_type_1.FieldTypeResource(field_type_1.stringFieldTypeResourceRecord);
46
46
  new object_field_1.ObjectFieldResource({
47
- id: 'test-object-1-field-1',
47
+ id: 'test_object_1_field_1',
48
48
  kind: 'object_field',
49
- parentId: 'test-object-1',
49
+ parentId: 'test_object_1',
50
50
  settings: {
51
51
  title: '测试对象1测试字段1',
52
52
  description: '',
53
- name: 'test-1',
53
+ name: 'test_1',
54
54
  fieldTypeResourceId: field_type_1.stringFieldTypeResourceRecord.id,
55
55
  properties: {
56
56
  max: '10'
@@ -58,13 +58,13 @@ test('forms', () => {
58
58
  }
59
59
  });
60
60
  new object_field_1.ObjectFieldResource({
61
- id: 'test-object-1-field-2',
61
+ id: 'test_object_1_field_2',
62
62
  kind: 'object_field',
63
- parentId: 'test-object-1',
63
+ parentId: 'test_object_1',
64
64
  settings: {
65
65
  title: '测试对象1测试字段2',
66
66
  description: '',
67
- name: 'test-2',
67
+ name: 'test_2',
68
68
  fieldTypeResourceId: field_type_1.stringFieldTypeResourceRecord.id,
69
69
  properties: {
70
70
  max: '10'
@@ -72,13 +72,13 @@ test('forms', () => {
72
72
  }
73
73
  });
74
74
  new object_field_1.ObjectFieldResource({
75
- id: 'test-object-1-field-3',
75
+ id: 'test_object_1_field_3',
76
76
  kind: 'object_field',
77
- parentId: 'test-object-1',
77
+ parentId: 'test_object_1',
78
78
  settings: {
79
79
  title: '测试对象1测试字段3',
80
80
  description: '',
81
- name: 'test-3',
81
+ name: 'test_3',
82
82
  fieldTypeResourceId: field_type_1.stringFieldTypeResourceRecord.id,
83
83
  properties: {
84
84
  max: '10'
@@ -86,23 +86,23 @@ test('forms', () => {
86
86
  }
87
87
  });
88
88
  new object_1.ObjectResource({
89
- id: 'test-object-1',
89
+ id: 'test_object_1',
90
90
  kind: 'object',
91
91
  parentId: 'root',
92
92
  settings: {
93
93
  title: '测试对象1',
94
94
  description: '',
95
- name: 'test-object-1'
95
+ name: 'test_object_1'
96
96
  }
97
97
  });
98
98
  new object_field_1.ObjectFieldResource({
99
- id: 'test-object-2-field-1',
99
+ id: 'test_object_2_field_1',
100
100
  kind: 'object_field',
101
- parentId: 'test-object-2',
101
+ parentId: 'test_object_2',
102
102
  settings: {
103
103
  title: '测试对象2测试字段1',
104
104
  description: '',
105
- name: 'test-1',
105
+ name: 'test_1',
106
106
  fieldTypeResourceId: field_type_1.stringFieldTypeResourceRecord.id,
107
107
  properties: {
108
108
  max: '10'
@@ -110,26 +110,26 @@ test('forms', () => {
110
110
  }
111
111
  });
112
112
  new object_1.ObjectResource({
113
- id: 'test-object-2',
113
+ id: 'test_object_2',
114
114
  kind: 'object',
115
115
  parentId: 'root',
116
116
  settings: {
117
117
  title: '测试对象2',
118
118
  description: '',
119
- name: 'test-object-2'
119
+ name: 'test_object_2'
120
120
  }
121
121
  });
122
122
  const formsResource = new resource_2.FormsResource({
123
- id: 'test-forms',
123
+ id: 'test_forms',
124
124
  kind: 'form',
125
- parentId: 'test-application',
125
+ parentId: 'test_application',
126
126
  settings: {
127
127
  title: '测试表单组',
128
128
  description: ''
129
129
  }
130
130
  });
131
131
  new workflow_1.WorkflowResource({
132
- id: 'test-workflow-1',
132
+ id: 'test_workflow_1',
133
133
  kind: 'workflow',
134
134
  parentId: 'root',
135
135
  settings: {
@@ -140,7 +140,7 @@ test('forms', () => {
140
140
  }
141
141
  });
142
142
  new workflow_1.WorkflowResource({
143
- id: 'test-workflow-2',
143
+ id: 'test_workflow_2',
144
144
  kind: 'workflow',
145
145
  parentId: 'root',
146
146
  settings: {
@@ -151,27 +151,27 @@ test('forms', () => {
151
151
  }
152
152
  });
153
153
  new MockFormResource({
154
- id: 'test-form-1',
154
+ id: 'test_form_1',
155
155
  kind: 'form',
156
- parentId: 'test-forms',
156
+ parentId: 'test_forms',
157
157
  settings: {
158
158
  title: '测试表单1',
159
159
  description: '',
160
- name: 'test-a-1',
161
- inputObjectResourceId: 'test-object-1',
162
- outputObjectResourceId: 'test-object-2'
160
+ name: 'test_a_1',
161
+ inputObjectResourceId: 'test_object_1',
162
+ outputObjectResourceId: 'test_object_2'
163
163
  }
164
164
  });
165
165
  new MockFormResource({
166
- id: 'test-form-2',
166
+ id: 'test_form_2',
167
167
  kind: 'form',
168
- parentId: 'test-forms',
168
+ parentId: 'test_forms',
169
169
  settings: {
170
170
  title: '测试表单2',
171
171
  description: '',
172
- name: 'test-a-2',
173
- inputObjectResourceId: 'test-object-2',
174
- outputObjectResourceId: 'test-object-1'
172
+ name: 'test_a_2',
173
+ inputObjectResourceId: 'test_object_2',
174
+ outputObjectResourceId: 'test_object_1'
175
175
  }
176
176
  });
177
177
  const getFormInfoListRes = formsResource.getFormInfoList();
@@ -180,101 +180,3 @@ test('forms', () => {
180
180
  const schemaDSL = (0, graphql_2.printSchema)(schema);
181
181
  expect(schemaDSL).toMatchSnapshot();
182
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
- });
@@ -0,0 +1,9 @@
1
+ import { SchemaComposerParams } from '@ldsg/graphql';
2
+ import { FormInfo } from '../../types';
3
+ interface HandleFormInfoListParams extends SchemaComposerParams {
4
+ formInfoList: FormInfo[];
5
+ }
6
+ type HandleFormInfoList = (params: HandleFormInfoListParams) => void;
7
+ export declare const handleFormInfoList: HandleFormInfoList;
8
+ export {};
9
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/utils/handle-form-info-list/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,oBAAoB,EAAE,MAAM,eAAe,CAAC;AACrD,OAAO,EAAE,QAAQ,EAAE,MAAM,aAAa,CAAC;AAIvC,UAAU,wBAAyB,SAAQ,oBAAoB;IAC7D,YAAY,EAAE,QAAQ,EAAE,CAAC;CAC1B;AAED,KAAK,kBAAkB,GAAG,CAAC,MAAM,EAAE,wBAAwB,KAAK,IAAI,CAAC;AAErE,eAAO,MAAM,kBAAkB,EAAE,kBAmBhC,CAAC"}
@@ -0,0 +1,21 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.handleFormInfoList = void 0;
4
+ const get_input_itc_1 = require("./utils/get-input-itc");
5
+ const get_output_otc_1 = require("./utils/get-output-otc");
6
+ const handleFormInfoList = (params) => {
7
+ const { schemaComposer, formInfoList } = params;
8
+ formInfoList.forEach((formInfo) => {
9
+ const { inputObjectInfo, outputObjectInfo } = formInfo;
10
+ const { outputOTC } = (0, get_output_otc_1.getOutputOTC)({ schemaComposer, outputObjectInfo });
11
+ const { inputITC } = (0, get_input_itc_1.getInputITC)({ schemaComposer, inputObjectInfo });
12
+ outputOTC.addResolver({
13
+ name: 'submit',
14
+ type: outputOTC,
15
+ args: inputITC.getFields(),
16
+ resolve: undefined
17
+ });
18
+ schemaComposer.addSchemaMustHaveType(outputOTC);
19
+ });
20
+ };
21
+ exports.handleFormInfoList = handleFormInfoList;
@@ -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/handle-form-info-list/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,2BAyBzC,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/handle-form-info-list/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,CAAC,MAAM,EAAE,gCAAgC,KAAK,6BAA6B,CAAC;AAE9G,eAAO,MAAM,0BAA0B,EAAE,0BAuBxC,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/handle-form-info-list/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,CAAC,MAAM,EAAE,8BAA8B,KAAK,2BAA2B,CAAC;AAExG,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/handle-form-info-list/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,EAAE,iBAAiB,EAA+B,MAAM,iBAAiB,CAAC;AAGjF,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,WAuBzB,CAAC"}
@@ -0,0 +1,22 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.getInputITC = void 0;
4
+ const get_field_config_map_definition_1 = require("./get-field-config-map-definition");
5
+ const getInputITC = (params) => {
6
+ const { schemaComposer, inputObjectInfo } = params;
7
+ const { title, description, name, fieldInfoList } = inputObjectInfo;
8
+ const { fieldConfigMapDefinition } = (0, get_field_config_map_definition_1.getFieldConfigMapDefinition)({
9
+ fieldInfoList
10
+ });
11
+ const definition = {
12
+ name,
13
+ fields: fieldConfigMapDefinition
14
+ };
15
+ const inputITC = schemaComposer.createInputTC(definition);
16
+ inputITC.setDescription(`${title}${description ? `:${description}` : ''}`);
17
+ const res = {
18
+ inputITC
19
+ };
20
+ return res;
21
+ };
22
+ 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/handle-form-info-list/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,EAAE,kBAAkB,EAAgC,MAAM,iBAAiB,CAAC;AAGnF,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,YAuB1B,CAAC"}
@@ -0,0 +1,22 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.getOutputOTC = void 0;
4
+ const get_field_config_map_definition_1 = require("./get-field-config-map-definition");
5
+ const getOutputOTC = (params) => {
6
+ const { schemaComposer, outputObjectInfo } = params;
7
+ const { title, description, name, fieldInfoList } = outputObjectInfo;
8
+ const { fieldConfigMapDefinition } = (0, get_field_config_map_definition_1.getFieldConfigMapDefinition)({
9
+ fieldInfoList
10
+ });
11
+ const definition = {
12
+ name,
13
+ fields: fieldConfigMapDefinition
14
+ };
15
+ const outputOTC = schemaComposer.createObjectTC(definition);
16
+ outputOTC.setDescription(`${title}${description ? `:${description}` : ''}`);
17
+ const res = {
18
+ outputOTC
19
+ };
20
+ return res;
21
+ };
22
+ exports.getOutputOTC = getOutputOTC;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@ldsg/forms",
3
- "version": "0.3.23",
3
+ "version": "0.3.25",
4
4
  "description": "",
5
5
  "keywords": [],
6
6
  "license": "MIT",
@@ -14,10 +14,10 @@
14
14
  "@formily/json-schema": "^2.3.1",
15
15
  "json-schema": "^0.4.0",
16
16
  "lodash": "^4.17.21",
17
- "@ldsg/field-type": "0.3.23",
18
- "@ldsg/resource": "0.3.23",
19
- "@ldsg/resource-definition": "0.3.23",
20
- "@ldsg/handler": "0.3.23"
17
+ "@ldsg/field-type": "0.3.25",
18
+ "@ldsg/resource": "0.3.25",
19
+ "@ldsg/handler": "0.3.25",
20
+ "@ldsg/resource-definition": "0.3.25"
21
21
  },
22
22
  "devDependencies": {
23
23
  "@types/jest": "^29.5.2",
@@ -31,11 +31,11 @@
31
31
  "ts-jest": "^29.1.5",
32
32
  "ts-node": "^10.9.2",
33
33
  "typescript": "^5.8.3",
34
- "@ldsg/graphql": "0.3.23",
35
- "@ldsg/object-field": "0.3.23",
36
- "@ldsg/types": "0.3.23",
37
- "@ldsg/workflow": "0.3.23",
38
- "@ldsg/object": "0.3.23"
34
+ "@ldsg/graphql": "0.3.25",
35
+ "@ldsg/object": "0.3.25",
36
+ "@ldsg/object-field": "0.3.25",
37
+ "@ldsg/types": "0.3.25",
38
+ "@ldsg/workflow": "0.3.25"
39
39
  },
40
40
  "publishConfig": {
41
41
  "access": "public"
@@ -43,6 +43,6 @@
43
43
  "scripts": {
44
44
  "build": "tsc --project tsconfig.build.json",
45
45
  "clean": "rm -rf dist",
46
- "test": "jest"
46
+ "test": "jest --passWithNoTests"
47
47
  }
48
48
  }