@ldsg/forms 0.3.10 → 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/resource.d.ts.map +1 -1
- package/dist/resource.js +1 -5
- package/dist/test/__tests__/unit.js +98 -0
- package/dist/types/index.d.ts +1 -0
- 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/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/utils/get-output-otc.d.ts.map +1 -1
- package/dist/utils/get-new-fields/utils/get-output-otc.js +6 -0
- package/dist/utils/index.d.ts +1 -0
- package/dist/utils/index.d.ts.map +1 -1
- package/dist/utils/index.js +1 -0
- package/package.json +11 -7
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/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
|
@@ -32,15 +32,11 @@ class FormsResource extends resource_1.Resource {
|
|
|
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
38
|
schemaComposer
|
|
40
39
|
});
|
|
41
|
-
[Mutation, Query].forEach((value) => {
|
|
42
|
-
value.addFields(newFields);
|
|
43
|
-
});
|
|
44
40
|
};
|
|
45
41
|
}
|
|
46
42
|
}
|
|
@@ -180,3 +180,101 @@ 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
|
+
});
|
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);
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
import { ObjectInfo } from '@ldsg/object';
|
|
2
|
+
/**
|
|
3
|
+
* Extended ObjectInfo with JSON schemas for form queries
|
|
4
|
+
*/
|
|
5
|
+
export interface FormObjectInfo extends Omit<ObjectInfo, 'fieldInfoList'> {
|
|
6
|
+
/**
|
|
7
|
+
* List of field information
|
|
8
|
+
*/
|
|
9
|
+
fieldInfoList?: ObjectInfo['fieldInfoList'];
|
|
10
|
+
/**
|
|
11
|
+
* JSON Schema for the object
|
|
12
|
+
*/
|
|
13
|
+
jsonSchema?: any;
|
|
14
|
+
/**
|
|
15
|
+
* Formily JSON Schema for the object
|
|
16
|
+
*/
|
|
17
|
+
formilyJsonSchema?: any;
|
|
18
|
+
}
|
|
19
|
+
/**
|
|
20
|
+
* Form metadata returned by the forms query
|
|
21
|
+
*/
|
|
22
|
+
export interface FormMetadata {
|
|
23
|
+
/**
|
|
24
|
+
* Form name (used to query the form)
|
|
25
|
+
*/
|
|
26
|
+
name: string;
|
|
27
|
+
/**
|
|
28
|
+
* Human-readable form title
|
|
29
|
+
*/
|
|
30
|
+
title?: string;
|
|
31
|
+
/**
|
|
32
|
+
* Optional form description
|
|
33
|
+
*/
|
|
34
|
+
description?: string;
|
|
35
|
+
}
|
|
36
|
+
/**
|
|
37
|
+
* Detailed form information returned by the form query
|
|
38
|
+
* Includes input and output objects
|
|
39
|
+
*/
|
|
40
|
+
export interface FormDetail extends FormMetadata {
|
|
41
|
+
/**
|
|
42
|
+
* Input object information
|
|
43
|
+
*/
|
|
44
|
+
inputObjectInfo: FormObjectInfo;
|
|
45
|
+
/**
|
|
46
|
+
* Output object information
|
|
47
|
+
*/
|
|
48
|
+
outputObjectInfo: FormObjectInfo;
|
|
49
|
+
}
|
|
50
|
+
//# sourceMappingURL=query-types.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"query-types.d.ts","sourceRoot":"","sources":["../../src/types/query-types.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,cAAc,CAAC;AAE1C;;GAEG;AACH,MAAM,WAAW,cAAe,SAAQ,IAAI,CAAC,UAAU,EAAE,eAAe,CAAC;IACvE;;OAEG;IACH,aAAa,CAAC,EAAE,UAAU,CAAC,eAAe,CAAC,CAAC;IAE5C;;OAEG;IACH,UAAU,CAAC,EAAE,GAAG,CAAC;IAEjB;;OAEG;IACH,iBAAiB,CAAC,EAAE,GAAG,CAAC;CACzB;AAED;;GAEG;AACH,MAAM,WAAW,YAAY;IAC3B;;OAEG;IACH,IAAI,EAAE,MAAM,CAAC;IAEb;;OAEG;IACH,KAAK,CAAC,EAAE,MAAM,CAAC;IAEf;;OAEG;IACH,WAAW,CAAC,EAAE,MAAM,CAAC;CACtB;AAED;;;GAGG;AACH,MAAM,WAAW,UAAW,SAAQ,YAAY;IAC9C;;OAEG;IACH,eAAe,EAAE,cAAc,CAAC;IAEhC;;OAEG;IACH,gBAAgB,EAAE,cAAc,CAAC;CAClC"}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { SchemaComposerParams } from '@ldsg/graphql';
|
|
2
|
+
import { FormInfo } from '../../types';
|
|
3
|
+
export interface AddQueryFieldsParams extends SchemaComposerParams {
|
|
4
|
+
formInfoList: FormInfo[];
|
|
5
|
+
}
|
|
6
|
+
/**
|
|
7
|
+
* Adds `form` and `forms` query fields to the GraphQL schema
|
|
8
|
+
*/
|
|
9
|
+
export declare function addQueryFields(params: AddQueryFieldsParams): void;
|
|
10
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/utils/add-query-fields/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,oBAAoB,EAAE,MAAM,eAAe,CAAC;AACrD,OAAO,EAAE,QAAQ,EAAE,MAAM,aAAa,CAAC;AAIvC,MAAM,WAAW,oBAAqB,SAAQ,oBAAoB;IAChE,YAAY,EAAE,QAAQ,EAAE,CAAC;CAC1B;AAED;;GAEG;AACH,wBAAgB,cAAc,CAAC,MAAM,EAAE,oBAAoB,GAAG,IAAI,CAqBjE"}
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.addQueryFields = addQueryFields;
|
|
4
|
+
const create_types_1 = require("./utils/create-types");
|
|
5
|
+
const create_resolvers_1 = require("./utils/create-resolvers");
|
|
6
|
+
/**
|
|
7
|
+
* Adds `form` and `forms` query fields to the GraphQL schema
|
|
8
|
+
*/
|
|
9
|
+
function addQueryFields(params) {
|
|
10
|
+
const { schemaComposer, formInfoList } = params;
|
|
11
|
+
const { Query } = schemaComposer;
|
|
12
|
+
// Create GraphQL types
|
|
13
|
+
const formDetailTC = (0, create_types_1.createFormDetailTC)(schemaComposer);
|
|
14
|
+
const formMetadataTC = (0, create_types_1.createFormMetadataTC)(schemaComposer);
|
|
15
|
+
// Add the types to the schema
|
|
16
|
+
schemaComposer.addSchemaMustHaveType(formDetailTC);
|
|
17
|
+
schemaComposer.addSchemaMustHaveType(formMetadataTC);
|
|
18
|
+
// Create resolvers
|
|
19
|
+
const formResolver = (0, create_resolvers_1.createFormResolver)(formInfoList);
|
|
20
|
+
const formsResolver = (0, create_resolvers_1.createFormsResolver)(formInfoList);
|
|
21
|
+
// Add fields to Query type
|
|
22
|
+
Query.addFields({
|
|
23
|
+
form: formResolver,
|
|
24
|
+
forms: formsResolver
|
|
25
|
+
});
|
|
26
|
+
}
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import { FormInfo } from '../../../types';
|
|
2
|
+
/**
|
|
3
|
+
* Creates a resolver definition for querying a single form by name
|
|
4
|
+
*/
|
|
5
|
+
export declare function createFormResolver(formInfoList: FormInfo[]): {
|
|
6
|
+
name: string;
|
|
7
|
+
type: string;
|
|
8
|
+
args: {
|
|
9
|
+
name: string;
|
|
10
|
+
};
|
|
11
|
+
resolve: (_root: any, args: any) => Promise<import("../../../types").FormDetail>;
|
|
12
|
+
};
|
|
13
|
+
/**
|
|
14
|
+
* Creates a resolver definition for querying all forms
|
|
15
|
+
*/
|
|
16
|
+
export declare function createFormsResolver(formInfoList: FormInfo[]): {
|
|
17
|
+
name: string;
|
|
18
|
+
type: string;
|
|
19
|
+
resolve: () => Promise<import("../../../types").FormMetadata[]>;
|
|
20
|
+
};
|
|
21
|
+
//# sourceMappingURL=create-resolvers.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"create-resolvers.d.ts","sourceRoot":"","sources":["../../../../src/utils/add-query-fields/utils/create-resolvers.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,MAAM,gBAAgB,CAAC;AAG1C;;GAEG;AACH,wBAAgB,kBAAkB,CAAC,YAAY,EAAE,QAAQ,EAAE;;;;;;qBAOhC,GAAG,QAAQ,GAAG;EAWxC;AAED;;GAEG;AACH,wBAAgB,mBAAmB,CAAC,YAAY,EAAE,QAAQ,EAAE;;;;EAQ3D"}
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.createFormResolver = createFormResolver;
|
|
4
|
+
exports.createFormsResolver = createFormsResolver;
|
|
5
|
+
const map_form_info_1 = require("./map-form-info");
|
|
6
|
+
/**
|
|
7
|
+
* Creates a resolver definition for querying a single form by name
|
|
8
|
+
*/
|
|
9
|
+
function createFormResolver(formInfoList) {
|
|
10
|
+
return {
|
|
11
|
+
name: 'form',
|
|
12
|
+
type: 'FormDetail',
|
|
13
|
+
args: {
|
|
14
|
+
name: 'String!'
|
|
15
|
+
},
|
|
16
|
+
resolve: async (_root, args) => {
|
|
17
|
+
const { name } = args;
|
|
18
|
+
const formInfo = formInfoList.find((f) => f.name === name);
|
|
19
|
+
if (!formInfo) {
|
|
20
|
+
throw new Error(`Form not found: ${name}`);
|
|
21
|
+
}
|
|
22
|
+
return (0, map_form_info_1.mapFormInfoToDetail)(formInfo);
|
|
23
|
+
}
|
|
24
|
+
};
|
|
25
|
+
}
|
|
26
|
+
/**
|
|
27
|
+
* Creates a resolver definition for querying all forms
|
|
28
|
+
*/
|
|
29
|
+
function createFormsResolver(formInfoList) {
|
|
30
|
+
return {
|
|
31
|
+
name: 'forms',
|
|
32
|
+
type: '[FormMetadata!]!',
|
|
33
|
+
resolve: async () => {
|
|
34
|
+
return formInfoList.map((f) => (0, map_form_info_1.mapFormInfoToMetadata)(f));
|
|
35
|
+
}
|
|
36
|
+
};
|
|
37
|
+
}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { ObjectTypeComposer, SchemaComposer } from 'graphql-compose';
|
|
2
|
+
/**
|
|
3
|
+
* Creates GraphQL type for FormMetadata
|
|
4
|
+
*/
|
|
5
|
+
export declare function createFormMetadataTC(schemaComposer: SchemaComposer): ObjectTypeComposer<any, any>;
|
|
6
|
+
/**
|
|
7
|
+
* Creates GraphQL type for FormDetail
|
|
8
|
+
*/
|
|
9
|
+
export declare function createFormDetailTC(schemaComposer: SchemaComposer): ObjectTypeComposer<any, any>;
|
|
10
|
+
//# sourceMappingURL=create-types.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"create-types.d.ts","sourceRoot":"","sources":["../../../../src/utils/add-query-fields/utils/create-types.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,kBAAkB,EAAE,cAAc,EAAE,MAAM,iBAAiB,CAAC;AAyCrE;;GAEG;AACH,wBAAgB,oBAAoB,CAAC,cAAc,EAAE,cAAc,GAAG,kBAAkB,CAAC,GAAG,EAAE,GAAG,CAAC,CAsBjG;AAED;;GAEG;AACH,wBAAgB,kBAAkB,CAAC,cAAc,EAAE,cAAc,GAAG,kBAAkB,CAAC,GAAG,EAAE,GAAG,CAAC,CAgC/F"}
|
|
@@ -0,0 +1,100 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.createFormMetadataTC = createFormMetadataTC;
|
|
4
|
+
exports.createFormDetailTC = createFormDetailTC;
|
|
5
|
+
/**
|
|
6
|
+
* Creates GraphQL type for ObjectInfo (used in inputObject and outputObject)
|
|
7
|
+
*/
|
|
8
|
+
function createObjectInfoTC(schemaComposer) {
|
|
9
|
+
if (schemaComposer.has('FormObjectInfo')) {
|
|
10
|
+
return schemaComposer.getOTC('FormObjectInfo');
|
|
11
|
+
}
|
|
12
|
+
return schemaComposer.createObjectTC({
|
|
13
|
+
name: 'FormObjectInfo',
|
|
14
|
+
fields: {
|
|
15
|
+
name: {
|
|
16
|
+
type: 'String',
|
|
17
|
+
description: 'Object name'
|
|
18
|
+
},
|
|
19
|
+
title: {
|
|
20
|
+
type: 'String',
|
|
21
|
+
description: 'Object title'
|
|
22
|
+
},
|
|
23
|
+
description: {
|
|
24
|
+
type: 'String',
|
|
25
|
+
description: 'Object description'
|
|
26
|
+
},
|
|
27
|
+
fieldInfoList: {
|
|
28
|
+
type: 'JSON',
|
|
29
|
+
description: 'List of field information'
|
|
30
|
+
},
|
|
31
|
+
jsonSchema: {
|
|
32
|
+
type: 'JSON',
|
|
33
|
+
description: 'JSON Schema for the object'
|
|
34
|
+
},
|
|
35
|
+
formilyJsonSchema: {
|
|
36
|
+
type: 'JSON',
|
|
37
|
+
description: 'Formily JSON Schema for the object'
|
|
38
|
+
}
|
|
39
|
+
}
|
|
40
|
+
});
|
|
41
|
+
}
|
|
42
|
+
/**
|
|
43
|
+
* Creates GraphQL type for FormMetadata
|
|
44
|
+
*/
|
|
45
|
+
function createFormMetadataTC(schemaComposer) {
|
|
46
|
+
if (schemaComposer.has('FormMetadata')) {
|
|
47
|
+
return schemaComposer.getOTC('FormMetadata');
|
|
48
|
+
}
|
|
49
|
+
return schemaComposer.createObjectTC({
|
|
50
|
+
name: 'FormMetadata',
|
|
51
|
+
fields: {
|
|
52
|
+
name: {
|
|
53
|
+
type: 'String!',
|
|
54
|
+
description: 'Form name'
|
|
55
|
+
},
|
|
56
|
+
title: {
|
|
57
|
+
type: 'String',
|
|
58
|
+
description: 'Human-readable form title'
|
|
59
|
+
},
|
|
60
|
+
description: {
|
|
61
|
+
type: 'String',
|
|
62
|
+
description: 'Optional form description'
|
|
63
|
+
}
|
|
64
|
+
}
|
|
65
|
+
});
|
|
66
|
+
}
|
|
67
|
+
/**
|
|
68
|
+
* Creates GraphQL type for FormDetail
|
|
69
|
+
*/
|
|
70
|
+
function createFormDetailTC(schemaComposer) {
|
|
71
|
+
if (schemaComposer.has('FormDetail')) {
|
|
72
|
+
return schemaComposer.getOTC('FormDetail');
|
|
73
|
+
}
|
|
74
|
+
const objectInfoTC = createObjectInfoTC(schemaComposer);
|
|
75
|
+
return schemaComposer.createObjectTC({
|
|
76
|
+
name: 'FormDetail',
|
|
77
|
+
fields: {
|
|
78
|
+
name: {
|
|
79
|
+
type: 'String!',
|
|
80
|
+
description: 'Form name'
|
|
81
|
+
},
|
|
82
|
+
title: {
|
|
83
|
+
type: 'String',
|
|
84
|
+
description: 'Human-readable form title'
|
|
85
|
+
},
|
|
86
|
+
description: {
|
|
87
|
+
type: 'String',
|
|
88
|
+
description: 'Optional form description'
|
|
89
|
+
},
|
|
90
|
+
inputObjectInfo: {
|
|
91
|
+
type: objectInfoTC,
|
|
92
|
+
description: 'Input object information'
|
|
93
|
+
},
|
|
94
|
+
outputObjectInfo: {
|
|
95
|
+
type: objectInfoTC,
|
|
96
|
+
description: 'Output object information'
|
|
97
|
+
}
|
|
98
|
+
}
|
|
99
|
+
});
|
|
100
|
+
}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { FieldInfo } from '@ldsg/object';
|
|
2
|
+
/**
|
|
3
|
+
* Generates JSON Schema for an object from its field info list
|
|
4
|
+
*/
|
|
5
|
+
export declare function getJsonSchemaByFieldInfoList(fieldInfoList: FieldInfo[]): any;
|
|
6
|
+
/**
|
|
7
|
+
* Generates Formily JSON Schema for an object from its field info list
|
|
8
|
+
* Falls back to JSON Schema for individual fields if Formily schema is not available
|
|
9
|
+
*/
|
|
10
|
+
export declare function getFormilyJsonSchemaByFieldInfoList(fieldInfoList: FieldInfo[]): any;
|
|
11
|
+
//# sourceMappingURL=get-json-schema.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"get-json-schema.d.ts","sourceRoot":"","sources":["../../../../src/utils/add-query-fields/utils/get-json-schema.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,SAAS,EAAE,MAAM,cAAc,CAAC;AA0DzC;;GAEG;AACH,wBAAgB,4BAA4B,CAAC,aAAa,EAAE,SAAS,EAAE,GAAG,GAAG,CAmB5E;AAED;;;GAGG;AACH,wBAAgB,mCAAmC,CAAC,aAAa,EAAE,SAAS,EAAE,GAAG,GAAG,CAqBnF"}
|
|
@@ -0,0 +1,90 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.getJsonSchemaByFieldInfoList = getJsonSchemaByFieldInfoList;
|
|
4
|
+
exports.getFormilyJsonSchemaByFieldInfoList = getFormilyJsonSchemaByFieldInfoList;
|
|
5
|
+
const json_schema_1 = require("@formily/json-schema");
|
|
6
|
+
const field_type_1 = require("@ldsg/field-type");
|
|
7
|
+
const get_schema_for_formily_1 = require("./get-schema-for-formily");
|
|
8
|
+
/**
|
|
9
|
+
* Generates JSON Schema for a field based on its type info
|
|
10
|
+
*/
|
|
11
|
+
function getJsonSchemaForField(fieldInfo) {
|
|
12
|
+
const { typeInfo } = fieldInfo;
|
|
13
|
+
const { platformToTypeMap } = typeInfo;
|
|
14
|
+
// Try to get JSON schema from platform-specific type map
|
|
15
|
+
const jsonSchema = platformToTypeMap[field_type_1.FieldTypeBasePlatform.JSON_SCHEMA];
|
|
16
|
+
if (jsonSchema) {
|
|
17
|
+
return jsonSchema;
|
|
18
|
+
}
|
|
19
|
+
// Fallback: generate basic schema based on common type
|
|
20
|
+
const commonType = platformToTypeMap[field_type_1.FieldTypeBasePlatform.COMMON];
|
|
21
|
+
if (!commonType) {
|
|
22
|
+
return {
|
|
23
|
+
type: 'string',
|
|
24
|
+
title: fieldInfo.title || fieldInfo.name
|
|
25
|
+
};
|
|
26
|
+
}
|
|
27
|
+
// Basic type mapping
|
|
28
|
+
const typeMap = {
|
|
29
|
+
string: { type: 'string', title: fieldInfo.title || fieldInfo.name },
|
|
30
|
+
number: { type: 'number', title: fieldInfo.title || fieldInfo.name },
|
|
31
|
+
boolean: { type: 'boolean', title: fieldInfo.title || fieldInfo.name },
|
|
32
|
+
array: { type: 'array', title: fieldInfo.title || fieldInfo.name },
|
|
33
|
+
object: { type: 'object', title: fieldInfo.title || fieldInfo.name }
|
|
34
|
+
};
|
|
35
|
+
return typeMap[commonType] || { type: 'string', title: fieldInfo.title || fieldInfo.name };
|
|
36
|
+
}
|
|
37
|
+
/**
|
|
38
|
+
* Generates Formily JSON Schema for a field based on its type info
|
|
39
|
+
* Falls back to JSON Schema if Formily schema is not available
|
|
40
|
+
*/
|
|
41
|
+
function getFormilyJsonSchemaForField(fieldInfo) {
|
|
42
|
+
const { title, description, typeInfo } = fieldInfo;
|
|
43
|
+
const { platformToTypeMap } = typeInfo;
|
|
44
|
+
let res = platformToTypeMap[field_type_1.FieldTypeBasePlatform.FORMILY_JSON_SCHEMA];
|
|
45
|
+
if (!res) {
|
|
46
|
+
const commonType = platformToTypeMap[field_type_1.FieldTypeBasePlatform.COMMON];
|
|
47
|
+
res = { ...commonType, title, description };
|
|
48
|
+
}
|
|
49
|
+
return res;
|
|
50
|
+
}
|
|
51
|
+
/**
|
|
52
|
+
* Generates JSON Schema for an object from its field info list
|
|
53
|
+
*/
|
|
54
|
+
function getJsonSchemaByFieldInfoList(fieldInfoList) {
|
|
55
|
+
const properties = {};
|
|
56
|
+
const required = [];
|
|
57
|
+
fieldInfoList.forEach((fieldInfo) => {
|
|
58
|
+
const schema = getJsonSchemaForField(fieldInfo);
|
|
59
|
+
properties[fieldInfo.name] = schema;
|
|
60
|
+
// Add to required if field is mandatory (check if there's a required flag)
|
|
61
|
+
// This assumes there might be a 'required' property in fieldInfo or typeInfo
|
|
62
|
+
if (fieldInfo.required) {
|
|
63
|
+
required.push(fieldInfo.name);
|
|
64
|
+
}
|
|
65
|
+
});
|
|
66
|
+
return {
|
|
67
|
+
type: 'object',
|
|
68
|
+
properties
|
|
69
|
+
};
|
|
70
|
+
}
|
|
71
|
+
/**
|
|
72
|
+
* Generates Formily JSON Schema for an object from its field info list
|
|
73
|
+
* Falls back to JSON Schema for individual fields if Formily schema is not available
|
|
74
|
+
*/
|
|
75
|
+
function getFormilyJsonSchemaByFieldInfoList(fieldInfoList) {
|
|
76
|
+
const properties = {};
|
|
77
|
+
fieldInfoList.forEach((fieldInfo) => {
|
|
78
|
+
const formilySchema = getFormilyJsonSchemaForField(fieldInfo);
|
|
79
|
+
properties[fieldInfo.name] = formilySchema;
|
|
80
|
+
});
|
|
81
|
+
const schema = new json_schema_1.Schema({
|
|
82
|
+
type: 'object',
|
|
83
|
+
properties
|
|
84
|
+
});
|
|
85
|
+
const { schemaForFormily } = (0, get_schema_for_formily_1.getSchemaForFormily)({
|
|
86
|
+
schema
|
|
87
|
+
});
|
|
88
|
+
const res = schemaForFormily;
|
|
89
|
+
return res;
|
|
90
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"constants.d.ts","sourceRoot":"","sources":["../../../../../src/utils/add-query-fields/utils/get-schema-for-formily/constants.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,WAAW,EAAE,MAAM,sBAAsB,CAAC;AAE5D,eAAO,MAAM,aAAa,EAAE,OAAO,CAAC,MAAM,CAAC,WAAW,EAAE,OAAO,CAAC,CAyB/D,CAAC"}
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.SchemaTypeMap = void 0;
|
|
4
|
+
exports.SchemaTypeMap = {
|
|
5
|
+
boolean: {
|
|
6
|
+
'x-decorator': 'FormItem',
|
|
7
|
+
'x-component': 'Checkbox'
|
|
8
|
+
},
|
|
9
|
+
integer: {
|
|
10
|
+
'x-decorator': 'FormItem',
|
|
11
|
+
'x-component': 'NumberPicker'
|
|
12
|
+
},
|
|
13
|
+
number: {
|
|
14
|
+
'x-decorator': 'FormItem',
|
|
15
|
+
'x-component': 'NumberPicker'
|
|
16
|
+
},
|
|
17
|
+
object: {},
|
|
18
|
+
objectWithoutProperties: {
|
|
19
|
+
'x-decorator': 'FormItem',
|
|
20
|
+
'x-component': 'JsonInput'
|
|
21
|
+
},
|
|
22
|
+
string: {
|
|
23
|
+
'x-decorator': 'FormItem',
|
|
24
|
+
'x-component': 'Input'
|
|
25
|
+
},
|
|
26
|
+
array: {
|
|
27
|
+
'x-decorator': 'FormItem'
|
|
28
|
+
}
|
|
29
|
+
};
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { Schema } from '@formily/json-schema';
|
|
2
|
+
interface GetSchemaForFormilyParams {
|
|
3
|
+
schema: Schema;
|
|
4
|
+
}
|
|
5
|
+
interface GetSchemaForFormilyRes {
|
|
6
|
+
schemaForFormily: Schema;
|
|
7
|
+
}
|
|
8
|
+
type GetSchemaForFormily = (params: GetSchemaForFormilyParams) => GetSchemaForFormilyRes;
|
|
9
|
+
export declare const getSchemaForFormily: GetSchemaForFormily;
|
|
10
|
+
export {};
|
|
11
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../../src/utils/add-query-fields/utils/get-schema-for-formily/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,MAAM,sBAAsB,CAAC;AAG9C,UAAU,yBAAyB;IACjC,MAAM,EAAE,MAAM,CAAC;CAChB;AAED,UAAU,sBAAsB;IAC9B,gBAAgB,EAAE,MAAM,CAAC;CAC1B;AAED,KAAK,mBAAmB,GAAG,CAAC,MAAM,EAAE,yBAAyB,KAAK,sBAAsB,CAAC;AAEzF,eAAO,MAAM,mBAAmB,EAAE,mBAYjC,CAAC"}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.getSchemaForFormily = void 0;
|
|
4
|
+
const process_object_schema_1 = require("./utils/process-object-schema");
|
|
5
|
+
const getSchemaForFormily = (params) => {
|
|
6
|
+
const { schema } = params;
|
|
7
|
+
(0, process_object_schema_1.processObjectSchema)({
|
|
8
|
+
schema
|
|
9
|
+
});
|
|
10
|
+
const res = {
|
|
11
|
+
schemaForFormily: schema
|
|
12
|
+
};
|
|
13
|
+
return res;
|
|
14
|
+
};
|
|
15
|
+
exports.getSchemaForFormily = getSchemaForFormily;
|
package/dist/utils/add-query-fields/utils/get-schema-for-formily/utils/process-object-schema.d.ts
ADDED
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import { Schema } from '@formily/json-schema';
|
|
2
|
+
interface ProcessObjectSchemaParams {
|
|
3
|
+
schema: Schema;
|
|
4
|
+
}
|
|
5
|
+
type ProcessObjectSchema = (params: ProcessObjectSchemaParams) => void;
|
|
6
|
+
export declare const processObjectSchema: ProcessObjectSchema;
|
|
7
|
+
export {};
|
|
8
|
+
//# sourceMappingURL=process-object-schema.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"process-object-schema.d.ts","sourceRoot":"","sources":["../../../../../../src/utils/add-query-fields/utils/get-schema-for-formily/utils/process-object-schema.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,MAAM,sBAAsB,CAAC;AAI9C,UAAU,yBAAyB;IACjC,MAAM,EAAE,MAAM,CAAC;CAChB;AAED,KAAK,mBAAmB,GAAG,CAAC,MAAM,EAAE,yBAAyB,KAAK,IAAI,CAAC;AAEvE,eAAO,MAAM,mBAAmB,EAAE,mBA2CjC,CAAC"}
|
package/dist/utils/add-query-fields/utils/get-schema-for-formily/utils/process-object-schema.js
ADDED
|
@@ -0,0 +1,44 @@
|
|
|
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.processObjectSchema = void 0;
|
|
7
|
+
const lodash_1 = __importDefault(require("lodash"));
|
|
8
|
+
const constants_1 = require("../constants");
|
|
9
|
+
const processObjectSchema = (params) => {
|
|
10
|
+
const { schema } = params;
|
|
11
|
+
const { type, properties } = schema;
|
|
12
|
+
switch (type) {
|
|
13
|
+
case 'object': {
|
|
14
|
+
if (properties && lodash_1.default.keys(properties).length) {
|
|
15
|
+
const schemaTypeMapValue = constants_1.SchemaTypeMap['object'];
|
|
16
|
+
lodash_1.default.defaults(schema, schemaTypeMapValue);
|
|
17
|
+
schema.mapProperties((property) => {
|
|
18
|
+
(0, exports.processObjectSchema)({
|
|
19
|
+
schema: property
|
|
20
|
+
});
|
|
21
|
+
});
|
|
22
|
+
}
|
|
23
|
+
else {
|
|
24
|
+
const schemaTypeMapValue = constants_1.SchemaTypeMap['objectWithoutProperties'];
|
|
25
|
+
lodash_1.default.defaults(schema, schemaTypeMapValue);
|
|
26
|
+
}
|
|
27
|
+
break;
|
|
28
|
+
}
|
|
29
|
+
default: {
|
|
30
|
+
if (schema.enum && schema.enum.length && !schema['x-component']) {
|
|
31
|
+
/**
|
|
32
|
+
* TODO:应改成 Select,但在此 react 版本中 Select 功能异常
|
|
33
|
+
*/
|
|
34
|
+
schema['x-component'] = 'Radio.Group';
|
|
35
|
+
}
|
|
36
|
+
const schemaTypeMapValue = constants_1.SchemaTypeMap[type];
|
|
37
|
+
if (schemaTypeMapValue) {
|
|
38
|
+
lodash_1.default.defaults(schema, schemaTypeMapValue);
|
|
39
|
+
}
|
|
40
|
+
break;
|
|
41
|
+
}
|
|
42
|
+
}
|
|
43
|
+
};
|
|
44
|
+
exports.processObjectSchema = processObjectSchema;
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { FormInfo } from '../../../types';
|
|
2
|
+
import { FormDetail, FormMetadata } from '../../../types/query-types';
|
|
3
|
+
/**
|
|
4
|
+
* Maps FormInfo to FormMetadata (lightweight version without schemas)
|
|
5
|
+
*/
|
|
6
|
+
export declare function mapFormInfoToMetadata(formInfo: FormInfo): FormMetadata;
|
|
7
|
+
/**
|
|
8
|
+
* Maps FormInfo to FormDetail (includes schemas)
|
|
9
|
+
*/
|
|
10
|
+
export declare function mapFormInfoToDetail(formInfo: FormInfo): FormDetail;
|
|
11
|
+
//# sourceMappingURL=map-form-info.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"map-form-info.d.ts","sourceRoot":"","sources":["../../../../src/utils/add-query-fields/utils/map-form-info.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,MAAM,gBAAgB,CAAC;AAC1C,OAAO,EAAE,UAAU,EAAE,YAAY,EAAE,MAAM,4BAA4B,CAAC;AAGtE;;GAEG;AACH,wBAAgB,qBAAqB,CAAC,QAAQ,EAAE,QAAQ,GAAG,YAAY,CAMtE;AAED;;GAEG;AACH,wBAAgB,mBAAmB,CAAC,QAAQ,EAAE,QAAQ,GAAG,UAAU,CA0BlE"}
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.mapFormInfoToMetadata = mapFormInfoToMetadata;
|
|
4
|
+
exports.mapFormInfoToDetail = mapFormInfoToDetail;
|
|
5
|
+
const get_json_schema_1 = require("./get-json-schema");
|
|
6
|
+
/**
|
|
7
|
+
* Maps FormInfo to FormMetadata (lightweight version without schemas)
|
|
8
|
+
*/
|
|
9
|
+
function mapFormInfoToMetadata(formInfo) {
|
|
10
|
+
return {
|
|
11
|
+
name: formInfo.name,
|
|
12
|
+
title: formInfo.title,
|
|
13
|
+
description: formInfo.description
|
|
14
|
+
};
|
|
15
|
+
}
|
|
16
|
+
/**
|
|
17
|
+
* Maps FormInfo to FormDetail (includes schemas)
|
|
18
|
+
*/
|
|
19
|
+
function mapFormInfoToDetail(formInfo) {
|
|
20
|
+
const { inputObjectInfo, outputObjectInfo } = formInfo;
|
|
21
|
+
// Generate JSON schemas for input object
|
|
22
|
+
const inputJsonSchema = (0, get_json_schema_1.getJsonSchemaByFieldInfoList)(inputObjectInfo.fieldInfoList);
|
|
23
|
+
const inputFormilyJsonSchema = (0, get_json_schema_1.getFormilyJsonSchemaByFieldInfoList)(inputObjectInfo.fieldInfoList);
|
|
24
|
+
// Generate JSON schemas for output object
|
|
25
|
+
const outputJsonSchema = (0, get_json_schema_1.getJsonSchemaByFieldInfoList)(outputObjectInfo.fieldInfoList);
|
|
26
|
+
const outputFormilyJsonSchema = (0, get_json_schema_1.getFormilyJsonSchemaByFieldInfoList)(outputObjectInfo.fieldInfoList);
|
|
27
|
+
return {
|
|
28
|
+
name: formInfo.name,
|
|
29
|
+
title: formInfo.title,
|
|
30
|
+
description: formInfo.description,
|
|
31
|
+
inputObjectInfo: {
|
|
32
|
+
...inputObjectInfo,
|
|
33
|
+
jsonSchema: inputJsonSchema,
|
|
34
|
+
formilyJsonSchema: inputFormilyJsonSchema
|
|
35
|
+
},
|
|
36
|
+
outputObjectInfo: {
|
|
37
|
+
...outputObjectInfo,
|
|
38
|
+
jsonSchema: outputJsonSchema,
|
|
39
|
+
formilyJsonSchema: outputFormilyJsonSchema
|
|
40
|
+
}
|
|
41
|
+
};
|
|
42
|
+
}
|
|
@@ -1 +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,EAAE,kBAAkB,EAAgC,MAAM,iBAAiB,CAAC;AAInF,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,
|
|
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,EAAE,kBAAkB,EAAgC,MAAM,iBAAiB,CAAC;AAInF,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,YAgC1B,CAAC"}
|
|
@@ -19,6 +19,12 @@ const getOutputOTC = (params) => {
|
|
|
19
19
|
};
|
|
20
20
|
const outputOTC = schemaComposer.createObjectTC(definition);
|
|
21
21
|
outputOTC.setDescription(`${title}${description ? `:${description}` : ''}`);
|
|
22
|
+
outputOTC.addResolver({
|
|
23
|
+
name: 'submit',
|
|
24
|
+
type: outputOTC,
|
|
25
|
+
args: outputOTC.getInputTypeComposer().getFields(),
|
|
26
|
+
resolve: undefined
|
|
27
|
+
});
|
|
22
28
|
const res = {
|
|
23
29
|
outputOTC
|
|
24
30
|
};
|
package/dist/utils/index.d.ts
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/utils/index.ts"],"names":[],"mappings":"AAAA,cAAc,kBAAkB,CAAC"}
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/utils/index.ts"],"names":[],"mappings":"AAAA,cAAc,oBAAoB,CAAC;AACnC,cAAc,kBAAkB,CAAC"}
|
package/dist/utils/index.js
CHANGED
|
@@ -14,4 +14,5 @@ var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
|
14
14
|
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
15
15
|
};
|
|
16
16
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
|
+
__exportStar(require("./add-query-fields"), exports);
|
|
17
18
|
__exportStar(require("./get-new-fields"), exports);
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@ldsg/forms",
|
|
3
|
-
"version": "0.3.
|
|
3
|
+
"version": "0.3.11",
|
|
4
4
|
"description": "",
|
|
5
5
|
"keywords": [],
|
|
6
6
|
"license": "MIT",
|
|
@@ -11,14 +11,17 @@
|
|
|
11
11
|
"dist/"
|
|
12
12
|
],
|
|
13
13
|
"dependencies": {
|
|
14
|
+
"@formily/json-schema": "^2.3.1",
|
|
15
|
+
"json-schema": "^0.4.0",
|
|
14
16
|
"lodash": "^4.17.21",
|
|
15
17
|
"@ldsg/field-type": "0.3.10",
|
|
18
|
+
"@ldsg/handler": "0.3.10",
|
|
16
19
|
"@ldsg/resource-definition": "0.3.10",
|
|
17
|
-
"@ldsg/resource": "0.3.10"
|
|
18
|
-
"@ldsg/handler": "0.3.10"
|
|
20
|
+
"@ldsg/resource": "0.3.10"
|
|
19
21
|
},
|
|
20
22
|
"devDependencies": {
|
|
21
23
|
"@types/jest": "^29.5.2",
|
|
24
|
+
"@types/json-schema": "^7.0.15",
|
|
22
25
|
"@types/lodash": "^4.14.202",
|
|
23
26
|
"@types/supertest": "^6.0.0",
|
|
24
27
|
"graphql": "16.11.0",
|
|
@@ -28,17 +31,18 @@
|
|
|
28
31
|
"ts-jest": "^29.1.5",
|
|
29
32
|
"ts-node": "^10.9.2",
|
|
30
33
|
"typescript": "^5.8.3",
|
|
31
|
-
"@ldsg/graphql": "0.3.
|
|
34
|
+
"@ldsg/graphql": "0.3.11",
|
|
32
35
|
"@ldsg/object": "0.3.10",
|
|
33
|
-
"@ldsg/workflow": "0.3.10",
|
|
34
36
|
"@ldsg/object-field": "0.3.10",
|
|
35
|
-
"@ldsg/types": "0.3.10"
|
|
37
|
+
"@ldsg/types": "0.3.10",
|
|
38
|
+
"@ldsg/workflow": "0.3.11"
|
|
36
39
|
},
|
|
37
40
|
"publishConfig": {
|
|
38
41
|
"access": "public"
|
|
39
42
|
},
|
|
40
43
|
"scripts": {
|
|
41
44
|
"build": "tsc --project tsconfig.build.json",
|
|
42
|
-
"clean": "rm -rf dist"
|
|
45
|
+
"clean": "rm -rf dist",
|
|
46
|
+
"test": "jest"
|
|
43
47
|
}
|
|
44
48
|
}
|