@ldsg/forms 0.3.9 → 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.
Files changed (68) hide show
  1. package/README.md +51 -1
  2. package/dist/constants.d.ts +3 -3
  3. package/dist/constants.d.ts.map +1 -1
  4. package/dist/constants.js +11 -10
  5. package/dist/handler.d.ts +5 -7
  6. package/dist/handler.d.ts.map +1 -1
  7. package/dist/index.d.ts +5 -5
  8. package/dist/instantiate-resource.d.ts +4 -4
  9. package/dist/instantiate-resource.js +1 -1
  10. package/dist/resource.d.ts +4 -4
  11. package/dist/resource.d.ts.map +1 -1
  12. package/dist/resource.js +4 -8
  13. package/dist/test/__tests__/unit.js +199 -131
  14. package/dist/types/get-form-info.d.ts +3 -3
  15. package/dist/types/index.d.ts +3 -2
  16. package/dist/types/index.d.ts.map +1 -1
  17. package/dist/types/index.js +1 -0
  18. package/dist/types/query-types.d.ts +50 -0
  19. package/dist/types/query-types.d.ts.map +1 -0
  20. package/dist/types/query-types.js +2 -0
  21. package/dist/types/specific-resource-settings.d.ts +1 -1
  22. package/dist/types/specific-resource-settings.d.ts.map +1 -1
  23. package/dist/utils/add-query-fields/index.d.ts +10 -0
  24. package/dist/utils/add-query-fields/index.d.ts.map +1 -0
  25. package/dist/utils/add-query-fields/index.js +26 -0
  26. package/dist/utils/add-query-fields/utils/create-resolvers.d.ts +21 -0
  27. package/dist/utils/add-query-fields/utils/create-resolvers.d.ts.map +1 -0
  28. package/dist/utils/add-query-fields/utils/create-resolvers.js +37 -0
  29. package/dist/utils/add-query-fields/utils/create-types.d.ts +10 -0
  30. package/dist/utils/add-query-fields/utils/create-types.d.ts.map +1 -0
  31. package/dist/utils/add-query-fields/utils/create-types.js +100 -0
  32. package/dist/utils/add-query-fields/utils/get-json-schema.d.ts +11 -0
  33. package/dist/utils/add-query-fields/utils/get-json-schema.d.ts.map +1 -0
  34. package/dist/utils/add-query-fields/utils/get-json-schema.js +90 -0
  35. package/dist/utils/add-query-fields/utils/get-schema-for-formily/constants.d.ts +3 -0
  36. package/dist/utils/add-query-fields/utils/get-schema-for-formily/constants.d.ts.map +1 -0
  37. package/dist/utils/add-query-fields/utils/get-schema-for-formily/constants.js +29 -0
  38. package/dist/utils/add-query-fields/utils/get-schema-for-formily/index.d.ts +11 -0
  39. package/dist/utils/add-query-fields/utils/get-schema-for-formily/index.d.ts.map +1 -0
  40. package/dist/utils/add-query-fields/utils/get-schema-for-formily/index.js +15 -0
  41. package/dist/utils/add-query-fields/utils/get-schema-for-formily/utils/process-object-schema.d.ts +8 -0
  42. package/dist/utils/add-query-fields/utils/get-schema-for-formily/utils/process-object-schema.d.ts.map +1 -0
  43. package/dist/utils/add-query-fields/utils/get-schema-for-formily/utils/process-object-schema.js +44 -0
  44. package/dist/utils/add-query-fields/utils/map-form-info.d.ts +11 -0
  45. package/dist/utils/add-query-fields/utils/map-form-info.d.ts.map +1 -0
  46. package/dist/utils/add-query-fields/utils/map-form-info.js +42 -0
  47. package/dist/utils/get-new-fields/index.d.ts +3 -3
  48. package/dist/utils/get-new-fields/index.d.ts.map +1 -1
  49. package/dist/utils/get-new-fields/index.js +3 -3
  50. package/dist/utils/get-new-fields/utils/get-field-config-map-definition.d.ts +1 -1
  51. package/dist/utils/get-new-fields/utils/get-field-config-map-definition.d.ts.map +1 -1
  52. package/dist/utils/get-new-fields/utils/get-field-config-map-definition.js +3 -3
  53. package/dist/utils/get-new-fields/utils/get-graphql-type-by-common-type.d.ts.map +1 -1
  54. package/dist/utils/get-new-fields/utils/get-graphql-type-by-common-type.js +3 -3
  55. package/dist/utils/get-new-fields/utils/get-graphql-type-by-type-info.d.ts +1 -1
  56. package/dist/utils/get-new-fields/utils/get-graphql-type-by-type-info.d.ts.map +1 -1
  57. package/dist/utils/get-new-fields/utils/get-graphql-type-by-type-info.js +2 -2
  58. package/dist/utils/get-new-fields/utils/get-input-itc.d.ts +3 -3
  59. package/dist/utils/get-new-fields/utils/get-input-itc.d.ts.map +1 -1
  60. package/dist/utils/get-new-fields/utils/get-input-itc.js +4 -4
  61. package/dist/utils/get-new-fields/utils/get-output-otc.d.ts +3 -3
  62. package/dist/utils/get-new-fields/utils/get-output-otc.d.ts.map +1 -1
  63. package/dist/utils/get-new-fields/utils/get-output-otc.js +10 -4
  64. package/dist/utils/get-new-fields/utils/index.d.ts +2 -2
  65. package/dist/utils/index.d.ts +2 -1
  66. package/dist/utils/index.d.ts.map +1 -1
  67. package/dist/utils/index.js +1 -0
  68. package/package.json +27 -19
@@ -13,15 +13,15 @@ const getFieldConfigMapDefinition = (params) => {
13
13
  const { title, description, name, typeInfo } = fieldInfo;
14
14
  const camelCaseName = lodash_1.default.camelCase(name);
15
15
  const { graphqlType } = (0, get_graphql_type_by_type_info_1.getGraphqlTypeByTypeInfo)({
16
- typeInfo,
16
+ typeInfo
17
17
  });
18
18
  fieldConfigMapDefinition[camelCaseName] = {
19
19
  type: graphqlType,
20
- description: `${title}${description ? `:${description}` : ""}`,
20
+ description: `${title}${description ? `:${description}` : ''}`
21
21
  };
22
22
  });
23
23
  const res = {
24
- fieldConfigMapDefinition,
24
+ fieldConfigMapDefinition
25
25
  };
26
26
  return res;
27
27
  };
@@ -1 +1 @@
1
- {"version":3,"file":"get-graphql-type-by-common-type.d.ts","sourceRoot":"","sources":["../../../../src/utils/get-new-fields/utils/get-graphql-type-by-common-type.ts"],"names":[],"mappings":"AAAA,UAAU,gCAAgC;IACxC,UAAU,EAAE,GAAG,CAAC;CACjB;AAED,UAAU,6BAA6B;IACrC,WAAW,EAAE,GAAG,CAAC;CAClB;AAED,KAAK,0BAA0B,GAAG,CAChC,MAAM,EAAE,gCAAgC,KACrC,6BAA6B,CAAC;AAEnC,eAAO,MAAM,0BAA0B,EAAE,0BAyBxC,CAAC"}
1
+ {"version":3,"file":"get-graphql-type-by-common-type.d.ts","sourceRoot":"","sources":["../../../../src/utils/get-new-fields/utils/get-graphql-type-by-common-type.ts"],"names":[],"mappings":"AAAA,UAAU,gCAAgC;IACxC,UAAU,EAAE,GAAG,CAAC;CACjB;AAED,UAAU,6BAA6B;IACrC,WAAW,EAAE,GAAG,CAAC;CAClB;AAED,KAAK,0BAA0B,GAAG,CAAC,MAAM,EAAE,gCAAgC,KAAK,6BAA6B,CAAC;AAE9G,eAAO,MAAM,0BAA0B,EAAE,0BAuBxC,CAAC"}
@@ -6,15 +6,15 @@ const getGraphqlTypeByCommonType = (params) => {
6
6
  const { type } = commonType;
7
7
  let graphqlType;
8
8
  switch (type) {
9
- case "string": {
10
- graphqlType = "String";
9
+ case 'string': {
10
+ graphqlType = 'String';
11
11
  break;
12
12
  }
13
13
  default:
14
14
  break;
15
15
  }
16
16
  const res = {
17
- graphqlType,
17
+ graphqlType
18
18
  };
19
19
  return res;
20
20
  };
@@ -1,4 +1,4 @@
1
- import { FieldTypeInfo } from "@ldsg/field-type";
1
+ import { FieldTypeInfo } from '@ldsg/field-type';
2
2
  interface GetGraphqlTypeByTypeInfoParams {
3
3
  typeInfo: FieldTypeInfo;
4
4
  }
@@ -1 +1 @@
1
- {"version":3,"file":"get-graphql-type-by-type-info.d.ts","sourceRoot":"","sources":["../../../../src/utils/get-new-fields/utils/get-graphql-type-by-type-info.ts"],"names":[],"mappings":"AAAA,OAAO,EAAyB,aAAa,EAAE,MAAM,kBAAkB,CAAC;AAGxE,UAAU,8BAA8B;IACtC,QAAQ,EAAE,aAAa,CAAC;CACzB;AAED,UAAU,2BAA2B;IACnC,WAAW,EAAE,GAAG,CAAC;CAClB;AAED,KAAK,wBAAwB,GAAG,CAC9B,MAAM,EAAE,8BAA8B,KACnC,2BAA2B,CAAC;AAEjC,eAAO,MAAM,wBAAwB,EAAE,wBAoBtC,CAAC"}
1
+ {"version":3,"file":"get-graphql-type-by-type-info.d.ts","sourceRoot":"","sources":["../../../../src/utils/get-new-fields/utils/get-graphql-type-by-type-info.ts"],"names":[],"mappings":"AAAA,OAAO,EAAyB,aAAa,EAAE,MAAM,kBAAkB,CAAC;AAGxE,UAAU,8BAA8B;IACtC,QAAQ,EAAE,aAAa,CAAC;CACzB;AAED,UAAU,2BAA2B;IACnC,WAAW,EAAE,GAAG,CAAC;CAClB;AAED,KAAK,wBAAwB,GAAG,CAAC,MAAM,EAAE,8BAA8B,KAAK,2BAA2B,CAAC;AAExG,eAAO,MAAM,wBAAwB,EAAE,wBAoBtC,CAAC"}
@@ -10,11 +10,11 @@ const getGraphqlTypeByTypeInfo = (params) => {
10
10
  if (!graphqlType) {
11
11
  const commonType = platformToTypeMap[field_type_1.FieldTypeBasePlatform.COMMON];
12
12
  graphqlType = (0, get_graphql_type_by_common_type_1.getGraphqlTypeByCommonType)({
13
- commonType,
13
+ commonType
14
14
  }).graphqlType;
15
15
  }
16
16
  const res = {
17
- graphqlType,
17
+ graphqlType
18
18
  };
19
19
  return res;
20
20
  };
@@ -1,6 +1,6 @@
1
- import { SchemaComposerParams } from "@ldsg/graphql";
2
- import { ObjectInfo } from "@ldsg/object";
3
- import { InputTypeComposer } from "graphql-compose";
1
+ import { SchemaComposerParams } from '@ldsg/graphql';
2
+ import { ObjectInfo } from '@ldsg/object';
3
+ import { InputTypeComposer } from 'graphql-compose';
4
4
  interface GetInputITCParams extends SchemaComposerParams {
5
5
  inputObjectInfo: ObjectInfo;
6
6
  }
@@ -1 +1 @@
1
- {"version":3,"file":"get-input-itc.d.ts","sourceRoot":"","sources":["../../../../src/utils/get-new-fields/utils/get-input-itc.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,oBAAoB,EAAE,MAAM,eAAe,CAAC;AACrD,OAAO,EAAE,UAAU,EAAE,MAAM,cAAc,CAAC;AAC1C,OAAO,EACL,iBAAiB,EAElB,MAAM,iBAAiB,CAAC;AAIzB,UAAU,iBAAkB,SAAQ,oBAAoB;IACtD,eAAe,EAAE,UAAU,CAAC;CAC7B;AAED,UAAU,cAAc;IACtB,QAAQ,EAAE,iBAAiB,CAAC,GAAG,CAAC,CAAC;CAClC;AAED,KAAK,WAAW,GAAG,CAAC,MAAM,EAAE,iBAAiB,KAAK,cAAc,CAAC;AAEjE,eAAO,MAAM,WAAW,EAAE,WAyBzB,CAAC"}
1
+ {"version":3,"file":"get-input-itc.d.ts","sourceRoot":"","sources":["../../../../src/utils/get-new-fields/utils/get-input-itc.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,oBAAoB,EAAE,MAAM,eAAe,CAAC;AACrD,OAAO,EAAE,UAAU,EAAE,MAAM,cAAc,CAAC;AAC1C,OAAO,EAAE,iBAAiB,EAA+B,MAAM,iBAAiB,CAAC;AAIjF,UAAU,iBAAkB,SAAQ,oBAAoB;IACtD,eAAe,EAAE,UAAU,CAAC;CAC7B;AAED,UAAU,cAAc;IACtB,QAAQ,EAAE,iBAAiB,CAAC,GAAG,CAAC,CAAC;CAClC;AAED,KAAK,WAAW,GAAG,CAAC,MAAM,EAAE,iBAAiB,KAAK,cAAc,CAAC;AAEjE,eAAO,MAAM,WAAW,EAAE,WAyBzB,CAAC"}
@@ -11,16 +11,16 @@ const getInputITC = (params) => {
11
11
  const { title, description, name, fieldInfoList } = inputObjectInfo;
12
12
  const upperFirstCamelCaseName = lodash_1.default.upperFirst(lodash_1.default.camelCase(name));
13
13
  const { fieldConfigMapDefinition } = (0, get_field_config_map_definition_1.getFieldConfigMapDefinition)({
14
- fieldInfoList,
14
+ fieldInfoList
15
15
  });
16
16
  const definition = {
17
17
  name: upperFirstCamelCaseName,
18
- fields: fieldConfigMapDefinition,
18
+ fields: fieldConfigMapDefinition
19
19
  };
20
20
  const inputITC = schemaComposer.createInputTC(definition);
21
- inputITC.setDescription(`${title}${description ? `:${description}` : ""}`);
21
+ inputITC.setDescription(`${title}${description ? `:${description}` : ''}`);
22
22
  const res = {
23
- inputITC,
23
+ inputITC
24
24
  };
25
25
  return res;
26
26
  };
@@ -1,6 +1,6 @@
1
- import { SchemaComposerParams } from "@ldsg/graphql";
2
- import { ObjectInfo } from "@ldsg/object";
3
- import { ObjectTypeComposer } from "graphql-compose";
1
+ import { SchemaComposerParams } from '@ldsg/graphql';
2
+ import { ObjectInfo } from '@ldsg/object';
3
+ import { ObjectTypeComposer } from 'graphql-compose';
4
4
  interface GetOutputOTCParams extends SchemaComposerParams {
5
5
  outputObjectInfo: ObjectInfo;
6
6
  }
@@ -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,EACL,kBAAkB,EAEnB,MAAM,iBAAiB,CAAC;AAIzB,UAAU,kBAAmB,SAAQ,oBAAoB;IACvD,gBAAgB,EAAE,UAAU,CAAC;CAC9B;AAED,UAAU,eAAe;IACvB,SAAS,EAAE,kBAAkB,CAAC,GAAG,EAAE,GAAG,CAAC,CAAC;CACzC;AAED,KAAK,YAAY,GAAG,CAAC,MAAM,EAAE,kBAAkB,KAAK,eAAe,CAAC;AAEpE,eAAO,MAAM,YAAY,EAAE,YAyB1B,CAAC"}
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"}
@@ -11,16 +11,22 @@ const getOutputOTC = (params) => {
11
11
  const { title, description, name, fieldInfoList } = outputObjectInfo;
12
12
  const upperFirstCamelCaseName = lodash_1.default.upperFirst(lodash_1.default.camelCase(name));
13
13
  const { fieldConfigMapDefinition } = (0, get_field_config_map_definition_1.getFieldConfigMapDefinition)({
14
- fieldInfoList,
14
+ fieldInfoList
15
15
  });
16
16
  const definition = {
17
17
  name: upperFirstCamelCaseName,
18
- fields: fieldConfigMapDefinition,
18
+ fields: fieldConfigMapDefinition
19
19
  };
20
20
  const outputOTC = schemaComposer.createObjectTC(definition);
21
- outputOTC.setDescription(`${title}${description ? `:${description}` : ""}`);
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
- outputOTC,
29
+ outputOTC
24
30
  };
25
31
  return res;
26
32
  };
@@ -1,3 +1,3 @@
1
- export * from "./get-input-itc";
2
- export * from "./get-output-otc";
1
+ export * from './get-input-itc';
2
+ export * from './get-output-otc';
3
3
  //# sourceMappingURL=index.d.ts.map
@@ -1,2 +1,3 @@
1
- export * from "./get-new-fields";
1
+ export * from './add-query-fields';
2
+ export * from './get-new-fields';
2
3
  //# sourceMappingURL=index.d.ts.map
@@ -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"}
@@ -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,40 +1,48 @@
1
1
  {
2
2
  "name": "@ldsg/forms",
3
- "version": "0.3.9",
3
+ "version": "0.3.11",
4
4
  "description": "",
5
+ "keywords": [],
6
+ "license": "MIT",
7
+ "author": "wanxger",
5
8
  "main": "dist/index.js",
9
+ "types": "dist",
6
10
  "files": [
7
11
  "dist/"
8
12
  ],
9
- "types": "dist",
10
- "keywords": [],
11
- "author": "wanxger",
12
- "license": "MIT",
13
- "publishConfig": {
14
- "access": "public"
15
- },
16
13
  "dependencies": {
14
+ "@formily/json-schema": "^2.3.1",
15
+ "json-schema": "^0.4.0",
17
16
  "lodash": "^4.17.21",
18
- "@ldsg/handler": "0.3.9",
19
- "@ldsg/resource": "0.3.9",
20
- "@ldsg/resource-definition": "0.3.9"
17
+ "@ldsg/field-type": "0.3.10",
18
+ "@ldsg/handler": "0.3.10",
19
+ "@ldsg/resource-definition": "0.3.10",
20
+ "@ldsg/resource": "0.3.10"
21
21
  },
22
22
  "devDependencies": {
23
+ "@types/jest": "^29.5.2",
24
+ "@types/json-schema": "^7.0.15",
23
25
  "@types/lodash": "^4.14.202",
24
26
  "@types/supertest": "^6.0.0",
25
27
  "graphql": "16.11.0",
26
28
  "graphql-compose": "^9.1.0",
29
+ "jest": "^29.5.0",
27
30
  "supertest": "^6.3.4",
28
- "@ldsg/application": "0.3.9",
29
- "@ldsg/field-type": "0.3.9",
30
- "@ldsg/graphql": "0.3.9",
31
- "@ldsg/object": "0.3.9",
32
- "@ldsg/object-field": "0.3.9",
33
- "@ldsg/types": "0.3.9",
34
- "@ldsg/workflow": "0.3.9"
31
+ "ts-jest": "^29.1.5",
32
+ "ts-node": "^10.9.2",
33
+ "typescript": "^5.8.3",
34
+ "@ldsg/graphql": "0.3.11",
35
+ "@ldsg/object": "0.3.10",
36
+ "@ldsg/object-field": "0.3.10",
37
+ "@ldsg/types": "0.3.10",
38
+ "@ldsg/workflow": "0.3.11"
39
+ },
40
+ "publishConfig": {
41
+ "access": "public"
35
42
  },
36
43
  "scripts": {
37
44
  "build": "tsc --project tsconfig.build.json",
38
- "clean": "rm -rf dist"
45
+ "clean": "rm -rf dist",
46
+ "test": "jest"
39
47
  }
40
48
  }