@ldsg/forms 0.3.38 → 0.3.40

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.
@@ -15,4 +15,5 @@ export declare const INSTANTIATE_RESOURCE_HANDLER_SPECIFIC_RESOURCE_SETTINGS: Ha
15
15
  export declare const RESOURCE_DEFINITION_GENERAL_RESOURCE_SETTINGS: GeneralResourceSettings;
16
16
  export declare const RESOURCE_DEFINITION_SPECIFIC_RESOURCE_SETTINGS: ResourceDefinitionSpecificResourceSettings;
17
17
  export declare const FORMS_ROUTE = "/forms";
18
+ export declare const FORM_RESOLVER_NAME = "submit";
18
19
  //# sourceMappingURL=constants.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"constants.d.ts","sourceRoot":"","sources":["../src/constants.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,+BAA+B,EAAE,MAAM,eAAe,CAAC;AAChE,OAAO,EAAE,0CAA0C,EAAE,MAAM,2BAA2B,CAAC;AACvF,OAAO,EAAE,uBAAuB,EAAE,MAAM,aAAa,CAAC;AAEtD;;;GAGG;AACH,eAAO,MAAM,sDAAsD,EAAE,uBAGpE,CAAC;AAEF;;;;GAIG;AACH,eAAO,MAAM,uDAAuD,EAAE,+BAQnE,CAAC;AAEJ,eAAO,MAAM,6CAA6C,EAAE,uBAG3D,CAAC;AAEF,eAAO,MAAM,8CAA8C,EAAE,0CAG1D,CAAC;AAEJ,eAAO,MAAM,WAAW,WAAW,CAAC"}
1
+ {"version":3,"file":"constants.d.ts","sourceRoot":"","sources":["../src/constants.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,+BAA+B,EAAE,MAAM,eAAe,CAAC;AAChE,OAAO,EAAE,0CAA0C,EAAE,MAAM,2BAA2B,CAAC;AACvF,OAAO,EAAE,uBAAuB,EAAE,MAAM,aAAa,CAAC;AAEtD;;;GAGG;AACH,eAAO,MAAM,sDAAsD,EAAE,uBAIpE,CAAC;AAEF;;;;GAIG;AACH,eAAO,MAAM,uDAAuD,EAAE,+BAQnE,CAAC;AAEJ,eAAO,MAAM,6CAA6C,EAAE,uBAI3D,CAAC;AAEF,eAAO,MAAM,8CAA8C,EAAE,0CAG1D,CAAC;AAEJ,eAAO,MAAM,WAAW,WAAW,CAAC;AAEpC,eAAO,MAAM,kBAAkB,WAAW,CAAC"}
package/dist/constants.js CHANGED
@@ -1,11 +1,12 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.FORMS_ROUTE = exports.RESOURCE_DEFINITION_SPECIFIC_RESOURCE_SETTINGS = exports.RESOURCE_DEFINITION_GENERAL_RESOURCE_SETTINGS = exports.INSTANTIATE_RESOURCE_HANDLER_SPECIFIC_RESOURCE_SETTINGS = exports.INSTANTIATE_RESOURCE_HANDLER_GENERAL_RESOURCE_SETTINGS = void 0;
3
+ exports.FORM_RESOLVER_NAME = exports.FORMS_ROUTE = exports.RESOURCE_DEFINITION_SPECIFIC_RESOURCE_SETTINGS = exports.RESOURCE_DEFINITION_GENERAL_RESOURCE_SETTINGS = exports.INSTANTIATE_RESOURCE_HANDLER_SPECIFIC_RESOURCE_SETTINGS = exports.INSTANTIATE_RESOURCE_HANDLER_GENERAL_RESOURCE_SETTINGS = void 0;
4
4
  /**
5
5
  * Instantiate Resource Handler General Resource Settings
6
6
  * 实例化资源处理程序普通资源配置
7
7
  */
8
8
  exports.INSTANTIATE_RESOURCE_HANDLER_GENERAL_RESOURCE_SETTINGS = {
9
+ slug: "forms-instantiate-resource-handler",
9
10
  title: "表单组实例化资源处理程序",
10
11
  description: "",
11
12
  };
@@ -23,6 +24,7 @@ exports.INSTANTIATE_RESOURCE_HANDLER_SPECIFIC_RESOURCE_SETTINGS = {
23
24
  ],
24
25
  };
25
26
  exports.RESOURCE_DEFINITION_GENERAL_RESOURCE_SETTINGS = {
27
+ slug: "forms-resource-definition",
26
28
  title: "表单组资源定义",
27
29
  description: "",
28
30
  };
@@ -30,3 +32,4 @@ exports.RESOURCE_DEFINITION_SPECIFIC_RESOURCE_SETTINGS = {
30
32
  kind: "forms",
31
33
  };
32
34
  exports.FORMS_ROUTE = "/forms";
35
+ exports.FORM_RESOLVER_NAME = "submit";
@@ -1 +1 @@
1
- {"version":3,"file":"resource.d.ts","sourceRoot":"","sources":["../src/resource.ts"],"names":[],"mappings":"AACA,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,CA6B9B;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,CAyB9B;IAEF,mBAAmB,EAAE,mBAAmB,CAStC;CACH"}
package/dist/resource.js CHANGED
@@ -1,12 +1,7 @@
1
1
  "use strict";
2
- var __importDefault = (this && this.__importDefault) || function (mod) {
3
- return (mod && mod.__esModule) ? mod : { "default": mod };
4
- };
5
2
  Object.defineProperty(exports, "__esModule", { value: true });
6
3
  exports.FormsResource = void 0;
7
- const apaas_constants_1 = require("@ldsg/apaas-constants");
8
4
  const resource_1 = require("@ldsg/resource");
9
- const lodash_1 = __importDefault(require("lodash"));
10
5
  const handle_form_info_list_1 = require("./utils/handle-form-info-list");
11
6
  class FormsResource extends resource_1.Resource {
12
7
  constructor() {
@@ -15,17 +10,14 @@ class FormsResource extends resource_1.Resource {
15
10
  const { id, formInfoList: thisFormInfoList, getFilteredResources } = this;
16
11
  let formInfoList = thisFormInfoList;
17
12
  if (!formInfoList) {
18
- const { resources: formResources } = getFilteredResources({
19
- kind: apaas_constants_1.ApaasResourceKind.FORM,
13
+ const getFormInfoResList = getFilteredResources({
14
+ kind: "form",
20
15
  parentId: id,
16
+ }).resources.map((formResource) => {
17
+ return formResource.getFormInfo(params);
21
18
  });
22
- const mapRes = formResources.map((formResource) => {
23
- var _a;
24
- return (_a = formResource.getFormInfo) === null || _a === void 0 ? void 0 : _a.call(formResource, params);
25
- });
26
- const filterRes = lodash_1.default.filter(mapRes, (value) => !lodash_1.default.isUndefined(value));
27
- formInfoList = filterRes;
28
- this.formInfoList = formInfoList;
19
+ this.formInfoList = getFormInfoResList;
20
+ formInfoList = getFormInfoResList;
29
21
  }
30
22
  const res = {
31
23
  formInfoList,
@@ -13,15 +13,14 @@ class MockFormResource extends resource_1.Resource {
13
13
  constructor() {
14
14
  super(...arguments);
15
15
  this.getFormInfo = (params) => {
16
- const { id, settings: { title, description, name }, getResourcesFromSettings, } = this;
16
+ const { settings: { title, description, slug }, getResourcesFromSettings, } = this;
17
17
  const { inputObjectResource, outputObjectResource } = getResourcesFromSettings();
18
18
  const { objectInfo: inputObjectInfo } = inputObjectResource.getObjectInfo(params);
19
19
  const { objectInfo: outputObjectInfo } = outputObjectResource.getObjectInfo(params);
20
20
  const res = {
21
- id,
21
+ slug,
22
22
  title,
23
23
  description,
24
- name,
25
24
  inputObjectInfo,
26
25
  outputObjectInfo,
27
26
  };
@@ -35,6 +34,7 @@ test("forms", () => {
35
34
  kind: "graphql",
36
35
  parentId: "test-application",
37
36
  settings: {
37
+ slug: "test-graphql",
38
38
  title: "测试GraphQL",
39
39
  description: "",
40
40
  code: "",
@@ -124,6 +124,7 @@ test("forms", () => {
124
124
  kind: "form",
125
125
  parentId: "test-application",
126
126
  settings: {
127
+ slug: "test-forms",
127
128
  title: "测试表单组",
128
129
  description: "",
129
130
  },
@@ -133,6 +134,7 @@ test("forms", () => {
133
134
  kind: "workflow",
134
135
  parentId: "root",
135
136
  settings: {
137
+ slug: "test-workflow-1",
136
138
  title: "测试工作流1",
137
139
  description: "",
138
140
  startWorkflowNodeResourceId: "",
@@ -144,6 +146,7 @@ test("forms", () => {
144
146
  kind: "workflow",
145
147
  parentId: "root",
146
148
  settings: {
149
+ slug: "test-workflow-2",
147
150
  title: "测试工作流2",
148
151
  description: "",
149
152
  startWorkflowNodeResourceId: "",
@@ -155,6 +158,7 @@ test("forms", () => {
155
158
  kind: "form",
156
159
  parentId: "test-forms",
157
160
  settings: {
161
+ slug: "test-form-1",
158
162
  title: "测试表单1",
159
163
  description: "",
160
164
  name: "test-a-1",
@@ -167,6 +171,7 @@ test("forms", () => {
167
171
  kind: "form",
168
172
  parentId: "test-forms",
169
173
  settings: {
174
+ slug: "test-form-2",
170
175
  title: "测试表单2",
171
176
  description: "",
172
177
  name: "test-a-2",
@@ -186,6 +191,7 @@ test("form and forms query fields", () => {
186
191
  kind: "graphql",
187
192
  parentId: "test-application",
188
193
  settings: {
194
+ slug: "test-graphql",
189
195
  title: "测试GraphQL",
190
196
  description: "",
191
197
  code: "",
@@ -235,6 +241,7 @@ test("form and forms query fields", () => {
235
241
  kind: "forms",
236
242
  parentId: "test-application",
237
243
  settings: {
244
+ slug: "test-forms",
238
245
  title: "测试表单",
239
246
  description: "",
240
247
  },
@@ -244,6 +251,7 @@ test("form and forms query fields", () => {
244
251
  kind: "form",
245
252
  parentId: "test-forms",
246
253
  settings: {
254
+ slug: "test-form-1",
247
255
  title: "测试表单1",
248
256
  description: "Test Form 1",
249
257
  name: "test-a-1",
@@ -256,6 +264,7 @@ test("form and forms query fields", () => {
256
264
  kind: "form",
257
265
  parentId: "test-forms",
258
266
  settings: {
267
+ slug: "test-form-2",
259
268
  title: "测试表单2",
260
269
  description: "Test Form 2",
261
270
  name: "test-a-2",
@@ -2,14 +2,6 @@ import { PlatformsParams } from "@ldsg/field-type";
2
2
  import { ObjectInfo } from "@ldsg/object";
3
3
  import { GeneralResourceSettings } from "@ldsg/types";
4
4
  export interface FormInfo extends GeneralResourceSettings {
5
- /**
6
- * Form ID
7
- */
8
- id: string;
9
- /**
10
- * Form Name
11
- */
12
- name: string;
13
5
  /**
14
6
  * Input Object Info
15
7
  */
@@ -19,5 +11,9 @@ export interface FormInfo extends GeneralResourceSettings {
19
11
  */
20
12
  outputObjectInfo: ObjectInfo;
21
13
  }
14
+ /**
15
+ * 获取表单信息。当表单缺少 input/output object 引用时返回 undefined,
16
+ * 由调用方(getFormInfoList)过滤跳过,避免生成损坏的 GraphQL schema。
17
+ */
22
18
  export type GetFormInfo = (params?: PlatformsParams) => FormInfo;
23
19
  //# sourceMappingURL=get-form-info.d.ts.map
@@ -1 +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;AAEtD,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;CAC9B;AAED,MAAM,MAAM,WAAW,GAAG,CAAC,MAAM,CAAC,EAAE,eAAe,KAAK,QAAQ,CAAC"}
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;AAEtD,MAAM,WAAW,QAAS,SAAQ,uBAAuB;IACvD;;OAEG;IACH,eAAe,EAAE,UAAU,CAAC;IAE5B;;OAEG;IACH,gBAAgB,EAAE,UAAU,CAAC;CAC9B;AAED;;;GAGG;AACH,MAAM,MAAM,WAAW,GAAG,CAAC,MAAM,CAAC,EAAE,eAAe,KAAK,QAAQ,CAAC"}
@@ -1 +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"}
1
+ {"version":3,"file":"create-resolvers.d.ts","sourceRoot":"","sources":["../../../../src/utils/add-query-fields/utils/create-resolvers.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,QAAQ,EAAE,MAAM,gBAAgB,CAAC;AAG1C;;GAEG;AACH,wBAAgB,kBAAkB,CAAC,YAAY,EAAE,QAAQ,EAAE;;;;;;qBAOhC,GAAG,QAAQ,GAAG;EAcxC;AAED;;GAEG;AACH,wBAAgB,mBAAmB,CAAC,YAAY,EAAE,QAAQ,EAAE;;;;EAQ3D"}
@@ -1,7 +1,11 @@
1
1
  "use strict";
2
+ var __importDefault = (this && this.__importDefault) || function (mod) {
3
+ return (mod && mod.__esModule) ? mod : { "default": mod };
4
+ };
2
5
  Object.defineProperty(exports, "__esModule", { value: true });
3
6
  exports.createFormResolver = createFormResolver;
4
7
  exports.createFormsResolver = createFormsResolver;
8
+ const lodash_1 = __importDefault(require("lodash"));
5
9
  const map_form_info_1 = require("./map-form-info");
6
10
  /**
7
11
  * Creates a resolver definition for querying a single form by name
@@ -15,7 +19,9 @@ function createFormResolver(formInfoList) {
15
19
  },
16
20
  resolve: async (_root, args) => {
17
21
  const { name } = args;
18
- const formInfo = formInfoList.find((f) => f.name === name);
22
+ const formInfo = formInfoList.find((formInfo) => {
23
+ return lodash_1.default.camelCase(formInfo.slug) === name;
24
+ });
19
25
  if (!formInfo) {
20
26
  throw new Error(`Form not found: ${name}`);
21
27
  }
@@ -1 +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"}
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;AA+DzC;;GAEG;AACH,wBAAgB,4BAA4B,CAAC,aAAa,EAAE,SAAS,EAAE,GAAG,GAAG,CAqB5E;AAED;;;GAGG;AACH,wBAAgB,mCAAmC,CAAC,aAAa,EAAE,SAAS,EAAE,GAAG,GAAG,CAuBnF"}
@@ -1,10 +1,14 @@
1
1
  "use strict";
2
+ var __importDefault = (this && this.__importDefault) || function (mod) {
3
+ return (mod && mod.__esModule) ? mod : { "default": mod };
4
+ };
2
5
  Object.defineProperty(exports, "__esModule", { value: true });
3
6
  exports.getJsonSchemaByFieldInfoList = getJsonSchemaByFieldInfoList;
4
7
  exports.getFormilyJsonSchemaByFieldInfoList = getFormilyJsonSchemaByFieldInfoList;
5
8
  const json_schema_1 = require("@formily/json-schema");
6
9
  const field_type_1 = require("@ldsg/field-type");
7
10
  const get_schema_for_formily_1 = require("./get-schema-for-formily");
11
+ const lodash_1 = __importDefault(require("lodash"));
8
12
  /**
9
13
  * Generates JSON Schema for a field based on its type info
10
14
  */
@@ -18,21 +22,23 @@ function getJsonSchemaForField(fieldInfo) {
18
22
  }
19
23
  // Fallback: generate basic schema based on common type
20
24
  const commonType = platformToTypeMap[field_type_1.FieldTypeBasePlatform.COMMON];
25
+ const { title: fieldInfoTitle, slug } = fieldInfo;
26
+ const title = fieldInfoTitle !== null && fieldInfoTitle !== void 0 ? fieldInfoTitle : lodash_1.default.camelCase(slug);
21
27
  if (!commonType) {
22
28
  return {
23
29
  type: "string",
24
- title: fieldInfo.title || fieldInfo.name,
30
+ title,
25
31
  };
26
32
  }
27
33
  // Basic type mapping
28
34
  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 },
35
+ string: { type: "string", title },
36
+ number: { type: "number", title },
37
+ boolean: { type: "boolean", title },
38
+ array: { type: "array", title },
39
+ object: { type: "object", title },
34
40
  };
35
- return typeMap[commonType] || { type: "string", title: fieldInfo.title || fieldInfo.name };
41
+ return typeMap[commonType] || { type: "string", title };
36
42
  }
37
43
  /**
38
44
  * Generates Formily JSON Schema for a field based on its type info
@@ -55,12 +61,12 @@ function getJsonSchemaByFieldInfoList(fieldInfoList) {
55
61
  const properties = {};
56
62
  const required = [];
57
63
  fieldInfoList.forEach((fieldInfo) => {
64
+ const fieldName = lodash_1.default.camelCase(fieldInfo.slug);
58
65
  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
66
+ properties[fieldName] = schema;
67
+ // Add to required if field is mandatory
62
68
  if (fieldInfo.required) {
63
- required.push(fieldInfo.name);
69
+ required.push(fieldName);
64
70
  }
65
71
  });
66
72
  return {
@@ -75,8 +81,9 @@ function getJsonSchemaByFieldInfoList(fieldInfoList) {
75
81
  function getFormilyJsonSchemaByFieldInfoList(fieldInfoList) {
76
82
  const properties = {};
77
83
  fieldInfoList.forEach((fieldInfo) => {
84
+ const fieldName = lodash_1.default.camelCase(fieldInfo.slug);
78
85
  const formilySchema = getFormilyJsonSchemaForField(fieldInfo);
79
- properties[fieldInfo.name] = formilySchema;
86
+ properties[fieldName] = formilySchema;
80
87
  });
81
88
  const schema = new json_schema_1.Schema({
82
89
  type: "object",
@@ -1 +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;AAMtE;;GAEG;AACH,wBAAgB,qBAAqB,CAAC,QAAQ,EAAE,QAAQ,GAAG,YAAY,CAMtE;AAED;;GAEG;AACH,wBAAgB,mBAAmB,CAAC,QAAQ,EAAE,QAAQ,GAAG,UAAU,CA4BlE"}
1
+ {"version":3,"file":"map-form-info.d.ts","sourceRoot":"","sources":["../../../../src/utils/add-query-fields/utils/map-form-info.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,QAAQ,EAAE,MAAM,gBAAgB,CAAC;AAC1C,OAAO,EAAE,UAAU,EAAE,YAAY,EAAE,MAAM,4BAA4B,CAAC;AAMtE;;GAEG;AACH,wBAAgB,qBAAqB,CAAC,QAAQ,EAAE,QAAQ,GAAG,YAAY,CAQtE;AAED;;GAEG;AACH,wBAAgB,mBAAmB,CAAC,QAAQ,EAAE,QAAQ,GAAG,UAAU,CA8BlE"}
@@ -1,16 +1,21 @@
1
1
  "use strict";
2
+ var __importDefault = (this && this.__importDefault) || function (mod) {
3
+ return (mod && mod.__esModule) ? mod : { "default": mod };
4
+ };
2
5
  Object.defineProperty(exports, "__esModule", { value: true });
3
6
  exports.mapFormInfoToMetadata = mapFormInfoToMetadata;
4
7
  exports.mapFormInfoToDetail = mapFormInfoToDetail;
8
+ const lodash_1 = __importDefault(require("lodash"));
5
9
  const get_json_schema_1 = require("./get-json-schema");
6
10
  /**
7
11
  * Maps FormInfo to FormMetadata (lightweight version without schemas)
8
12
  */
9
13
  function mapFormInfoToMetadata(formInfo) {
14
+ const { slug, title, description } = formInfo;
10
15
  return {
11
- name: formInfo.name,
12
- title: formInfo.title,
13
- description: formInfo.description,
16
+ name: lodash_1.default.camelCase(slug),
17
+ title,
18
+ description,
14
19
  };
15
20
  }
16
21
  /**
@@ -24,10 +29,11 @@ function mapFormInfoToDetail(formInfo) {
24
29
  // Generate JSON schemas for output object
25
30
  const outputJsonSchema = (0, get_json_schema_1.getJsonSchemaByFieldInfoList)(outputObjectInfo.fieldInfoList);
26
31
  const outputFormilyJsonSchema = (0, get_json_schema_1.getFormilyJsonSchemaByFieldInfoList)(outputObjectInfo.fieldInfoList);
32
+ const { slug, title, description } = formInfo;
27
33
  return {
28
- name: formInfo.name,
29
- title: formInfo.title,
30
- description: formInfo.description,
34
+ name: lodash_1.default.camelCase(slug),
35
+ title,
36
+ description,
31
37
  inputObjectInfo: {
32
38
  ...inputObjectInfo,
33
39
  jsonSchema: inputJsonSchema,
@@ -1 +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"}
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;AAKvC,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,kBA2BhC,CAAC"}
@@ -3,14 +3,23 @@ Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.handleFormInfoList = void 0;
4
4
  const get_input_itc_1 = require("./utils/get-input-itc");
5
5
  const get_output_otc_1 = require("./utils/get-output-otc");
6
+ const constants_1 = require("../../constants");
6
7
  const handleFormInfoList = (params) => {
7
8
  const { schemaComposer, formInfoList } = params;
8
9
  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 });
10
+ const { slug: formSlug, inputObjectInfo, outputObjectInfo } = formInfo;
11
+ const { outputOTC } = (0, get_output_otc_1.getOutputOTC)({
12
+ schemaComposer,
13
+ formSlug,
14
+ outputObjectInfo,
15
+ });
16
+ const { inputITC } = (0, get_input_itc_1.getInputITC)({
17
+ schemaComposer,
18
+ formSlug,
19
+ inputObjectInfo,
20
+ });
12
21
  outputOTC.addResolver({
13
- name: "submit",
22
+ name: constants_1.FORM_RESOLVER_NAME,
14
23
  type: outputOTC,
15
24
  args: inputITC.getFields(),
16
25
  resolve: undefined,
@@ -10,12 +10,12 @@ const getFieldConfigMapDefinition = (params) => {
10
10
  const { fieldInfoList } = params;
11
11
  const fieldConfigMapDefinition = {};
12
12
  lodash_1.default.each(fieldInfoList, (fieldInfo) => {
13
- const { title, description, name, typeInfo } = fieldInfo;
14
- const camelCaseName = lodash_1.default.camelCase(name);
13
+ const { title, description, slug, typeInfo } = fieldInfo;
14
+ const fieldName = lodash_1.default.camelCase(slug);
15
15
  const { graphqlType } = (0, get_graphql_type_by_type_info_1.getGraphqlTypeByTypeInfo)({
16
16
  typeInfo,
17
17
  });
18
- fieldConfigMapDefinition[camelCaseName] = {
18
+ fieldConfigMapDefinition[fieldName] = {
19
19
  type: graphqlType,
20
20
  description: `${title}${description ? `:${description}` : ""}`,
21
21
  };
@@ -2,6 +2,10 @@ import { SchemaComposerParams } from "@ldsg/graphql";
2
2
  import { ObjectInfo } from "@ldsg/object";
3
3
  import { InputTypeComposer } from "graphql-compose";
4
4
  interface GetInputITCParams extends SchemaComposerParams {
5
+ /**
6
+ * 表单别名
7
+ */
8
+ formSlug: string;
5
9
  inputObjectInfo: ObjectInfo;
6
10
  }
7
11
  interface GetInputITCRes {
@@ -1 +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"}
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;AAIjF,UAAU,iBAAkB,SAAQ,oBAAoB;IACtD;;OAEG;IACH,QAAQ,EAAE,MAAM,CAAC;IAEjB,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"}
@@ -1,13 +1,18 @@
1
1
  "use strict";
2
+ var __importDefault = (this && this.__importDefault) || function (mod) {
3
+ return (mod && mod.__esModule) ? mod : { "default": mod };
4
+ };
2
5
  Object.defineProperty(exports, "__esModule", { value: true });
3
6
  exports.getInputITC = void 0;
4
7
  const get_field_config_map_definition_1 = require("./get-field-config-map-definition");
8
+ const lodash_1 = __importDefault(require("lodash"));
5
9
  const getInputITC = (params) => {
6
- const { schemaComposer, inputObjectInfo } = params;
7
- const { title, description, objectTypeName, fieldInfoList } = inputObjectInfo;
10
+ const { schemaComposer, formSlug, inputObjectInfo } = params;
11
+ const { title, description, fieldInfoList } = inputObjectInfo;
8
12
  const { fieldConfigMapDefinition } = (0, get_field_config_map_definition_1.getFieldConfigMapDefinition)({
9
13
  fieldInfoList,
10
14
  });
15
+ const objectTypeName = lodash_1.default.upperFirst(lodash_1.default.camelCase(`${formSlug}-input`));
11
16
  const definition = {
12
17
  name: objectTypeName,
13
18
  fields: fieldConfigMapDefinition,
@@ -2,6 +2,10 @@ import { SchemaComposerParams } from "@ldsg/graphql";
2
2
  import { ObjectInfo } from "@ldsg/object";
3
3
  import { ObjectTypeComposer } from "graphql-compose";
4
4
  interface GetOutputOTCParams extends SchemaComposerParams {
5
+ /**
6
+ * 表单别名
7
+ */
8
+ formSlug: string;
5
9
  outputObjectInfo: ObjectInfo;
6
10
  }
7
11
  interface GetOutputOTCRes {
@@ -1 +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"}
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;AAInF,UAAU,kBAAmB,SAAQ,oBAAoB;IACvD;;OAEG;IACH,QAAQ,EAAE,MAAM,CAAC;IAEjB,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"}
@@ -1,13 +1,18 @@
1
1
  "use strict";
2
+ var __importDefault = (this && this.__importDefault) || function (mod) {
3
+ return (mod && mod.__esModule) ? mod : { "default": mod };
4
+ };
2
5
  Object.defineProperty(exports, "__esModule", { value: true });
3
6
  exports.getOutputOTC = void 0;
4
7
  const get_field_config_map_definition_1 = require("./get-field-config-map-definition");
8
+ const lodash_1 = __importDefault(require("lodash"));
5
9
  const getOutputOTC = (params) => {
6
- const { schemaComposer, outputObjectInfo } = params;
7
- const { title, description, objectTypeName, fieldInfoList } = outputObjectInfo;
10
+ const { schemaComposer, formSlug, outputObjectInfo } = params;
11
+ const { title, description, fieldInfoList } = outputObjectInfo;
8
12
  const { fieldConfigMapDefinition } = (0, get_field_config_map_definition_1.getFieldConfigMapDefinition)({
9
13
  fieldInfoList,
10
14
  });
15
+ const objectTypeName = lodash_1.default.upperFirst(lodash_1.default.camelCase(formSlug));
11
16
  const definition = {
12
17
  name: objectTypeName,
13
18
  fields: fieldConfigMapDefinition,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@ldsg/forms",
3
- "version": "0.3.38",
3
+ "version": "0.3.40",
4
4
  "description": "",
5
5
  "keywords": [],
6
6
  "license": "MIT",
@@ -18,16 +18,15 @@
18
18
  "json-schema": "^0.4.0",
19
19
  "lodash": "^4.17.21",
20
20
  "zod": "^4.1.11",
21
- "@ldsg/field-type": "0.3.38",
22
- "@ldsg/handler": "0.3.38",
23
- "@ldsg/object": "0.3.38",
24
- "@ldsg/graphql": "0.3.38",
25
- "@ldsg/apaas-constants": "0.3.38",
26
- "@ldsg/object-field": "0.3.38",
27
- "@ldsg/resource": "0.3.38",
28
- "@ldsg/resource-definition": "0.3.38",
29
- "@ldsg/types": "0.3.38",
30
- "@ldsg/workflow": "0.3.38"
21
+ "@ldsg/field-type": "0.3.40",
22
+ "@ldsg/handler": "0.3.40",
23
+ "@ldsg/graphql": "0.3.40",
24
+ "@ldsg/object": "0.3.40",
25
+ "@ldsg/object-field": "0.3.40",
26
+ "@ldsg/resource": "0.3.40",
27
+ "@ldsg/resource-definition": "0.3.40",
28
+ "@ldsg/workflow": "0.3.40",
29
+ "@ldsg/types": "0.3.40"
31
30
  },
32
31
  "devDependencies": {
33
32
  "@types/jest": "^29.5.2",