@ldsg/workflow 0.3.31 → 0.3.32

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 (33) hide show
  1. package/dist/__tests__/unit/evaluate-variables.prefixItems.test.js +197 -191
  2. package/dist/__tests__/unit/resource.js +61 -61
  3. package/dist/__tests__/unit/resource.portId.test.js +144 -144
  4. package/dist/constants.d.ts +3 -3
  5. package/dist/constants.d.ts.map +1 -1
  6. package/dist/constants.js +10 -10
  7. package/dist/handler.d.ts +4 -4
  8. package/dist/index.d.ts +5 -5
  9. package/dist/instantiate-resource.d.ts +4 -4
  10. package/dist/instantiate-resource.js +1 -1
  11. package/dist/resource.d.ts +2 -2
  12. package/dist/resource.js +12 -12
  13. package/dist/types/index.d.ts +6 -6
  14. package/dist/types/json_schema_with_expression_extension.d.ts +6 -6
  15. package/dist/types/json_schema_with_expression_extension.d.ts.map +1 -1
  16. package/dist/types/node.d.ts +1 -1
  17. package/dist/types/specific-resource-settings.d.ts +1 -1
  18. package/dist/types/specific-resource-settings.d.ts.map +1 -1
  19. package/dist/types/specific-resource-settings.js +1 -1
  20. package/dist/types/workflow.d.ts +3 -3
  21. package/dist/utils/evaluate-variables/constants.js +17 -17
  22. package/dist/utils/evaluate-variables/index.d.ts +1 -1
  23. package/dist/utils/evaluate-variables/index.debug.js +79 -79
  24. package/dist/utils/evaluate-variables/index.js +2 -2
  25. package/dist/utils/evaluate-variables/utils/get-data-with-json-schema-and-input/index.d.ts +1 -1
  26. package/dist/utils/evaluate-variables/utils/get-data-with-json-schema-and-input/index.js +2 -2
  27. package/dist/utils/evaluate-variables/utils/get-data-with-json-schema-and-input/resolve-json-schema.d.ts +1 -1
  28. package/dist/utils/evaluate-variables/utils/get-data-with-json-schema-and-input/resolve-json-schema.js +11 -11
  29. package/dist/utils/evaluate-variables/utils/get-field-path-by-field-type-key.js +3 -3
  30. package/dist/utils/execute-workflow.d.ts +2 -2
  31. package/dist/utils/execute-workflow.d.ts.map +1 -1
  32. package/dist/utils/execute-workflow.js +19 -17
  33. package/package.json +11 -7
package/dist/constants.js CHANGED
@@ -6,8 +6,8 @@ exports.SPECIFIC_WORKFLOW_NODE_TYPE_TO_WORKFLOW_NODE_TYPE_RESOURCE_ID_MAP = expo
6
6
  * 实例化资源处理程序普通资源配置
7
7
  */
8
8
  exports.INSTANTIATE_RESOURCE_HANDLER_GENERAL_RESOURCE_SETTINGS = {
9
- title: '工作流实例化资源处理程序',
10
- description: ''
9
+ title: "工作流实例化资源处理程序",
10
+ description: "",
11
11
  };
12
12
  /**
13
13
  * Instantiate Resource Handler Specific Resource Settings
@@ -18,21 +18,21 @@ exports.INSTANTIATE_RESOURCE_HANDLER_SPECIFIC_RESOURCE_SETTINGS = {
18
18
  code: `export * from "@ldsg/workflow";`,
19
19
  dependencies: [
20
20
  {
21
- name: '@ldsg/workflow'
22
- }
23
- ]
21
+ name: "@ldsg/workflow",
22
+ },
23
+ ],
24
24
  };
25
25
  exports.RESOURCE_DEFINITION_GENERAL_RESOURCE_SETTINGS = {
26
- title: '工作流资源定义',
27
- description: ''
26
+ title: "工作流资源定义",
27
+ description: "",
28
28
  };
29
29
  exports.RESOURCE_DEFINITION_SPECIFIC_RESOURCE_SETTINGS = {
30
- kind: 'workflow'
30
+ kind: "workflow",
31
31
  };
32
32
  /**
33
33
  * Specific Workflow Node Type Id Map
34
34
  */
35
35
  exports.SPECIFIC_WORKFLOW_NODE_TYPE_TO_WORKFLOW_NODE_TYPE_RESOURCE_ID_MAP = {
36
- start: 'start-workflow-node-type',
37
- end: 'end-workflow-node-type'
36
+ start: "start-workflow-node-type",
37
+ end: "end-workflow-node-type",
38
38
  };
package/dist/handler.d.ts CHANGED
@@ -1,6 +1,6 @@
1
- import { Handler, HandlerExtendedResourceSettings } from '@ldsg/handler';
2
- import { InstantiateResourceParams, InstantiateResourceRes } from '@ldsg/resource';
3
- import { WorkflowResource } from './resource';
4
- import { WorkflowSpecificResourceSettings } from './types';
1
+ import { Handler, HandlerExtendedResourceSettings } from "@ldsg/handler";
2
+ import { InstantiateResourceParams, InstantiateResourceRes } from "@ldsg/resource";
3
+ import { WorkflowResource } from "./resource";
4
+ import { WorkflowSpecificResourceSettings } from "./types";
5
5
  export declare const handler: Handler<InstantiateResourceParams<HandlerExtendedResourceSettings<WorkflowSpecificResourceSettings>>, InstantiateResourceRes<WorkflowResource>>;
6
6
  //# sourceMappingURL=handler.d.ts.map
package/dist/index.d.ts CHANGED
@@ -1,6 +1,6 @@
1
- export * from './constants';
2
- export * from './handler';
3
- export * from './instantiate-resource';
4
- export * from './resource';
5
- export * from './types';
1
+ export * from "./constants";
2
+ export * from "./handler";
3
+ export * from "./instantiate-resource";
4
+ export * from "./resource";
5
+ export * from "./types";
6
6
  //# sourceMappingURL=index.d.ts.map
@@ -1,6 +1,6 @@
1
- import { HandlerExtendedResourceSettings } from '@ldsg/handler';
2
- import { InstantiateResource } from '@ldsg/resource';
3
- import { WorkflowResource } from './resource';
4
- import { WorkflowSpecificResourceSettings } from './types';
1
+ import { HandlerExtendedResourceSettings } from "@ldsg/handler";
2
+ import { InstantiateResource } from "@ldsg/resource";
3
+ import { WorkflowResource } from "./resource";
4
+ import { WorkflowSpecificResourceSettings } from "./types";
5
5
  export declare const instantiateResource: InstantiateResource<HandlerExtendedResourceSettings<WorkflowSpecificResourceSettings>, WorkflowResource>;
6
6
  //# sourceMappingURL=instantiate-resource.d.ts.map
@@ -6,7 +6,7 @@ const instantiateResource = (params) => {
6
6
  const { resourceConstructorParams } = params;
7
7
  const resource = new resource_1.WorkflowResource(resourceConstructorParams);
8
8
  const res = {
9
- resource
9
+ resource,
10
10
  };
11
11
  return res;
12
12
  };
@@ -1,5 +1,5 @@
1
- import { Resource } from '@ldsg/resource';
2
- import { WorkflowData, WorkflowEdgeInfo, WorkflowExecute, WorkflowInfo, WorkflowNodeInfo, WorkflowSpecificResourceSettings } from './types';
1
+ import { Resource } from "@ldsg/resource";
2
+ import { WorkflowData, WorkflowEdgeInfo, WorkflowExecute, WorkflowInfo, WorkflowNodeInfo, WorkflowSpecificResourceSettings } from "./types";
3
3
  export interface GetWorkflowEdgeInfoListRes {
4
4
  workflowEdgeInfoList: WorkflowEdgeInfo[];
5
5
  }
package/dist/resource.js CHANGED
@@ -13,32 +13,32 @@ class WorkflowResource extends resource_1.Resource {
13
13
  this.getWorkflowEdgeInfoList = () => {
14
14
  const { id, getFilteredResources } = this;
15
15
  const { resources } = getFilteredResources({
16
- parentId: id
16
+ parentId: id,
17
17
  });
18
18
  const mapRes = resources.map((resource) => {
19
19
  var _a;
20
20
  return (_a = resource.getWorkflowEdgeInfo) === null || _a === void 0 ? void 0 : _a.call(resource);
21
21
  });
22
22
  const getWorkflowEdgeInfoResList = lodash_1.default.filter(mapRes, (value) => !lodash_1.default.isUndefined(value));
23
- const workflowEdgeInfoList = lodash_1.default.map(getWorkflowEdgeInfoResList, 'workflowEdgeInfo');
23
+ const workflowEdgeInfoList = lodash_1.default.map(getWorkflowEdgeInfoResList, "workflowEdgeInfo");
24
24
  const res = {
25
- workflowEdgeInfoList
25
+ workflowEdgeInfoList,
26
26
  };
27
27
  return res;
28
28
  };
29
29
  this.getWorkflowNodeInfoList = () => {
30
30
  const { id, getFilteredResources } = this;
31
31
  const { resources } = getFilteredResources({
32
- parentId: id
32
+ parentId: id,
33
33
  });
34
34
  const mapRes = resources.map((resource) => {
35
35
  var _a;
36
36
  return (_a = resource.getWorkflowNodeInfo) === null || _a === void 0 ? void 0 : _a.call(resource);
37
37
  });
38
38
  const filterRes = lodash_1.default.filter(mapRes, (value) => !lodash_1.default.isUndefined(value));
39
- const workflowNodeInfoList = lodash_1.default.map(filterRes, 'workflowNodeInfo');
39
+ const workflowNodeInfoList = lodash_1.default.map(filterRes, "workflowNodeInfo");
40
40
  const res = {
41
- workflowNodeInfoList
41
+ workflowNodeInfoList,
42
42
  };
43
43
  return res;
44
44
  };
@@ -48,16 +48,16 @@ class WorkflowResource extends resource_1.Resource {
48
48
  const { workflowNodeInfoList } = getWorkflowNodeInfoList();
49
49
  const workflowData = {
50
50
  edges: workflowEdgeInfoList,
51
- nodes: workflowNodeInfoList
51
+ nodes: workflowNodeInfoList,
52
52
  };
53
53
  const res = {
54
- workflowData
54
+ workflowData,
55
55
  };
56
56
  return res;
57
57
  };
58
58
  this.execute = async (params) => {
59
59
  const { context, presetWorkflowVariables, variables, traceContext } = params;
60
- const { getWorkflowData, settings: { startWorkflowNodeResourceId, endWorkflowNodeResourceId } } = this;
60
+ const { getWorkflowData, settings: { startWorkflowNodeResourceId, endWorkflowNodeResourceId }, } = this;
61
61
  const { workflowData } = getWorkflowData();
62
62
  const { nodes, edges } = workflowData;
63
63
  return (0, execute_workflow_1.executeWorkflow)({
@@ -69,16 +69,16 @@ class WorkflowResource extends resource_1.Resource {
69
69
  startWorkflowNodeResourceId,
70
70
  variables,
71
71
  workflowData,
72
- traceContext
72
+ traceContext,
73
73
  });
74
74
  };
75
75
  this.getWorkflowInfo = () => {
76
76
  const { execute } = this;
77
77
  const workflowInfo = {
78
- execute
78
+ execute,
79
79
  };
80
80
  const res = {
81
- workflowInfo
81
+ workflowInfo,
82
82
  };
83
83
  return res;
84
84
  };
@@ -1,7 +1,7 @@
1
- export * from './edge';
2
- export * from './json_schema_with_expression_extension';
3
- export * from './node';
4
- export * from './specific-resource-settings';
5
- export * from './variables';
6
- export * from './workflow';
1
+ export * from "./edge";
2
+ export * from "./json_schema_with_expression_extension";
3
+ export * from "./node";
4
+ export * from "./specific-resource-settings";
5
+ export * from "./variables";
6
+ export * from "./workflow";
7
7
  //# sourceMappingURL=index.d.ts.map
@@ -1,17 +1,17 @@
1
- import { JSONSchema7, JSONSchema7TypeName } from 'json-schema';
2
- export type JSONSchemaWithExpressionExtensionType = JSONSchema7TypeName | 'any';
1
+ import { JSONSchema7, JSONSchema7TypeName } from "json-schema";
2
+ export type JSONSchemaWithExpressionExtensionType = JSONSchema7TypeName | "any";
3
3
  /**
4
4
  * JSON Schema with Expression Extension
5
5
  */
6
- export interface JSONSchemaWithExpressionExtension extends Omit<JSONSchema7, 'type' | 'items' | 'properties'> {
6
+ export interface JSONSchemaWithExpressionExtension extends Omit<JSONSchema7, "type" | "items" | "properties"> {
7
7
  type?: JSONSchemaWithExpressionExtensionType;
8
8
  properties?: {
9
9
  [key: string]: JSONSchemaWithExpressionExtension;
10
10
  };
11
11
  items?: JSONSchemaWithExpressionExtension | JSONSchemaWithExpressionExtension[];
12
12
  prefixItems?: JSONSchemaWithExpressionExtension[];
13
- 'x-expression'?: string;
14
- 'x-expression-const'?: string;
15
- 'x-expression-default'?: string;
13
+ "x-expression"?: string;
14
+ "x-expression-const"?: string;
15
+ "x-expression-default"?: string;
16
16
  }
17
17
  //# sourceMappingURL=json_schema_with_expression_extension.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"json_schema_with_expression_extension.d.ts","sourceRoot":"","sources":["../../src/types/json_schema_with_expression_extension.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAE,mBAAmB,EAAE,MAAM,aAAa,CAAC;AAE/D,MAAM,MAAM,qCAAqC,GAAG,mBAAmB,GAAG,KAAK,CAAC;AAEhF;;GAEG;AACH,MAAM,WAAW,iCACf,SAAQ,IAAI,CAAC,WAAW,EAAE,MAAM,GAAG,OAAO,GAAG,YAAY,CAAC;IAC1D,IAAI,CAAC,EAAE,qCAAqC,CAAC;IAE7C,UAAU,CAAC,EAAE;QACX,CAAC,GAAG,EAAE,MAAM,GAAG,iCAAiC,CAAC;KAClD,CAAC;IAEF,KAAK,CAAC,EAAE,iCAAiC,GAAG,iCAAiC,EAAE,CAAC;IAEhF,WAAW,CAAC,EAAE,iCAAiC,EAAE,CAAC;IAElD,cAAc,CAAC,EAAE,MAAM,CAAC;IACxB,oBAAoB,CAAC,EAAE,MAAM,CAAC;IAC9B,sBAAsB,CAAC,EAAE,MAAM,CAAC;CACjC"}
1
+ {"version":3,"file":"json_schema_with_expression_extension.d.ts","sourceRoot":"","sources":["../../src/types/json_schema_with_expression_extension.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAE,mBAAmB,EAAE,MAAM,aAAa,CAAC;AAE/D,MAAM,MAAM,qCAAqC,GAAG,mBAAmB,GAAG,KAAK,CAAC;AAEhF;;GAEG;AACH,MAAM,WAAW,iCAAkC,SAAQ,IAAI,CAC7D,WAAW,EACX,MAAM,GAAG,OAAO,GAAG,YAAY,CAChC;IACC,IAAI,CAAC,EAAE,qCAAqC,CAAC;IAE7C,UAAU,CAAC,EAAE;QACX,CAAC,GAAG,EAAE,MAAM,GAAG,iCAAiC,CAAC;KAClD,CAAC;IAEF,KAAK,CAAC,EAAE,iCAAiC,GAAG,iCAAiC,EAAE,CAAC;IAEhF,WAAW,CAAC,EAAE,iCAAiC,EAAE,CAAC;IAElD,cAAc,CAAC,EAAE,MAAM,CAAC;IACxB,oBAAoB,CAAC,EAAE,MAAM,CAAC;IAC9B,sBAAsB,CAAC,EAAE,MAAM,CAAC;CACjC"}
@@ -1,4 +1,4 @@
1
- import { JSONSchemaWithExpressionExtension } from './json_schema_with_expression_extension';
1
+ import { JSONSchemaWithExpressionExtension } from "./json_schema_with_expression_extension";
2
2
  export type WorkflowNodeExecuterExecute = () => void | Promise<void>;
3
3
  export interface WorkflowNodeExecuteParams<Variables = any, Context = any> {
4
4
  /**
@@ -1,4 +1,4 @@
1
- import { z } from 'zod';
1
+ import { z } from "zod";
2
2
  export declare const WorkflowSpecificResourceSettingsSchema: z.ZodObject<{
3
3
  startWorkflowNodeResourceId: z.ZodString;
4
4
  endWorkflowNodeResourceId: z.ZodString;
@@ -1 +1 @@
1
- {"version":3,"file":"specific-resource-settings.d.ts","sourceRoot":"","sources":["../../src/types/specific-resource-settings.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAExB,eAAO,MAAM,sCAAsC;;;8BAY/B,CAAC;AAErB,eAAO,MAAM,8BAA8B;;;8BAAyC,CAAC;AACrF,MAAM,MAAM,gCAAgC,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,sCAAsC,CAAC,CAAC"}
1
+ {"version":3,"file":"specific-resource-settings.d.ts","sourceRoot":"","sources":["../../src/types/specific-resource-settings.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAExB,eAAO,MAAM,sCAAsC;;;8BAY/B,CAAC;AAErB,eAAO,MAAM,8BAA8B;;;8BAAyC,CAAC;AACrF,MAAM,MAAM,gCAAgC,GAAG,CAAC,CAAC,KAAK,CACpD,OAAO,sCAAsC,CAC9C,CAAC"}
@@ -11,7 +11,7 @@ exports.WorkflowSpecificResourceSettingsSchema = zod_1.z
11
11
  /**
12
12
  * End Workflow Node Resource ID
13
13
  */
14
- endWorkflowNodeResourceId: zod_1.z.string()
14
+ endWorkflowNodeResourceId: zod_1.z.string(),
15
15
  })
16
16
  .catchall(zod_1.z.any());
17
17
  exports.SpecificResourceSettingsSchema = exports.WorkflowSpecificResourceSettingsSchema;
@@ -1,6 +1,6 @@
1
- import { WorkflowEdgeInfo } from './edge';
2
- import { WorkflowNodeInfo } from './node';
3
- import { WorkflowVariables } from './variables';
1
+ import { WorkflowEdgeInfo } from "./edge";
2
+ import { WorkflowNodeInfo } from "./node";
3
+ import { WorkflowVariables } from "./variables";
4
4
  export interface WorkflowData {
5
5
  edges: WorkflowEdgeInfo[];
6
6
  nodes: WorkflowNodeInfo[];
@@ -6,7 +6,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
6
6
  exports.FIELD_VALUE_RETRIEVAL_METHODS = void 0;
7
7
  const jsonata_1 = __importDefault(require("jsonata"));
8
8
  const expressionHandle = async (params) => {
9
- const { input, retrievalMethodValue, returnExpressionAsData, objectExpression
9
+ const { input, retrievalMethodValue, returnExpressionAsData, objectExpression,
10
10
  // expressionMayContainObject
11
11
  } = params;
12
12
  /**
@@ -14,17 +14,17 @@ const expressionHandle = async (params) => {
14
14
  */
15
15
  if (returnExpressionAsData) {
16
16
  return {
17
- expression: retrievalMethodValue
17
+ expression: retrievalMethodValue,
18
18
  };
19
19
  }
20
20
  let jsonataStr = retrievalMethodValue;
21
21
  if (objectExpression) {
22
- jsonataStr = retrievalMethodValue.replace('{}', objectExpression);
22
+ jsonataStr = retrievalMethodValue.replace("{}", objectExpression);
23
23
  }
24
24
  const expression = (0, jsonata_1.default)(jsonataStr);
25
25
  const data = await expression.evaluate(input);
26
26
  const res = {
27
- data
27
+ data,
28
28
  };
29
29
  return res;
30
30
  };
@@ -33,37 +33,37 @@ const expressionHandle = async (params) => {
33
33
  */
34
34
  exports.FIELD_VALUE_RETRIEVAL_METHODS = [
35
35
  {
36
- name: 'const',
36
+ name: "const",
37
37
  handle: (params) => {
38
38
  const { retrievalMethodValue } = params;
39
39
  const res = {
40
40
  const: retrievalMethodValue,
41
- data: retrievalMethodValue
41
+ data: retrievalMethodValue,
42
42
  };
43
43
  return res;
44
- }
44
+ },
45
45
  },
46
46
  {
47
- name: 'x-expression-const',
48
- handle: expressionHandle
47
+ name: "x-expression-const",
48
+ handle: expressionHandle,
49
49
  },
50
50
  {
51
- name: 'x-expression',
52
- handle: expressionHandle
51
+ name: "x-expression",
52
+ handle: expressionHandle,
53
53
  },
54
54
  {
55
- name: 'x-expression-default',
56
- handle: expressionHandle
55
+ name: "x-expression-default",
56
+ handle: expressionHandle,
57
57
  },
58
58
  {
59
- name: 'default',
59
+ name: "default",
60
60
  handle: (params) => {
61
61
  const { retrievalMethodValue } = params;
62
62
  const res = {
63
63
  default: retrievalMethodValue,
64
- data: retrievalMethodValue
64
+ data: retrievalMethodValue,
65
65
  };
66
66
  return res;
67
- }
68
- }
67
+ },
68
+ },
69
69
  ];
@@ -1,4 +1,4 @@
1
- import { JSONSchemaWithExpressionExtension } from '../../types';
1
+ import { JSONSchemaWithExpressionExtension } from "../../types";
2
2
  interface EvaluateVariablesParams {
3
3
  jsonSchema: JSONSchemaWithExpressionExtension;
4
4
  variables: any;
@@ -8,187 +8,187 @@ const path_1 = __importDefault(require("path"));
8
8
  const _1 = require(".");
9
9
  const input = {
10
10
  Account: {
11
- 'Account Name': 'Firefly',
11
+ "Account Name": "Firefly",
12
12
  Order: [
13
13
  {
14
- OrderID: 'order103',
14
+ OrderID: "order103",
15
15
  Product: [
16
16
  {
17
- 'Product Name': 'Bowler Hat',
17
+ "Product Name": "Bowler Hat",
18
18
  ProductID: 858383,
19
- SKU: '0406654608',
19
+ SKU: "0406654608",
20
20
  Description: {
21
- Colour: 'Purple',
21
+ Colour: "Purple",
22
22
  Width: 300,
23
23
  Height: 200,
24
24
  Depth: 210,
25
- Weight: 0.75
25
+ Weight: 0.75,
26
26
  },
27
27
  Price: 34.45,
28
- Quantity: 2
28
+ Quantity: 2,
29
29
  },
30
30
  {
31
- 'Product Name': 'Trilby hat',
31
+ "Product Name": "Trilby hat",
32
32
  ProductID: 858236,
33
- SKU: '0406634348',
33
+ SKU: "0406634348",
34
34
  Description: {
35
- Colour: 'Orange',
35
+ Colour: "Orange",
36
36
  Width: 300,
37
37
  Height: 200,
38
38
  Depth: 210,
39
- Weight: 0.6
39
+ Weight: 0.6,
40
40
  },
41
41
  Price: 21.67,
42
- Quantity: 1
43
- }
44
- ]
42
+ Quantity: 1,
43
+ },
44
+ ],
45
45
  },
46
46
  {
47
- OrderID: 'order104',
47
+ OrderID: "order104",
48
48
  Product: [
49
49
  {
50
- 'Product Name': 'Bowler Hat',
50
+ "Product Name": "Bowler Hat",
51
51
  ProductID: 858383,
52
- SKU: '040657863',
52
+ SKU: "040657863",
53
53
  Description: {
54
- Colour: 'Purple',
54
+ Colour: "Purple",
55
55
  Width: 300,
56
56
  Height: 200,
57
57
  Depth: 210,
58
- Weight: 0.75
58
+ Weight: 0.75,
59
59
  },
60
60
  Price: 34.45,
61
- Quantity: 4
61
+ Quantity: 4,
62
62
  },
63
63
  {
64
64
  ProductID: 345664,
65
- SKU: '0406654603',
66
- 'Product Name': 'Cloak',
65
+ SKU: "0406654603",
66
+ "Product Name": "Cloak",
67
67
  Description: {
68
- Colour: 'Black',
68
+ Colour: "Black",
69
69
  Width: 30,
70
70
  Height: 20,
71
71
  Depth: 210,
72
- Weight: 2
72
+ Weight: 2,
73
73
  },
74
74
  Price: 107.99,
75
- Quantity: 1
76
- }
77
- ]
78
- }
79
- ]
80
- }
75
+ Quantity: 1,
76
+ },
77
+ ],
78
+ },
79
+ ],
80
+ },
81
81
  };
82
82
  const subJsonSchema = {
83
- type: 'object',
83
+ type: "object",
84
84
  properties: {
85
85
  CurrentAccount: {
86
- type: 'string',
86
+ type: "string",
87
87
  /**
88
88
  * 从默认值内取值
89
89
  */
90
- default: 'Current Account',
91
- const: 'Current Account'
90
+ default: "Current Account",
91
+ const: "Current Account",
92
92
  },
93
93
  type: {
94
- type: 'string',
95
- default: 'order',
96
- const: 'order'
94
+ type: "string",
95
+ default: "order",
96
+ const: "order",
97
97
  },
98
98
  AccountName: {
99
- type: 'string',
99
+ type: "string",
100
100
  /**
101
101
  * 根据 jsonata 取值
102
102
  */
103
- 'x-expression': `Account."Account Name"`
103
+ "x-expression": `Account."Account Name"`,
104
104
  },
105
105
  CurrentOrder: {
106
- type: 'string',
106
+ type: "string",
107
107
  /**
108
108
  * 根据 jsonata 取值
109
109
  */
110
- 'x-expression': `"Current Order"`
110
+ "x-expression": `"Current Order"`,
111
111
  },
112
112
  OrderPrice: {
113
- type: 'number',
114
- 'x-expression': '$sum(Account.Order.Product.(Price * Quantity))'
113
+ type: "number",
114
+ "x-expression": "$sum(Account.Order.Product.(Price * Quantity))",
115
115
  },
116
116
  ProductIds: {
117
- type: 'array',
117
+ type: "array",
118
118
  items: {
119
- type: 'number'
119
+ type: "number",
120
120
  },
121
- 'x-expression': 'Account.Order.Product.ProductID'
121
+ "x-expression": "Account.Order.Product.ProductID",
122
122
  },
123
123
  ordersWithProductIds: {
124
- type: 'array',
125
- title: '具有产品 ID 的订单列表',
124
+ type: "array",
125
+ title: "具有产品 ID 的订单列表",
126
126
  items: {
127
- type: 'object',
127
+ type: "object",
128
128
  properties: {
129
129
  CurrentOrdersWithProductIdsTitle: {
130
- type: 'string',
130
+ type: "string",
131
131
  /**
132
132
  * 从默认值内取值
133
133
  */
134
- default: 'CurrentOrdersWithProductIdsTitle',
135
- const: 'CurrentOrdersWithProductIdsTitle'
134
+ default: "CurrentOrdersWithProductIdsTitle",
135
+ const: "CurrentOrdersWithProductIdsTitle",
136
136
  },
137
137
  productIds: {
138
- type: 'array',
138
+ type: "array",
139
139
  items: {
140
- type: 'number'
140
+ type: "number",
141
141
  },
142
- 'x-expression': '$v.Product.ProductID'
142
+ "x-expression": "$v.Product.ProductID",
143
143
  },
144
144
  AccountName: {
145
- type: 'string',
145
+ type: "string",
146
146
  /**
147
147
  * 根据 jsonata 取值
148
148
  */
149
- 'x-expression': `Account."Account Name"`
149
+ "x-expression": `Account."Account Name"`,
150
150
  },
151
151
  orderId: {
152
- type: 'string',
153
- 'x-expression': '$v.OrderID'
154
- }
155
- }
152
+ type: "string",
153
+ "x-expression": "$v.OrderID",
154
+ },
155
+ },
156
156
  },
157
- 'x-expression': '$map($.Account.Order, function($v, $i, $a) {{}})'
158
- }
159
- }
157
+ "x-expression": "$map($.Account.Order, function($v, $i, $a) {{}})",
158
+ },
159
+ },
160
160
  };
161
161
  const jsonSchema = {
162
- type: 'object',
162
+ type: "object",
163
163
  properties: {
164
164
  ...subJsonSchema.properties,
165
165
  nestd: {
166
- type: 'object',
166
+ type: "object",
167
167
  properties: {
168
168
  ...subJsonSchema.properties,
169
169
  nestd: {
170
- type: 'object',
170
+ type: "object",
171
171
  properties: {
172
172
  ...subJsonSchema.properties,
173
173
  nestd: {
174
- type: 'object',
174
+ type: "object",
175
175
  properties: {
176
- ...subJsonSchema.properties
177
- }
178
- }
179
- }
180
- }
181
- }
182
- }
183
- }
176
+ ...subJsonSchema.properties,
177
+ },
178
+ },
179
+ },
180
+ },
181
+ },
182
+ },
183
+ },
184
184
  };
185
185
  const main = async () => {
186
186
  const evaluateVariablesRes = await (0, _1.evaluateVariables)({
187
187
  jsonSchema,
188
- variables: input
188
+ variables: input,
189
189
  });
190
- await fs_extra_1.default.writeJson(path_1.default.resolve(__dirname, 'evaluate-variables-res.json'), evaluateVariablesRes, {
191
- spaces: 2
190
+ await fs_extra_1.default.writeJson(path_1.default.resolve(__dirname, "evaluate-variables-res.json"), evaluateVariablesRes, {
191
+ spaces: 2,
192
192
  });
193
193
  };
194
194
  main();
@@ -6,11 +6,11 @@ const evaluateVariables = async (params) => {
6
6
  const { jsonSchema, variables: paramsVariables } = params;
7
7
  const getDataWithJsonSchemaAndInputRes = await (0, get_data_with_json_schema_and_input_1.getDataWithJsonSchemaAndInput)({
8
8
  jsonSchema,
9
- input: paramsVariables
9
+ input: paramsVariables,
10
10
  });
11
11
  const variables = getDataWithJsonSchemaAndInputRes.data;
12
12
  const res = {
13
- variables
13
+ variables,
14
14
  };
15
15
  return res;
16
16
  };
@@ -1,4 +1,4 @@
1
- import { JSONSchemaWithExpressionExtension } from '../../../../types';
1
+ import { JSONSchemaWithExpressionExtension } from "../../../../types";
2
2
  interface GetDataWithJsonSchemaAndInputParams {
3
3
  /**
4
4
  * 输入