@ldsg/graphql-workflows 0.3.41 → 0.3.42
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 +4 -0
- package/dist/constants.d.ts.map +1 -1
- package/dist/constants.js +5 -1
- package/dist/resource.d.ts.map +1 -1
- package/dist/resource.js +50 -6
- package/package.json +8 -8
package/dist/constants.d.ts
CHANGED
|
@@ -14,4 +14,8 @@ 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
|
+
/**
|
|
18
|
+
* GraphQL 全局工作流路径信息字符串
|
|
19
|
+
*/
|
|
20
|
+
export declare const GRAPHQL_GLOBAL_WORKFLOW_PATH_INFO_STRING = "*:*";
|
|
17
21
|
//# 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,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"}
|
|
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;;GAEG;AACH,eAAO,MAAM,wCAAwC,QAAQ,CAAC"}
|
package/dist/constants.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
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;
|
|
3
|
+
exports.GRAPHQL_GLOBAL_WORKFLOW_PATH_INFO_STRING = 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
|
* 实例化资源处理程序普通资源配置
|
|
@@ -31,3 +31,7 @@ exports.RESOURCE_DEFINITION_GENERAL_RESOURCE_SETTINGS = {
|
|
|
31
31
|
exports.RESOURCE_DEFINITION_SPECIFIC_RESOURCE_SETTINGS = {
|
|
32
32
|
kind: "graphql_workflows",
|
|
33
33
|
};
|
|
34
|
+
/**
|
|
35
|
+
* GraphQL 全局工作流路径信息字符串
|
|
36
|
+
*/
|
|
37
|
+
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;AAI1C,OAAO,EAA0B,wCAAwC,EAAE,MAAM,SAAS,CAAC;AAG3F,qBAAa,wBAAyB,SAAQ,QAAQ,CAAC,wCAAwC,CAAC;IAC9F,wBAAwB,EAAE,wBAAwB,CAuHhD;CACH"}
|
package/dist/resource.js
CHANGED
|
@@ -2,19 +2,63 @@
|
|
|
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");
|
|
5
7
|
class GraphqlWorkflowsResource extends resource_1.Resource {
|
|
6
8
|
constructor() {
|
|
7
9
|
super(...arguments);
|
|
8
10
|
this.getGraphqlMiddlewareInfo = () => {
|
|
9
11
|
const { getFilteredResources } = this;
|
|
10
|
-
const
|
|
11
|
-
const getGraphqlWorkflowInfoResList = getFilteredResources({
|
|
12
|
+
const graphqlWorkflowInfoList = getFilteredResources({
|
|
12
13
|
kind: "graphql_workflow",
|
|
13
|
-
})
|
|
14
|
-
|
|
15
|
-
|
|
14
|
+
})
|
|
15
|
+
.resources.filter((resource) => resource.getGraphqlWorkflowInfo)
|
|
16
|
+
.map((resource) => resource.getGraphqlWorkflowInfo());
|
|
17
|
+
const graphqlPathInfoStringToWorkflowInfoMap = {};
|
|
18
|
+
graphqlWorkflowInfoList.forEach((graphqlWorkflowInfo) => {
|
|
19
|
+
const { fieldName, typeName, workflowInfo } = graphqlWorkflowInfo;
|
|
20
|
+
const graphqlPathInfoString = `${typeName}:${fieldName}`;
|
|
21
|
+
graphqlPathInfoStringToWorkflowInfoMap[graphqlPathInfoString] = workflowInfo;
|
|
16
22
|
});
|
|
17
|
-
|
|
23
|
+
/**
|
|
24
|
+
* GraphQL 全局工作流(*.*)存在时,返回单个中间件包裹整个 schema:
|
|
25
|
+
* 每个字段解析前先执行全局工作流(如鉴权),由全局工作流内部的
|
|
26
|
+
* 「执行字段工作流或 resolve」节点按 fieldWorkflowInfo 派发或回退到原 resolver。
|
|
27
|
+
* 单函数中间件不触发 graphql-middleware 的字段存在性校验。
|
|
28
|
+
*/
|
|
29
|
+
const graphqlGlobalWorkflowInfo = graphqlPathInfoStringToWorkflowInfoMap[constants_1.GRAPHQL_GLOBAL_WORKFLOW_PATH_INFO_STRING];
|
|
30
|
+
if (graphqlGlobalWorkflowInfo) {
|
|
31
|
+
const workflowMiddleware = async (resolve, source, args, context, info) => {
|
|
32
|
+
const { graphqlPathInfoString } = (0, utils_1.getGraphqlPathInfoString)({
|
|
33
|
+
info,
|
|
34
|
+
});
|
|
35
|
+
/**
|
|
36
|
+
* GraphQL 字段工作流
|
|
37
|
+
*/
|
|
38
|
+
const graphqlFieldWorkflowInfo = graphqlPathInfoStringToWorkflowInfoMap[graphqlPathInfoString];
|
|
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
|
+
const res = executeRes.variables.result;
|
|
52
|
+
return res;
|
|
53
|
+
};
|
|
54
|
+
const res = {
|
|
55
|
+
sort: 0,
|
|
56
|
+
middleware: workflowMiddleware,
|
|
57
|
+
};
|
|
58
|
+
return res;
|
|
59
|
+
}
|
|
60
|
+
const middleware = {};
|
|
61
|
+
graphqlWorkflowInfoList.forEach((graphqlWorkflowInfo) => {
|
|
18
62
|
const { fieldName, typeName, workflowInfo } = graphqlWorkflowInfo;
|
|
19
63
|
const middlewareFunction = async (resolve, source, args, context, info) => {
|
|
20
64
|
const variables = {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@ldsg/graphql-workflows",
|
|
3
|
-
"version": "0.3.
|
|
3
|
+
"version": "0.3.42",
|
|
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/application": "0.3.
|
|
22
|
-
"@ldsg/graphql": "0.3.
|
|
23
|
-
"@ldsg/handler": "0.3.
|
|
24
|
-
"@ldsg/resource": "0.3.
|
|
25
|
-
"@ldsg/resource-definition": "0.3.
|
|
26
|
-
"@ldsg/types": "0.3.
|
|
27
|
-
"@ldsg/workflow": "0.3.
|
|
21
|
+
"@ldsg/application": "0.3.42",
|
|
22
|
+
"@ldsg/graphql": "0.3.42",
|
|
23
|
+
"@ldsg/handler": "0.3.42",
|
|
24
|
+
"@ldsg/resource": "0.3.42",
|
|
25
|
+
"@ldsg/resource-definition": "0.3.42",
|
|
26
|
+
"@ldsg/types": "0.3.42",
|
|
27
|
+
"@ldsg/workflow": "0.3.42"
|
|
28
28
|
},
|
|
29
29
|
"devDependencies": {
|
|
30
30
|
"@types/jest": "^29.5.2",
|