@ldsg/forms 0.3.5 → 0.3.6

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.
@@ -1,4 +1,3 @@
1
- import { ExtendExpressApp } from "@ldsg/application";
2
1
  import { PlatformsParams } from "@ldsg/field-type";
3
2
  import { ModifyGraphQLSchema } from "@ldsg/graphql";
4
3
  import { Resource } from "@ldsg/resource";
@@ -13,7 +12,6 @@ type GetFormInfoList = (params?: PlatformsParams) => GetFormInfoListRes;
13
12
  export declare class FormsResource extends Resource<FormsSpecificResourceSettings> {
14
13
  formInfoList?: FormInfo[];
15
14
  getFormInfoList: GetFormInfoList;
16
- extendExpressApp: ExtendExpressApp;
17
15
  modifyGraphQLSchema: ModifyGraphQLSchema;
18
16
  }
19
17
  export {};
@@ -1 +1 @@
1
- {"version":3,"file":"resource.d.ts","sourceRoot":"","sources":["../src/resource.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,gBAAgB,EAAE,MAAM,mBAAmB,CAAC;AACrD,OAAO,EAAE,eAAe,EAAE,MAAM,kBAAkB,CAAC;AACnD,OAAO,EAAE,mBAAmB,EAAE,MAAM,eAAe,CAAC;AACpD,OAAO,EAAE,QAAQ,EAAE,MAAM,gBAAgB,CAAC;AAI1C,OAAO,EAAE,QAAQ,EAAE,6BAA6B,EAAe,MAAM,SAAS,CAAC;AAG/E,UAAU,kBAAkB;IAC1B;;OAEG;IACH,YAAY,EAAE,QAAQ,EAAE,CAAC;CAC1B;AAED,KAAK,eAAe,GAAG,CAAC,MAAM,CAAC,EAAE,eAAe,KAAK,kBAAkB,CAAC;AAExE,qBAAa,aAAc,SAAQ,QAAQ,CAAC,6BAA6B,CAAC;IACxE,YAAY,CAAC,EAAE,QAAQ,EAAE,CAAC;IAE1B,eAAe,EAAE,eAAe,CA4B9B;IAEF,gBAAgB,EAAE,gBAAgB,CAkDhC;IAEF,mBAAmB,EAAE,mBAAmB,CAetC;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,YAAY,CAAC,EAAE,QAAQ,EAAE,CAAC;IAE1B,eAAe,EAAE,eAAe,CA4B9B;IAEF,mBAAmB,EAAE,mBAAmB,CAetC;CACH"}
package/dist/resource.js CHANGED
@@ -5,9 +5,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
5
5
  Object.defineProperty(exports, "__esModule", { value: true });
6
6
  exports.FormsResource = void 0;
7
7
  const resource_1 = require("@ldsg/resource");
8
- const express_1 = __importDefault(require("express"));
9
8
  const lodash_1 = __importDefault(require("lodash"));
10
- const constants_1 = require("./constants");
11
9
  const utils_1 = require("./utils");
12
10
  class FormsResource extends resource_1.Resource {
13
11
  constructor() {
@@ -32,43 +30,6 @@ class FormsResource extends resource_1.Resource {
32
30
  };
33
31
  return res;
34
32
  };
35
- this.extendExpressApp = async (params) => {
36
- const { app } = params;
37
- const { formInfoList } = this.getFormInfoList();
38
- // 解析 JSON 请求体
39
- app.use(express_1.default.json());
40
- // 解析 URL 编码的请求体,extended: true 允许使用复杂对象
41
- app.use(express_1.default.urlencoded({ extended: true }));
42
- /**
43
- * RESTful
44
- */
45
- app.get(constants_1.FORMS_ROUTE, (req, res) => {
46
- res.json({
47
- list: formInfoList,
48
- });
49
- });
50
- app.get(`${constants_1.FORMS_ROUTE}/:formId`, (req, res) => {
51
- const { formId } = req.params;
52
- const formInfo = formInfoList.find((formInfo) => {
53
- return formInfo.id === formId;
54
- });
55
- res.json(formInfo);
56
- });
57
- app.post(`${constants_1.FORMS_ROUTE}/:formId`, async (req, res) => {
58
- const { formId } = req.params;
59
- const formInfo = formInfoList.find((formInfo) => {
60
- return formInfo.id === formId;
61
- });
62
- if (!formInfo) {
63
- throw new Error("invalid form");
64
- }
65
- const workflowInputVariables = req.body;
66
- const { variables: workflowOutputVariables } = await formInfo.workflowInfo.execute({
67
- variables: workflowInputVariables,
68
- });
69
- res.json(workflowOutputVariables);
70
- });
71
- };
72
33
  this.modifyGraphQLSchema = (params) => {
73
34
  const { schemaComposer } = params;
74
35
  const { Mutation, Query } = schemaComposer;
@@ -14,10 +14,9 @@ class MockFormResource extends resource_1.Resource {
14
14
  super(...arguments);
15
15
  this.getFormInfo = (params) => {
16
16
  const { id, settings: { title, description, name }, getResourcesFromSettings, } = this;
17
- const { inputObjectResource, outputObjectResource, workflowResource } = getResourcesFromSettings();
17
+ const { inputObjectResource, outputObjectResource } = getResourcesFromSettings();
18
18
  const { objectInfo: inputObjectInfo } = inputObjectResource.getObjectInfo(params);
19
19
  const { objectInfo: outputObjectInfo } = outputObjectResource.getObjectInfo(params);
20
- const { workflowInfo } = workflowResource.getWorkflowInfo();
21
20
  const res = {
22
21
  id,
23
22
  title,
@@ -25,7 +24,6 @@ class MockFormResource extends resource_1.Resource {
25
24
  name,
26
25
  inputObjectInfo,
27
26
  outputObjectInfo,
28
- workflowInfo,
29
27
  };
30
28
  return res;
31
29
  };
@@ -192,7 +190,6 @@ test("forms", () => {
192
190
  name: "test-a-1",
193
191
  inputObjectResourceId: "test-object-1",
194
192
  outputObjectResourceId: "test-object-2",
195
- workflowResourceId: "test-workflow-1",
196
193
  },
197
194
  });
198
195
  new MockFormResource({
@@ -205,7 +202,6 @@ test("forms", () => {
205
202
  name: "test-a-2",
206
203
  inputObjectResourceId: "test-object-2",
207
204
  outputObjectResourceId: "test-object-1",
208
- workflowResourceId: "test-workflow-2",
209
205
  },
210
206
  });
211
207
  const getFormInfoListRes = formsResource.getFormInfoList();
@@ -1,7 +1,6 @@
1
1
  import { PlatformsParams } from "@ldsg/field-type";
2
2
  import { ObjectInfo } from "@ldsg/object";
3
3
  import { GeneralResourceSettings } from "@ldsg/types";
4
- import { WorkflowInfo } from "@ldsg/workflow";
5
4
  export interface FormInfo extends GeneralResourceSettings {
6
5
  /**
7
6
  * Form ID
@@ -19,10 +18,6 @@ export interface FormInfo extends GeneralResourceSettings {
19
18
  * Output Object Info
20
19
  */
21
20
  outputObjectInfo: ObjectInfo;
22
- /**
23
- * Workflow Info
24
- */
25
- workflowInfo: WorkflowInfo;
26
21
  }
27
22
  export type GetFormInfo = (params?: PlatformsParams) => FormInfo;
28
23
  //# 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;AACtD,OAAO,EAAE,YAAY,EAAE,MAAM,gBAAgB,CAAC;AAE9C,MAAM,WAAW,QAAS,SAAQ,uBAAuB;IACvD;;OAEG;IACH,EAAE,EAAE,MAAM,CAAC;IAEX;;OAEG;IACH,IAAI,EAAE,MAAM,CAAC;IAEb;;OAEG;IACH,eAAe,EAAE,UAAU,CAAC;IAE5B;;OAEG;IACH,gBAAgB,EAAE,UAAU,CAAC;IAE7B;;OAEG;IACH,YAAY,EAAE,YAAY,CAAC;CAC5B;AAED,MAAM,MAAM,WAAW,GAAG,CAAC,MAAM,CAAC,EAAE,eAAe,KAAK,QAAQ,CAAC"}
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 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/utils/get-new-fields/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,oBAAoB,EAAE,MAAM,eAAe,CAAC;AACrD,OAAO,EACL,0CAA0C,EAE3C,MAAM,iBAAiB,CAAC;AAEzB,OAAO,EAAE,QAAQ,EAAE,MAAM,aAAa,CAAC;AAGvC,UAAU,kBAAmB,SAAQ,oBAAoB;IACvD,YAAY,EAAE,QAAQ,EAAE,CAAC;CAC1B;AAED,UAAU,eAAe;IACvB,SAAS,EAAE,0CAA0C,CAAC,GAAG,EAAE,GAAG,CAAC,CAAC;CACjE;AAED,KAAK,YAAY,GAAG,CAAC,MAAM,EAAE,kBAAkB,KAAK,eAAe,CAAC;AAEpE,eAAO,MAAM,YAAY,EAAE,YAiD1B,CAAC"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/utils/get-new-fields/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,oBAAoB,EAAE,MAAM,eAAe,CAAC;AACrD,OAAO,EACL,0CAA0C,EAE3C,MAAM,iBAAiB,CAAC;AAEzB,OAAO,EAAE,QAAQ,EAAE,MAAM,aAAa,CAAC;AAGvC,UAAU,kBAAmB,SAAQ,oBAAoB;IACvD,YAAY,EAAE,QAAQ,EAAE,CAAC;CAC1B;AAED,UAAU,eAAe;IACvB,SAAS,EAAE,0CAA0C,CAAC,GAAG,EAAE,GAAG,CAAC,CAAC;CACjE;AAED,KAAK,YAAY,GAAG,CAAC,MAAM,EAAE,kBAAkB,KAAK,eAAe,CAAC;AAEpE,eAAO,MAAM,YAAY,EAAE,YAgC1B,CAAC"}
@@ -10,7 +10,7 @@ const getNewFields = (params) => {
10
10
  const { schemaComposer, formInfoList } = params;
11
11
  const newFields = {};
12
12
  formInfoList.forEach((formInfo) => {
13
- const { title, description, name, inputObjectInfo, outputObjectInfo, workflowInfo, } = formInfo;
13
+ const { title, description, name, inputObjectInfo, outputObjectInfo } = formInfo;
14
14
  const graphqlFieldName = lodash_1.default.camelCase(name);
15
15
  const { outputOTC } = (0, utils_1.getOutputOTC)({ schemaComposer, outputObjectInfo });
16
16
  const { inputITC } = (0, utils_1.getInputITC)({ schemaComposer, inputObjectInfo });
@@ -19,14 +19,6 @@ const getNewFields = (params) => {
19
19
  description: `${title}${description ? `:${description}` : ""}`,
20
20
  type: outputOTC,
21
21
  args: inputITC.getFields(),
22
- resolve: async (resolveParams) => {
23
- const { args } = resolveParams;
24
- const executeRes = await workflowInfo.execute({
25
- variables: args,
26
- });
27
- const res = executeRes.variables;
28
- return res;
29
- },
30
22
  };
31
23
  const fieldResolver = schemaComposer.createResolver(resolverDefinition);
32
24
  newFields[graphqlFieldName] = fieldResolver;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@ldsg/forms",
3
- "version": "0.3.5",
3
+ "version": "0.3.6",
4
4
  "description": "",
5
5
  "main": "dist/index.js",
6
6
  "files": [
@@ -15,9 +15,9 @@
15
15
  },
16
16
  "dependencies": {
17
17
  "lodash": "^4.17.21",
18
- "@ldsg/handler": "0.3.5",
19
- "@ldsg/resource-definition": "0.3.5",
20
- "@ldsg/resource": "0.3.5"
18
+ "@ldsg/handler": "0.3.6",
19
+ "@ldsg/resource": "0.3.6",
20
+ "@ldsg/resource-definition": "0.3.6"
21
21
  },
22
22
  "devDependencies": {
23
23
  "@types/lodash": "^4.14.202",
@@ -25,13 +25,13 @@
25
25
  "graphql": "16.11.0",
26
26
  "graphql-compose": "^9.1.0",
27
27
  "supertest": "^6.3.4",
28
- "@ldsg/application": "0.3.5",
29
- "@ldsg/field-type": "0.3.5",
30
- "@ldsg/graphql": "0.3.5",
31
- "@ldsg/object": "0.3.5",
32
- "@ldsg/object-field": "0.3.5",
33
- "@ldsg/types": "0.3.5",
34
- "@ldsg/workflow": "0.3.5"
28
+ "@ldsg/application": "0.3.6",
29
+ "@ldsg/field-type": "0.3.6",
30
+ "@ldsg/graphql": "0.3.6",
31
+ "@ldsg/object": "0.3.6",
32
+ "@ldsg/types": "0.3.6",
33
+ "@ldsg/workflow": "0.3.6",
34
+ "@ldsg/object-field": "0.3.6"
35
35
  },
36
36
  "scripts": {
37
37
  "build": "tsc --project tsconfig.build.json",