@ldsg/graphql-workflows 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.
- package/dist/constants.d.ts +0 -1
- package/dist/constants.d.ts.map +1 -1
- package/dist/constants.js +3 -2
- package/dist/resource.d.ts.map +1 -1
- package/dist/resource.js +20 -52
- package/package.json +8 -8
package/dist/constants.d.ts
CHANGED
|
@@ -14,5 +14,4 @@ export declare const INSTANTIATE_RESOURCE_HANDLER_GENERAL_RESOURCE_SETTINGS: Gen
|
|
|
14
14
|
export declare const INSTANTIATE_RESOURCE_HANDLER_SPECIFIC_RESOURCE_SETTINGS: HandlerSpecificResourceSettings;
|
|
15
15
|
export declare const RESOURCE_DEFINITION_GENERAL_RESOURCE_SETTINGS: GeneralResourceSettings;
|
|
16
16
|
export declare const RESOURCE_DEFINITION_SPECIFIC_RESOURCE_SETTINGS: ResourceDefinitionSpecificResourceSettings;
|
|
17
|
-
export declare const GRAPHQL_GLOBAL_WORKFLOW_PATH_INFO_STRING = "*:*";
|
|
18
17
|
//# sourceMappingURL=constants.d.ts.map
|
package/dist/constants.d.ts.map
CHANGED
|
@@ -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,
|
|
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"}
|
package/dist/constants.js
CHANGED
|
@@ -1,11 +1,12 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.
|
|
3
|
+
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: "graphql-workflows-instantiate-resource-handler",
|
|
9
10
|
title: "GraphQL工作流组实例化资源处理程序",
|
|
10
11
|
description: "",
|
|
11
12
|
};
|
|
@@ -23,10 +24,10 @@ exports.INSTANTIATE_RESOURCE_HANDLER_SPECIFIC_RESOURCE_SETTINGS = {
|
|
|
23
24
|
],
|
|
24
25
|
};
|
|
25
26
|
exports.RESOURCE_DEFINITION_GENERAL_RESOURCE_SETTINGS = {
|
|
27
|
+
slug: "graphql-workflows-resource-definition",
|
|
26
28
|
title: "GraphQL工作流组资源定义",
|
|
27
29
|
description: "",
|
|
28
30
|
};
|
|
29
31
|
exports.RESOURCE_DEFINITION_SPECIFIC_RESOURCE_SETTINGS = {
|
|
30
32
|
kind: "graphql_workflows",
|
|
31
33
|
};
|
|
32
|
-
exports.GRAPHQL_GLOBAL_WORKFLOW_PATH_INFO_STRING = "*:*";
|
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,wBAAwB,EAAyB,MAAM,eAAe,CAAC;AAChF,OAAO,EAAE,QAAQ,EAAE,MAAM,gBAAgB,CAAC;
|
|
1
|
+
{"version":3,"file":"resource.d.ts","sourceRoot":"","sources":["../src/resource.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,wBAAwB,EAAyB,MAAM,eAAe,CAAC;AAChF,OAAO,EAAE,QAAQ,EAAE,MAAM,gBAAgB,CAAC;AAE1C,OAAO,EAA0B,wCAAwC,EAAE,MAAM,SAAS,CAAC;AAE3F,qBAAa,wBAAyB,SAAQ,QAAQ,CAAC,wCAAwC,CAAC;IAC9F,wBAAwB,EAAE,wBAAwB,CAyDhD;CACH"}
|
package/dist/resource.js
CHANGED
|
@@ -2,55 +2,21 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.GraphqlWorkflowsResource = void 0;
|
|
4
4
|
const resource_1 = require("@ldsg/resource");
|
|
5
|
-
const constants_1 = require("./constants");
|
|
6
|
-
const utils_1 = require("./utils");
|
|
7
5
|
class GraphqlWorkflowsResource extends resource_1.Resource {
|
|
8
6
|
constructor() {
|
|
9
7
|
super(...arguments);
|
|
10
8
|
this.getGraphqlMiddlewareInfo = () => {
|
|
11
|
-
const {
|
|
12
|
-
const
|
|
13
|
-
|
|
9
|
+
const { getFilteredResources } = this;
|
|
10
|
+
const middleware = {};
|
|
11
|
+
const getGraphqlWorkflowInfoResList = getFilteredResources({
|
|
12
|
+
kind: "graphql_workflow",
|
|
13
|
+
}).resources.map((resource) => {
|
|
14
|
+
const graphqlWorkflowInfo = resource.getGraphqlWorkflowInfo();
|
|
15
|
+
return graphqlWorkflowInfo;
|
|
14
16
|
});
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
const graphqlWorkflowInfo = (_a = resource.getGraphqlWorkflowInfo) === null || _a === void 0 ? void 0 : _a.call(resource);
|
|
19
|
-
if (graphqlWorkflowInfo) {
|
|
20
|
-
const { fieldName, typeName, workflowInfo } = graphqlWorkflowInfo;
|
|
21
|
-
const graphqlPathInfoString = `${typeName}:${fieldName}`;
|
|
22
|
-
graphqlPathInfoStringToWorkflowInfoMap[graphqlPathInfoString] = workflowInfo;
|
|
23
|
-
}
|
|
24
|
-
});
|
|
25
|
-
/**
|
|
26
|
-
* GraphQL 全局工作流
|
|
27
|
-
*/
|
|
28
|
-
const graphqlGlobalWorkflowInfo = graphqlPathInfoStringToWorkflowInfoMap[constants_1.GRAPHQL_GLOBAL_WORKFLOW_PATH_INFO_STRING];
|
|
29
|
-
const workflowMiddleware = async (resolve, source, args, context, info) => {
|
|
30
|
-
const { graphqlPathInfoString } = (0, utils_1.getGraphqlPathInfoString)({
|
|
31
|
-
info,
|
|
32
|
-
});
|
|
33
|
-
/**
|
|
34
|
-
* GraphQL 字段工作流
|
|
35
|
-
*/
|
|
36
|
-
const graphqlFieldWorkflowInfo = graphqlPathInfoStringToWorkflowInfoMap[graphqlPathInfoString];
|
|
37
|
-
let res;
|
|
38
|
-
if (graphqlGlobalWorkflowInfo) {
|
|
39
|
-
const variables = {
|
|
40
|
-
resolve,
|
|
41
|
-
source,
|
|
42
|
-
args,
|
|
43
|
-
context,
|
|
44
|
-
info,
|
|
45
|
-
fieldWorkflowInfo: graphqlFieldWorkflowInfo,
|
|
46
|
-
};
|
|
47
|
-
const executeRes = await graphqlGlobalWorkflowInfo.execute({
|
|
48
|
-
context,
|
|
49
|
-
variables,
|
|
50
|
-
});
|
|
51
|
-
res = executeRes.variables.result;
|
|
52
|
-
}
|
|
53
|
-
else if (graphqlFieldWorkflowInfo) {
|
|
17
|
+
getGraphqlWorkflowInfoResList.forEach((graphqlWorkflowInfo) => {
|
|
18
|
+
const { fieldName, typeName, workflowInfo } = graphqlWorkflowInfo;
|
|
19
|
+
const middlewareFunction = async (resolve, source, args, context, info) => {
|
|
54
20
|
const variables = {
|
|
55
21
|
resolve,
|
|
56
22
|
source,
|
|
@@ -58,20 +24,22 @@ class GraphqlWorkflowsResource extends resource_1.Resource {
|
|
|
58
24
|
context,
|
|
59
25
|
info,
|
|
60
26
|
};
|
|
61
|
-
const executeRes = await
|
|
27
|
+
const executeRes = await workflowInfo.execute({
|
|
62
28
|
context,
|
|
63
29
|
variables,
|
|
64
30
|
});
|
|
65
|
-
res = executeRes.variables.result;
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
31
|
+
const res = executeRes.variables.result;
|
|
32
|
+
return res;
|
|
33
|
+
};
|
|
34
|
+
// 确保嵌套对象存在
|
|
35
|
+
if (!middleware[typeName]) {
|
|
36
|
+
middleware[typeName] = {};
|
|
69
37
|
}
|
|
70
|
-
|
|
71
|
-
};
|
|
38
|
+
middleware[typeName][fieldName] = middlewareFunction;
|
|
39
|
+
});
|
|
72
40
|
const res = {
|
|
73
41
|
sort: 0,
|
|
74
|
-
middleware
|
|
42
|
+
middleware,
|
|
75
43
|
};
|
|
76
44
|
return res;
|
|
77
45
|
};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@ldsg/graphql-workflows",
|
|
3
|
-
"version": "0.3.
|
|
3
|
+
"version": "0.3.40",
|
|
4
4
|
"description": "",
|
|
5
5
|
"keywords": [],
|
|
6
6
|
"license": "MIT",
|
|
@@ -18,13 +18,13 @@
|
|
|
18
18
|
"graphql-middleware": "^6.1.35",
|
|
19
19
|
"graphql-yoga": "^5.13.4",
|
|
20
20
|
"zod": "^4.1.11",
|
|
21
|
-
"@ldsg/
|
|
22
|
-
"@ldsg/
|
|
23
|
-
"@ldsg/resource
|
|
24
|
-
"@ldsg/handler": "0.3.
|
|
25
|
-
"@ldsg/
|
|
26
|
-
"@ldsg/types": "0.3.
|
|
27
|
-
"@ldsg/workflow": "0.3.
|
|
21
|
+
"@ldsg/application": "0.3.40",
|
|
22
|
+
"@ldsg/graphql": "0.3.40",
|
|
23
|
+
"@ldsg/resource": "0.3.40",
|
|
24
|
+
"@ldsg/handler": "0.3.40",
|
|
25
|
+
"@ldsg/resource-definition": "0.3.40",
|
|
26
|
+
"@ldsg/types": "0.3.40",
|
|
27
|
+
"@ldsg/workflow": "0.3.40"
|
|
28
28
|
},
|
|
29
29
|
"devDependencies": {
|
|
30
30
|
"@types/jest": "^29.5.2",
|